4 high availability y high performance.docx

59
4 High Availability y High Performance 4.1 Antecedentes Estudios recientes (IDC) han encontrado que los "downtime" o "caídas" son las causas principales al hablar de los TCO en las empresas. Caídas de algunas aplicaciones puede significar considerables pérdidas, por ejemplo: Proveedores de telecomunicaciones y operadores de redes requieren brindar sus servicios sin parar, independientemente de la información que manejan, por el simple hecho de mantener un nivel competitivo. Intituciones financieras aumentan cada día el número de usuarios y transacciones, es importante atenderlos y en el menor tiempo posible. Web sites y compañías de portales en Internet crean comunidades que también contribuyen de manera exponencial en el crecimiento de los datos . Todo lo relacionado con e-commerce representa tiendas o transacciones de gran demanda. Para estas y muchas otras compañías un downtime puede ser crucial y algo que simplemente no pueden permitir, alta disponibilidad es la solución central y crítica para su éxito. Sin HA y HP se comprometen la satisfacción del cliente y las ganancias. 4.2 High Performance Hablando de Performance existen algunas soluciones conocidas: Buen manejo de índices y memoria Denormalización 4.2.1 Manejo de índices y memoria 4.2.1.1 Indices mysql> describe book; +-------------+-----------+------+-----+---------+-------+

Upload: jose-f-casillas-lomeli

Post on 14-Apr-2015

45 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: 4 High Availability y High Performance.docx

4 High Availability y High Performance4.1 Antecedentes Estudios recientes (IDC) han encontrado que los "downtime" o "caídas" son las causas principales al hablar de los TCO en las empresas. Caídas de algunas aplicaciones puede significar considerables pérdidas, por ejemplo:

Proveedores de telecomunicaciones y operadores de redes requieren brindar sus servicios sin parar, independientemente de la información que manejan, por el simple hecho de mantener un nivel competitivo.

Intituciones financieras aumentan cada día el número de usuarios y transacciones, es importante atenderlos y en el menor tiempo posible.

Web sites y compañías de portales en Internet crean comunidades que también contribuyen de manera exponencial en el crecimiento de los datos .

Todo lo relacionado con e-commerce representa tiendas o transacciones de gran demanda.

 Para estas y muchas otras compañías un downtime puede ser crucial y algo que simplemente no pueden permitir, alta disponibilidad es la solución central y crítica para su éxito. Sin HA y HP se comprometen la satisfacción del cliente y las ganancias.  

4.2 High PerformanceHablando de Performance existen algunas soluciones conocidas:

Buen manejo de índices y memoria Denormalización

4.2.1 Manejo de índices y memoria4.2.1.1 Indices

mysql> describe book;+-------------+-----------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-------------+-----------+------+-----+---------+-------+| call_letter | char(10) | | PRI | | || call_number | float | | PRI | 0 | || call_cutter | char(50) | | PRI | | || title | char(255) | YES | MUL | NULL | || systemkey | char(10) | YES | | NULL | || series | char(255) | YES | | NULL | || year | int(11) | YES | MUL | NULL | || edition | char(255) | YES | | NULL | || publisher | char(255) | YES | MUL | NULL | || isbn | char(255) | YES | | NULL | || conference | char(255) | YES | | NULL | || corpauthor | char(255) | YES | | NULL | || alttitle | char(255) | YES | | NULL | || place | char(255) | YES | MUL | NULL | |+-------------+-----------+------+-----+---------+-------+14 rows in set (0.00 sec)mysql> show index from book; +-------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | +-------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | book | 0 | PRIMARY | 1 | call_cutter | A | 216144 | NULL | NULL | | BTREE |

Page 2: 4 High Availability y High Performance.docx

| | book | 0 | PRIMARY | 2 | call_number | A | 216144 | NULL | NULL | | BTREE | | | book | 0 | PRIMARY | 3 | call_letter | A | 216144 | NULL | NULL | | BTREE | | | book | 1 | book_idx_1 | 1 | year | A | 17 | NULL | NULL | YES | BTREE | | | book | 1 | book_idx_2 | 1 | title | A | 216144 | NULL | NULL | YES | BTREE | | | book | 1 | book_idx_3 | 1 | publisher | A | 108072 | NULL | NULL | YES | BTREE | | | book | 1 | book_idx_4 | 1 | place | A | 13509 | NULL | NULL | YES | BTREE | | +-------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ 7 rows in set (3.16 sec)mysql> explain select * from book where call_letter='QA' and call_number between 75.9999 and 76.0001; +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+ | 1 | SIMPLE | book | ALL | NULL | NULL | NULL | NULL | 216144 | Using where | +----+-------------+-------+------+---------------+------+---------+------+--------+-------------+ 1 row in set (0.00 sec)mysql> explain select * from book where call_letter='QA' and call_number between 75.9999 and 76.0001 and call_cutter='/abc'; +----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+ | 1 | SIMPLE | book | range | PRIMARY | PRIMARY | 64 | NULL | 1 | Using where | +----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+ 1 row in set (0.04 sec)

 4.2.1.2 Memoria

 

Page 3: 4 High Availability y High Performance.docx

 global buffers + (session buffers* maxconnections) = RAM Mem

Donde se puede observar que el total de la memoria empleada por el manejador de base de datos está repartido entre una sección global y otra dedicada cada conexión de los usuarios.

session buffers sort_buffer myisam_soft_buffer read_buffer join_buffer read_rnd_buffer

global buffers key_buffer innodb_buffer_pool innodb_log_buffer innodb_additional_mem_po

ol net_buffer

  

# The following options will be passed to all MySQL clients

Page 4: 4 High Availability y High Performance.docx

[client]

#password = your_passwordport = 3306socket = /tmp/mysql.sock# Here follows entries for some specific programs# The MySQL server[mysqld] port = 3306 socket = /tmp/mysql.sock skip-locking #set-variable = key_buffer=64M #set-variable = max_allowed_packet=300M #set-variable = table_cache=500 #set-variable = sort_buffer=32M set-variable = net_buffer_length=64M #set-variable = myisam_sort_buffer_size=16M set-variable = max_connections=500 #set-variable = interactive_timeout=604800 set-variable = wait_timeout=604800 #set-variable = thread_stack=64M set-variable = tmp_table_size=32M set-variable = back_log=100 #set-variable = binlog_cache_size=64M set-variable = connect_timeout= 45 set-variable = join_buffer_size=2M #set-variable = key_buffer_size=64M set-variable = long_query_time=604800 set-variable = max_binlog_cache_size=1000M set-variable = max_binlog_size=1000M set-variable = net_read_timeout=300 set-variable = net_write_timeout=300 set-variable = net_retry_count=50 #set-variable = preload_buffer_size=16M #set-variable = query_cache_size=128M #set-variable = sort_buffer_size=64M #set-variable = thread_cache_size=100 set-variable = key_buffer=64M set-variable = max_allowed_packet=300M set-variable = table_cache=512 set-variable = sort_buffer_size=2M set-variable = read_buffer_size=2M set-variable = read_rnd_buffer_size=8M set-variable = myisam_sort_buffer_size=64M set-variable = thread_cache=8 set-variable = query_cache_size=32M # Try number of CPU's*2 for thread_concurrency set-variable = thread_concurrency=8

#log-bin server-id = 1# Point the following paths to different dedicated disks tmpdir = /var/tmp/ #log-update = /centia01/final/database/mysql/var/log-catarina# Uncomment the following if you are using BDB tables set-variable = bdb_cache_size=4M set-variable = bdb_max_lock=10000# Uncomment the following if you are using Innobase tables innodb_file_per_table innodb_data_file_path = ibdata1:1G:autoextend innodb_data_home_dir = /mysql/data/innodb innodb_log_group_home_dir = /mysql/data/innodb innodb_log_arch_dir = /mysql/data/innodb set-variable = innodb_mirrored_log_groups=1 set-variable = innodb_log_files_in_group=5 set-variable = innodb_log_file_size=400M set-variable = innodb_log_buffer_size=256M innodb_flush_log_at_trx_commit=1 innodb_log_archive=0 set-variable = innodb_buffer_pool_size=2000M set-variable = innodb_additional_mem_pool_size=256M set-variable = innodb_file_io_threads=4 set-variable = innodb_lock_wait_timeout=50 #set-variable = innodb_force_recovery=3

Page 5: 4 High Availability y High Performance.docx

[mysqldump] quick set-variable = max_allowed_packet=300M[mysql] prompt=(\u) [\d]>\_ no-auto-rehash # Remove the next comment character if you are not familiar with SQL #safe-updates[isamchk] set-variable = key_buffer=20M set-variable = sort_buffer=20M set-variable = read_buffer=2M set-variable = write_buffer=2M[myisamchk] set-variable = key_buffer=20M set-variable = sort_buffer=20M set-variable = read_buffer=2M set-variable = write_buffer=2M[mysqlhotcopy] interactive-timeout

Configuración my.cnf

 4.2.2 DenormalizaciónSe puede definir como el proceso de poner la misma información en varios lugares.Una normalización reduce problemas de integridad y optimiza las actualizaciones, quizás con el costo del tiempo de recuperación. Cuando se pretende evitar esta demora resultado de la combinación de muchas tablas entonces se puede utilizar la denormalización.Antes de denormalizar es importante considerar:

El sistema puede tener un desempeño aceptable sin la denormalización ? Aún con la denormalización el desempeño será siendo malo ? El sistema será menos confiable debido a la denormalización ?

Candidatos a denormalización: Numerosas consultas críticas o reportes incluyen datos que incluyen más de una

tabla. Grupos repetidos de elementos necesitan ser procesados en un grupo en lugar de

individualmente. Muchos cálculos necesitan realizarse a una o más columnas antes de procesar las

consultas. Las tablas necesitan ser accesadas de diferentes maneras por diferentes usuarios

durante el mismo lapso de tiempo. Llaves primarias mal diseñadas que requieren tiempo al usarlas en relaciones. Algunas columnas son interrogadas un gran porcentaje del tiempo.

Importante: nunca se realiza un denormalización en un modelo lógico.Prejoined TablesCuando 2 tablas se mezclan (join) frecuentemente, considerar tener una tabla premezclada (prejoined) la cual debera:

Contener columnas que no sean redundantes Contener sólo aquellas columnas absolutamente necesarias para las necesidades de

la aplicación

Page 6: 4 High Availability y High Performance.docx

Ser creada periodicamente utilizando las tablas normalizadas (que forman el join)Ventaja: consultas rápidas y eficientesDesventaja: la tabla puede quedar inconsistente rapidamente, se recomienda para datos más estáticos que dinámicos.Report TablesMantener reportes en línea puede ser muy costoso, es mejor considerar tener una tabla que incluya los datos de dicho reporte.Dicha tabla deberá contener:

Una columna por cada columna del reporte Tener sus tuplas ordenadas secuencialmente en el mismo orden que deben aparecer

en el reporte (evitando ordenamientos) Elementos atómicos (1NF)

Mirror TablesEn ocasiones algún departamento de la organización necesita consultar mientras otro hace modificaciones, se pueden usar dos tablas para balancear la carga y obtener buen tiempo de acceso y modificación.Se debe tener un esquema de duplicación que permita actualizar el espejo de manera eficiente, esto puede hacerse:

A través de un proceso batch, que es bastante rápido Directamente con herramientas de replicación y propagación del dbms

  Split TablesSi la cantidad de información es considerable se puede pensar en partir una tabla ya sea vertical u horizontalmente

Vertical: implica conservar en ambas la llave primaria para tener una integridad referencial

Horizontal: consiste en separar las tuplas por rangos, los cuales se basan en algun criterio particular.

También se puede considerar el separar columnas:create table item

(itemnum integer not null,itemsize char(1), itemcolor char(10), itemdescr char(100))

 se dividiría en:

create table item (itemnum integer not null,itemsize char(1),itemcolor char(10),itemdescr char(10))

create table item_desc(itemnum integer not null, itemdescr char(90))

o bien

create table item_desc(itemnum integer not null,itemctr integer not null,itemdescr char(100))

Page 7: 4 High Availability y High Performance.docx

 Combined TablesDada una relacion 1-1, combinar las 2 tablas en una solaSe complica si hay otras relaciones involucradas, otra relación 1-m implicaría demasiada redundancia y un aumento considerable del tiempo para actualizaciones.Redundant DataCuando alguna columna de una tabla (A) es solicitada frecuentemente en una consulta de alguna otra tabla (B) entonces vale la pena agregar dicha columna de (A) en (B).Dichas columnas serán redundantes y deberán cumplir con:

Sólo ser pocas las columnas involucradas No deben necesitan actualizaciones frecuentes Deben usarse por un gran número de usuarios y por pocos pero importantes

Repeating GroupsMuchas veces la repetición de tuplas puede transformase en varias columnas de la misma tupla

create table cust_balance( custnum integer not null,balanceperiod integer not null,balance float)

 

create table cust_balance( custnum integer not null,period1_balance float,period2_balance float,period3_balance float,period4_balance float,period5_balance float,period6_balance float)

 Criterio:

Datos son raramente o nunca agregados, promediados o comparados dentro de una tupla

Los datos aparecen en un comportamiento estático y bajo un patrón Se puede calcular el número de ocurrencias Los datos se accesan colectivamente (grupos)

  Derivable DataSimilar al de reportes para minimizar muchas fórmulas, se usa cuando:

La fuente de los datos involucrados son relativamente estáticos.

Page 8: 4 High Availability y High Performance.docx

El costo de aplicar el cálculo es demasiado alto. Es factible realizar el recálculo si es que los datos son modificados.

 Hierarchies

create table dept( parentdeptnum integer not null,deptname char(25),supervisornum integer,reportstodeptnum integer)

 

create table dept( deptnum integer not null,childdeptnum integer not null,level integer,detail char(1),deptname char(25),supervisornum integer)

 Dos columnas adicionales se incorporaron:level, contiene un valor numérico indicando el nivel dentro de la jerarquía del childdeptnum; si el hijo reside 2 niveles abajo en la jerarquía del padre entonces el level será 2.detail, contiene una "Y" si el childdeptnum esta hasta abajo de la jerarquía, "N" de otra manera. Implementación física especialPartir una tabla de manera que su tamaño se aproxime al de la página que maneja el dbms. 

4.3 High AvailabilityRespecto a disponibilidad existen también diferentes soluciones

Replication Clustering

3.3.3.1 Replication [HOWTO] MySQL Replication

About: It took me days to figure out how to replicate database in MySQL, and the official docs are somewhat sparse. Hopefully this will help -- it's geared towards any general MySQL installation.

Edit: This guide only works with MyISAM table types (the default for MySQL).

The Master Server

Page 9: 4 High Availability y High Performance.docx

MySQL replicates the data between the two databases by using binary logs stored on the master server. The first step is to setup the server so it creates them.

Create a directory to store the binary logs

This creates the directories and sets the permissions so only the mysql daemon can read/write to the logs.Code:

$ mkdir /var/log/mysql/binary $ chown mysql: /var/log/mysql/binary

$ chmod 770 /var/log/mysql/binary

Edit the MySQL Configuration

This turns on the binary logging, tells it where to store the logs, and creates a server id.

Code:

$ vim /etc/mysql/my.cnf

Add under the [mysqld] section. It doesn't matter what the value for server-id is, as long as it is different from the slave's (which you will set later). Also make sure that "bind ip_address" and "skip-networking" are commented out, so that the slave user can log in remotely.

Code:

log-bin=/var/log/mysql/binary/mysql_binary_log

binlog-do-db=database_name server-id=1

Once you're done, restart the mysql server for the changes to take effect, and for the logging to start.

Code:

/etc/init.d/mysql restart

If you were already using binary logging before this, you don't need to make any changes, except for adding a server-id. The slave can keep up with your current binary logs, so there's no reason to delete them or flush the logs.

Setup a slave account

This both creates a new account in mysql.user, and grants replication privileges only .

Code:

Page 10: 4 High Availability y High Performance.docx

$ msyql mysql> GRANT REPLICATION SLAVE ON database_name TO 'slave_user_name'@'%' IDENTIFIED BY 'slave_password';

Adding "@'%'" means that "slave_user_name" can connect from any host. Change yours to whatever host name options you want to use.

AFAIK, you don't need to run FLUSH PRIVILEGES; in mysql for it to recognize the new account.

Get a database dump

There are two ways to get the data from the master to the slave -- this howto only covers one: exporting the actual data to a file, and then restoring it on the slave. The other option is LOAD DATA FROM MASTER; which does pretty much the same thing.

Note that you will need to have two shells open at this point -- one mysql shell and one terminal shell. The mysql shell must stay open while you do the database dump to get a clean export.

Switch to the database you want to replicate. FLUSH TABLES only locks the database you're currently using.

Code:

mysql> USE database_name; mysql> FLUSH TABLES WITH READ LOCK;

Once again, do NOT close your mysql session until you do a mysqldump in another shell (screen comes in handy). If you do, the tables will be unlocked.

Code:

mysql> SHOW MASTER STATUS;

Once you get the MASTER STATUS results, WRITE THEM DOWN because you'll need them in a minute. Should look something like this:

Code:

+----------------------+----------+--------------+------------------+ | File                 | Position | Binlog_do_db | Binlog_ignore_db | +----------------------+----------+--------------+------------------+ | mysql_binary_log.025 | 796947   | database_name|                  |

+----------------------+----------+--------------+------------------+ 1 row in set (0.00 sec)

Get the db dump:

Code:

$ mysqldump --opt database_name > database_name.sql

Page 11: 4 High Availability y High Performance.docx

and unlock the tables

Code:

mysql> UNLOCK TABLES;

You're done now with the master server.

The Slave Server

Import the mysqldump from the master server:

Code:

mysql database_name < database_name.sql

Edit the slave's MySQL configuration to setup replication:

Code:

$ vim /etc/mysql/my.cnf

Add under the [mysqld] section. It doesn't matter what the value for server-id is, as long as it is different from the master's.

Code:

server-id=2 # master server settings master-host=masterhost.com master-user=slave_user_name master-password=slave_password master-connect-retry=60 # num of seconds, default is 60

replicate-do-db=database_name

Restart MySQL -- don't worry, it won't start slaving yet.

Code:

/etc/init.d/mysql restart

Tell the slave specifically where to start logging:

This is where you use the data from SHOW MASTER STATUS; from the master mysql database.

Code:

mysql> CHANGE MASTER TO MASTER_HOST='master_host_name', MASTER_USER='slave_user_name', MASTER_PASSWORD='slave_password',

Page 12: 4 High Availability y High Performance.docx

MASTER_LOG_FILE='mysql_binary_log.025', MASTER_LOG_POS=796947;

Note that you don't put quotes around the value for MASTER_LOG_POS or mysql will give you an error.

Now start slaving!

Code:

mysql> START SLAVE;

And that's it!

 

4.3.2 Clustering4.3.2.1 Definición Qué es Clustering ?

En general, cuando las personas hablan de clusters, se refieren a tecnologías que permiten a múltiples computadoras trabajar conjuntamente para resolver problemas comunes.

Dichos problemas puede ser casi cualquier cosa, desde cálculos complejos que implican uso intensivo del CPU, hasta manejar una enorme cantidad de procesos que no tienen nada en común.

Actualmente por ejemplo los clusters Beowulf (múltiples máquinas conectadas a través de una LAN de gran velocidad) creados con Linux pueden ser bastante comunes y populares.

 Un cluster puede hacerse de distintas maneras y con distintos propósitos.

Formando un máquina enorme Buscando balanceo de procesos y memoria De bases de datos Combinaciones de las anteriores

The following are various cluster types found in use today. If you use or intend to use one of these cluster types, you may want to consider SSI clustering as an alternative or addition.

High performance (HP) clusters, typified by Beowulf clusters , are constructed to run parallel programs (weather simulations, data mining, etc.).

Load-leveling clusters, typified by Mosix , are constructed to allow a user on one node to spread his workload transparently across all nodes in the cluster. This can be very useful for compute intensive, long running jobs that aren't massively parallel.

Web-service clusters, typified by the Linux Virtual Server (LVS) project and Piranha , do a different kind of load leveling. Incoming web service requests are load-leveled by a front end system across a set of standard servers.

Storage clusters, typified by Sistina's GFS and the OpenGFS project , consist of nodes which supply parallel, coherent, and highly available access to filesystem data.

Page 13: 4 High Availability y High Performance.docx

Database clusters, typified by Oracle 9I RAC (formerly Oracle Parallel Server), consist of nodes which supply parallel, coherent, and HA access to a database.

High Availability clusters, typified by Lifekeeper , FailSafe and Heartbeat , are also often known as failover clusters. Resources, most importantly applications and nodes, are monitored. When a failure is detected, scripts are used to fail over IP addresses, disks, and filesystems, as well as restarting applications.

 4.3.2.2 Cluster de Bases de Datos Caso MySQL

Lanzado en el 2004, es el primer cluster de bases de datos open source Al igual que con el dbms, el cluster es simple, confiable, administrable. Provee solución para HA y HP

Un NDB Cluster database consiste de una colección de nodos de 3 tipos:1. Uno o más management servers (MGM nodes)2. Uno o más database/storage nodes (DB nodes)3. Uno o más applications (API nodes)Un nodo es un programa ejecutándose en alguna computadora Los nodos pueden correr en diferentes computadoras (o en la misma) y se comunican a través de módulos de software llamados "transporters".Funcionamiento

Los datos son síncronamente replicados entre los storage nodes, esto reduce al mínimo problemas de caídas por fail-over.

Los nodos están diseñados usando una arquitectura "share-nothing". No hay puntos de falla (points of failure). Cualquien nodo puede ser eliminado sin

existir pérdida de datos y sin detener las aplicaciones que usan la base. El empleo de SQL es transparente lo cual simplifica el trabajo de developers y

DBAs. Las aplicaciones se conectan al servidor sin reparar en detalles específicos de como

se encuentra almacenada la información o como son las conexiones de red. Lo anterior permite que una aplicacion sea "portable" entre ambientes donde existe

o no replication y donde existe o no clustering.  

Page 14: 4 High Availability y High Performance.docx

 

Node y System Recovery Cuando un nodo presenta una falla, al recuperarse restaura toda la información

auxiliándose de otros nodos.

Page 15: 4 High Availability y High Performance.docx

Al igual que en la versión sin cluster, éste maneja bitácoras y errores que permiten mantener íntegra y consistente la inf

El cluster utiliza "pessimistic concurrency control based on locking".  Ejemplos de configuraciones:

 

Failed Nodes Computers Recovery Procedure{D2} System Restart

 

 

Failed Nodes Computers Recovery Procedure

Page 16: 4 High Availability y High Performance.docx

{D2}, {D3} Node Recovery{D2, D3} System Restart

{C1}, {C2}Node Recovery (after computer is replaced/restarted)

{C3}, {C4}, {C3, C4}

Restart Applications and Management Server

 

Failed Nodes Computers Recovery Procedure{D2}, {D3}, {D2, D4}, {D2, D5}, {D3, D4}, {D3,D5}

Node Recovery

{D2, D3}, {D4, D5}+ all three node failures

System Restart

{C1}, {C2}Node Recovery (after computer is replaced/restarted)

{C3}, {C4}, {C3, C4}Restart Applications and Management Server

  

Page 17: 4 High Availability y High Performance.docx

 

Failed Nodes Computers Recovery Procedure{D2}, {D3}, ..., {D9} Node Recovery{D2,D3}, {D4,D5}, {D6,D7}, {D8,D9} System Restart{D2,D4}, {D2,D5}, {D2,D6}, {D2,D7}, {D2,D8}, {D2,D9}

Node Recovery

{D3,D4}, {D3,D5}, {D3,D6}, {D3,D7}, {D3,D8}, {D3,D9}

Node Recovery

{D4,D6}, {D4,D7}, {D4,D8}, {D4,D9} Node Recovery{D5,D6}, {D5,D7}, {D4,D8}, {D4,D9} Node Recovery{D6,D8}, {D6,D9} Node Recovery{D7,D8}, {D7,D9} Node Recovery

{C1}, {C2}Node Recovery if Arbitrator survived

{C1}, {C2}System Restart if Arbitrator did not survive

{C3}, {C4}, {C3, C4}Restart Applications and Management Server

Implementación

Partimos de una configuración básica cona las siguientes máquinas

Función Host PortManager agua 9000Transport agua 9099

Page 18: 4 High Availability y High Performance.docx

Monitor (Manager client) agua -Storage y API scanner 9001Storage y API ict 9002API santa 9003Balancer ict 9999

 

Manager Storage1 Storage2 API Balanceragua scanner ict santa ictBajar el binario de la plataforma,en este caso lo más recomendable es la versión4.1.9 Max de Solaris 8 Sparc 32 bits.mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz/carlos>gunzip mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz/carlos>tar -xvf mysql-max-4.1.9-sun-solaris2.8-sparc.tar..../carlos>mv mysql-max-4.1.9-sun-solaris2.8-sparc mysql_manager/carlos>cd mysql_managereditar el archivo nuevo

Page 19: 4 High Availability y High Performance.docx

config.ini/mysql_manager>vi config.ini

[NDBD DEFAULT]NoOfReplicas=2[MYSQLD DEFAULT][NDB_MGMD DEFAULT][TCP DEFAULT]PortNumber=9099 # Managment Server[NDB_MGMD]HostName=agua.udlap.mx # the IP of THIS SERVERPortNumber=9000 # Storage Engines[NDBD]HostName=scanner.udlap.mx # the IP of the FIRST SERVERDataDir= /archivos/vol880-12/carlos/mysql_1/cluster[NDBD]HostName=ict.udlap.mx # the IP of the

Bajar el binario de la plataforma,en este caso lo más recomendable es la versión4.1.9 Max de Solaris 8 Sparc 32 bits.mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz/carlos>gunzip mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz/carlos>tar -xvf mysql-max-4.1.9-sun-solaris2.8-sparc.tar..../carlos>mv mysql-max-4.1.9-sun-solaris2.8-sparc mysql_1

/carlos>cd mysql_1/mysql_1>cp support-files/my-medium.cnf data/my.cnfeditamos el archivo de configuracion/mysql_1>vi data/my.cnf

[client]#password =

Bajar el binario de la plataforma,en este caso lo más recomendable es la versión4.1.9 Max de Solaris 8 Sparc 32 bits.mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz/carlos>gunzip mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz/carlos>tar -xvf mysql-max-4.1.9-sun-solaris2.8-sparc.tar..../carlos>mv mysql-max-4.1.9-sun-solaris2.8-sparc mysql_2

/carlos>cd mysql_2/mysql_2>cp support-files/my-medium.cnf data/my.cnfeditamos el archivo de configuracion/mysql_2>vi data/my.cnf

[client]#password =

Bajar el binario de la plataforma,en este caso lo más recomendable es la versión4.1.9 Max de Solaris 8 Sparc 32 bits.mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz/carlos>gunzip mysql-max-4.1.9-sun-solaris2.8-sparc.tar.gz/carlos>tar -xvf mysql-max-4.1.9-sun-solaris2.8-sparc.tar..../carlos>mv mysql-max-4.1.9-sun-solaris2.8-sparc mysql_api

/carlos>cd mysql_api/mysql_api>cp support-files/my-medium.cnf data/my.cnfeditamos el archivo de configuracion/mysql_api>vi data/my.cnf

[client]#password =

Page 20: 4 High Availability y High Performance.docx

SECOND SERVERDataDir=/archivos/vol880-12/carlos/mysql_2/cluster# 2 MySQL Clients# I personally leave this blank to allow rapid changes of the mysql clients;# you can enter the hostnames of the above two servers here. I suggest you dont.[MYSQLD][MYSQLD][MYSQLD]

iniciamos el manager/mysql_manager>bin/ndb_mgmd -f config.inilisto el manager ya esta corriendo/mysql_manager>bin/ndb_mgm --connect-string=agua.udlap.mx:9000ndb_mgm>

your_passwordport = 9001socket = /tmp/mysql_1.sock# Here follows entries for some specific programs# The MySQL server[mysqld]port = 9001socket = /tmp/mysql_1.sockndbclusterndb-connectstring=agua.udlap.mx:9000....[mysql_cluster]ndb-connectstring=agua.udlap.mx:9000[mysqldump]quickmax_allowed_packet = 16M

/mysql_1>scripts/mysql_install_db/mysql_1>cp support-files/mysql.server ./mysql_1>vi mysql.server

basedir=/archivos/vol880-12/carlos/mysql_1# The following variables are

your_passwordport = 9002socket = /tmp/mysql_2.sock# Here follows entries for some specific programs# The MySQL server[mysqld]port = 9002socket = /tmp/mysql_2.sockndbclusterndb-connectstring=agua.udlap.mx:9000....[mysql_cluster]ndb-connectstring=agua.udlap.mx:9000[mysqldump]quickmax_allowed_packet = 16M

/mysql_2>scripts/mysql_install_db/mysql_2>cp support-files/mysql.server ./mysql_2>vi mysql.server

basedir=/archivos/vol880-12/carlos/mysql_2# The following variables are

your_passwordport = 9003socket = /tmp/mysql_3.sock# Here follows entries for some specific programs# The MySQL server[mysqld]port = 9003socket = /tmp/mysql_3.sockndbclusterndb-connectstring=agua.udlap.mx:9000....[mysql_cluster]ndb-connectstring=agua.udlap.mx:9000[mysqldump]quickmax_allowed_packet = 16M

/mysql_api>scripts/mysql_install_db/mysql_api>cp support-files/mysql.server ./mysql_api>vi mysql.server

basedir=/archivos/vol880-12/carlos/mysql_api# The following variables are

Page 21: 4 High Availability y High Performance.docx

showConnected to Management Server at: localhost:9000Cluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 (not connected, accepting connect from scanner.udid=3 (not connected, accepting connect from ict.udlap.[ndb_mgmd(MGM)] 1 node(s)id=1 @140.148.3.104 (Version: 4.1.9)[mysqld(API)] 3 node(s)id=4 (not connected, accepting connect from any host)id=5 (not connected, accepting connect from any host)id=6 (not connected, accepting connect from any host)ndb_mgm> show

only set for letting mysql.server find things.# Set some defaultsdatadir=/archivos/vol880-12/carlos/mysql_1/data

/mysql_1>chmod 755 mysql.server/mysql_1>mkdir cluster/mysql_1>bin/ndbd --connect-string=agua.udlap.mx:9000 --initial/mysql_1>./mysql.server start

/mysql_1>bin/mysql -u root --protocol=tcp -P 9001 -p mysql

only set for letting mysql.server find things.# Set some defaultsdatadir=/archivos/vol880-12/carlos/mysql_2/data

/mysql_2>chmod 755 mysql.server/mysql_2>mkdir cluster

/mysql_2>bin/ndbd --connect-string=agua.udlap.mx:9000 --initial/mysql_2>./mysql.server start

only set for letting mysql.server find things.# Set some defaultsdatadir=/archivos/vol880-12/carlos/mysql_api/data

/mysql_api>chmod 755 mysql.server

/mysql_api>./mysql.server start

Page 22: 4 High Availability y High Performance.docx

Cluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 (not connected, accepting connect from scanner.udlap.mx)id=3 (not connected, accepting connect from ict.udlap.mx)[ndb_mgmd(MGM)] 1 node(s)id=1 @140.148.3.104 (Version: 4.1.9)[mysqld(API)] 3 node(s)id=4 (not connected, accepting connect from any host)id=5 (not connected, accepting connect from any host)id=6 (not connected, accepting connect from any host)

Enter password: Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -AWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1 to server version: 4.1.9-max-logType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> show databases;+------------+| Database |+------------+| aplicacion || mysql || test |+------------+3 rows in set (0.00 sec)mysql> create database ejemplo;Query OK, 1 row affected (0.30 sec)mysql> use ejemplo;Database changedmysql> create table usuarios (id int) ENGINE=NDBCLUSTER;Query OK, 0 rows affected (1.27 sec)

/mysql_2>bin/mysql -u root --protocol=tcp -P 9002 -p mysqlEnter password: Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -AWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1 to server version: 4.1.9-max-logType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> show databases;+------------+| Database |+------------+| aplicacion || mysql || test |+------------+3 rows in set (0.01 sec)

/mysql_api>bin/mysql -u root --protocol=tcp -P 9003 -p mysqlEnter password: Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -AWelcome to the MySQL monitor.

Page 23: 4 High Availability y High Performance.docx

ndb_mgm> showCluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 @140.148.3.214 (Version: 4.1.9, starting, Nodegroup: 0, Master)id=3 (not connected, accepting connect from ict.udlap.mx)[ndb_mgmd(MGM)] 1 node(s)id=1 @140.148.3.10

insert into usuarios values (555);Query OK, 1 row affected (0.01 sec)mysql> select * from usuarios;+------+| id |+------+| 555 |+------+1 row in set (0.00 sec)mysql>

mysql> create database ejemplo;Query OK, 1 row affected (0.09 sec)mysql> use ejemplo;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> show tables;+-------------------+| Tables_in_ejemplo |+-------------------+| usuarios |+-------------------+1 row in set (0.01 sec)mysql> select * from usuarios;+------+| id |+------+| 555 |+------+1 row in set (0.00 sec)mysql>

Commands end with ; or \g.Your MySQL connection id is 1 to server version: 4.1.9-max-logType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> show databases;+----------+| Database |+----------+| mysql || test |+----------+2 rows in set (0.00 sec)mysql> create database ejemplo;Query OK, 1 row affected (0.07 sec)mysql> use ejemplo;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> show tables;+-------------------+| Tables_in_ejemplo |+-------------------+| usuarios |+-------------------+1 row in set (0.01 sec)

Descargamos algun software de balanceo como:http://siag.nu/pen/http://www.inlab.de/balance.htmlEn el caso de solaris recomiendo el primero./carlos>tar -xvf pen-0.15.0.tar/carlos> cd pen-0.15.0/pen-0.15.0> ./configure/pen-0.15.0> makeSi ocurre algun problema de compilacion se puede corregir usando las variables de ambiente de mi cuenta>csh (Si se esta en un shell diferente)>source ~carlos/.cshrc

Page 24: 4 High Availability y High Performance.docx

4 (Version: 4.1.9)[mysqld(API)] 3 node(s)id=4 (not connected, accepting connect from any host)id=5 (not connected, accepting connect from any host)id=6 (not connected, accepting connect from any host)

ndb_mgm> showCluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 @140.148.3.214 (Version: 4.1.9, starting, Nodegroup: 0)id=3 @140.148.155.147 (Version: 4.1.9, starting, Nodegroup: 0, Master)[ndb_mgmd(MGM)] 1 node(s)id=1 @140.148.3.10

mysql> select * from usuarios;+------+| id |+------+| 555 |+------+1 row in set (0.00 sec)

mysql> select * from usuarios;+------+| id |+------+

mysql>set autocommit=0;mysql> insert into usuarios values(455);Query OK, 1 row affected (0.23 sec)mysql> select * from usuarios;+------+| id |+------+| 555 |+------+| 455 |+------+

2 row in set (0.07 sec)

mysql> select * from usuarios;+------+| id |+------+| 555 |+------+1 row in set (0.00 sec)mysql>

mysql> select * from usuarios;+------+| id |

/pen-0.15.0> ./pen -r 9999 santa:9003 scanner:9001 ict:9002o/pen-0.15.0> pen -dfr 9999 santa:9003 scanner:9001 ict:9002(si se desea hacer el debug)

/mysql_x>bin/mysql -u lolo --protocol=tcp -h ict -P 9999 -p ejemploEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 5 to server version: 4.1.9-max-logType 'help;' or '\h' for help. Type '\c' to clear the buffer.

Page 25: 4 High Availability y High Performance.docx

4 (Version: 4.1.9)[mysqld(API)] 3 node(s)id=4 (not connected, accepting connect from any host)id=5 (not connected, accepting connect from any host)id=6 (not connected, accepting connect from any host)

| 555 |+------+| 455 |+------+1 row in set (0.62 sec)mysql>

mysql> delete from user where host='scanner';Query OK, 2 rows affected (0.01 sec)mysql> delete from user where user='';Query OK, 1 row affected (0.00 sec)mysql> insert into user (host,user,password) values

mysql> commit;mysql>

mysql> quitBye/mysql_2>bin/ndbd --connect-string=agua.udlap.mx:9000

/mysql_2>bin/mysql -u root --protocol=tcp -P 9002 -p mysql

+------+| 555 |+------+| 455 |+------+2 row in set (0.03 sec)mysql>

mysql> delete from user where host='santa';Query OK, 2 rows affected (0.00 sec)mysql> delete from user where

mysql> show tables;+-------------------+| Tables_in_ejemplo |+-------------------+| usuarios |+-------------------+1 row in set (0.02 sec)

mysql> insert into usuarios values (123);Query OK, 1 row affected (0.01 sec)mysql> select * from usuarios;+------+| id |+------+| 555 |+------+| 455 |+------+| 123 |+------+2 row in set (0.00 sec)

Page 26: 4 High Availability y High Performance.docx

ndb_mgm> showCluster Configuration---------------------[ndbd(NDB)] 2

('%','lolo',password('lolopass'));Query OK, 1 row affected (0.01 sec)mysql> insert into db values('%','ejemplo','lolo','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');Query OK, 1 row affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.16 sec)

Enter password:Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -AWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1 to server version: 4.1.9-max-logType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> delete from user where host='ict';Query OK, 2 rows affected (0.11 sec)mysql> delete from user where user='';Query OK, 1 row affected (0.00 sec)mysql> insert into user (host,user,password) values ('%','lolo',password('lolopass'));Query OK, 1 row affected (0.00 sec)mysql> insert into db values('%','ejemplo','lolo','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');Query OK, 1 row

user='';Query OK, 1 row affected (0.00 sec)mysql> insert into user (host,user,password) values ('%','lolo',password('lolopass'));Query OK, 1 row affected (0.00 sec)mysql> insert into db values('%','ejemplo','lolo','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');Query OK, 1 row affected (0.02 sec)mysql> flush privileges;Query OK, 0 rows affected (0.21 sec)

mysql> show processlist;+----+------

mysql> quitBye

ict:carlos:DragonCorp>bin/mysql -u lolo --protocol=tcp -h ict -P 9999 -p ejemploEnter password: Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -AWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4 to server version: 4.1.9-max-logType 'help;' or '\h' for help. Type '\c' to clear the

Page 27: 4 High Availability y High Performance.docx

node(s)id=2 @140.148.3.214 (Version: 4.1.9, Nodegroup: 0, Master)id=3 @140.148.155.147 (Version: 4.1.9, Nodegroup: 0)[ndb_mgmd(MGM)] 1 node(s)id=1 @140.148.3.104 (Version: 4.1.9)[mysqld(API)] 3 node(s)id=4 @140.148.3.214 (Version: 4.1.9)id=5 @140.148.155.147 (Version: 4.1.9)id=6 @140.148.3.247 (Version: 4.1.9)ndb_mgm>

mysql> show processlist;+----+------+------------------------+---------+---------+------+-------

affected (0.02 sec)mysql> flush privileges;Query OK, 0 rows affected (0.20 sec)

+------------------------+---------+---------+------+-------+------------------+| Id | User | Host | db | Command | Time | State | Info |+----+------+------------------------+---------+---------+------+-------+------------------+| 1 | lolo | ict.pue.udlap.mx:60982 | ejemplo | Sleep | 19 | | NULL || 2 | root | localhost:46899 | mysql | Query | 0 | NULL | show processlist |+----+------+------------------------+---------+---------+------+-------+------------------+2 rows in set (0.00 sec)mysql>

mysql> quitBye/mysql_api>./mysql.server stopKilling mysqld with pid 18960Wait for mysqld to exit.. done

buffer.mysql> show tables;+-------------------+| Tables_in_ejemplo |+-------------------+| usuarios |+-------------------+1 row in set (0.02 sec)mysql> select * from usuarios2;+------+| id |+------+| 555 |+------+| 455 |+------+| 123 |+------+2 row in set (0.00 sec)

mysql> select *

Page 28: 4 High Availability y High Performance.docx

ndb_mgm> 3 stopNode 3 has shutdown.ndb_mgm> showCluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 @140.148.3.214 (Version: 4.1.9, Nodegroup: 0, Master)id=3 (not connected, accepting connect from ict.udlap.mx)[ndb_mgmd(MGM)] 1 node(s)id=1 @140.148.3.104 (Version: 4.1.9)

+------------------+| Id | User | Host| db | Command | Time| State | Info |+----+------+------------------------+---------+---------+------+-------+------------------+| 1 | root | localhost:60102| mysql | Query | 0| NULL | show processlist || 8 | lolo | ict.pue.udlap.mx:60928| ejemplo | Sleep | 18| | NULL |+----+------+------------------------+---------+---------+------+-------+------------------+2 rows in set (0.00 sec)

mysql> quitBye/mysq_1>./mysql.server stopKilling mysqld with pid 25010Wait for mysqld to exit.. done/mysq_1>

/mysql_apì> from usuarios;ERROR 2013 (HY000): Lost connection to MySQL server during querymysql> select * from usuarios;ERROR 2006 (HY000): MySQL server has gone awayNo connection. Trying to reconnect...Connection id: 1Current database: ejemplo+------+| id |+------+| 555 |+------+| 455 |+------+| 123 |+------+2 row in set (0.06 sec)mysql>

Page 29: 4 High Availability y High Performance.docx

[mysqld(API)] 3 node(s)id=4 @140.148.3.214 (Version: 4.1.9)id=5 @140.148.155.147 (Version: 4.1.9)id=6 @140.148.3.247 (Version: 4.1.9)

ndb_mgm> showCluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 @140.148.3.214 (Version: 4.1.9, starting, Nodegroup: 0)id=3

mysql> show processlist;+----+------+-----------------+---------+---------+------+-------+------------------+| Id | User | Host | db | Command | Time | State | Info |+----+------+-----------------+---------+---------+------+-------+------------------+| 3 | root | localhost:60871 | mysql | Query | 0 | NULL | show processlist || 5 | lolo | ict:60910

| ejemplo | Sleep | 15 | | NULL |+----+------+-----------------+---------+---------+------+-------+------------------+2 rows in set (0.00 sec)

mysql> quitBye

/mysql_x>

/mysql_x>pkill pen

Page 30: 4 High Availability y High Performance.docx

@140.148.155.147 (Version: 4.1.9, starting, Nodegroup: 0, Master)[ndb_mgmd(MGM)] 1 node(s)id=1 @140.148.3.104 (Version: 4.1.9)[mysqld(API)] 3 node(s)id=4 (not connected, accepting connect from any host)id=5 (not connected, accepting connect from any host)id=6 (not connected, accepting connect from any host)ndb_mgm>

mysql> show processlist;+----+------+-----------------+-------+---------+------+-------+------------------+| Id | User | Host | db | Command | Time | State | Info |+----+------+-----------------+-------+---------+------+-------+------------------+| 3 | root | localhost:60871 | mysql | Query | 0 |NULL | show processlist |+----+------+-----------------+-------+---------+------+-------+------------------+1 row in set (0.00 sec)

mysql> quitBye

Page 31: 4 High Availability y High Performance.docx

ndb_mgm> showCluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 @140.148.3.214 (Version: 4.1.9, Nodegroup: 0, Master)id=3 @140.148.155.147 (Version: 4.1.9, Nodegroup: 0)[ndb_mgmd(MGM)] 1 node(s)id=1 @140.148.3.104 (Version: 4.1.9)[mysqld(API)] 3 node(s)id=4 (not connected, accepting connect from any host)id=5 @140.148.3.247 (Version: 4.1.9)id=6 (Version: 4.1.9)

/mysql_2>./mysql.server stopKilling mysqld with pid 2860Wait for mysqld to exit.. done/mysql_2>

Page 32: 4 High Availability y High Performance.docx

ndb_mgm> showCluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 @140.148.3.214 (Version: 4.1.9, Nodegroup: 0, Master)id=3 @140.148.155.147 (Version: 4.1.9, Nodegroup: 0)[ndb_mgmd(MGM)] 1 node(s)id=1 @140.148.3.104 (Version:

Page 33: 4 High Availability y High Performance.docx

4.1.9)[mysqld(API)] 3 node(s)id=4 @140.148.3.214 (Version: 4.1.9)id=5 (Version: 4.1.9)id=6 (not connected, accepting connect from any host)

ndb_mgm> showCluster Configuration---------------------[ndbd(NDB)] 2 node(s)id=2 @140.148.3.21

Page 34: 4 High Availability y High Performance.docx

4 (Version: 4.1.9, Nodegroup: 0, Master)id=3 @140.148.155.147 (Version: 4.1.9, Nodegroup: 0)[ndb_mgmd(MGM)] 1 node(s)id=1 @140.148.3.104 (Version: 4.1.9)[mysqld(API)] 3 node(s)id=4 @140.148.155.147 (Version: 4.1.9)id=5 (Version: 4.1.9)id=6 (not connected, accepting connect from any host)

ndb_mgm> showCluster Configuration---------------------

Page 35: 4 High Availability y High Performance.docx

[ndbd(NDB)] 2 node(s)id=2 @140.148.3.214 (Version: 4.1.9, Nodegroup: 0, Master)id=3 @140.148.155.147 (Version: 4.1.9, Nodegroup: 0)[ndb_mgmd(MGM)] 1 node(s)id=1 @140.148.3.104 (Version: 4.1.9)[mysqld(API)] 3 node(s)id=4 @140.148.155.147 (Version: 4.1.9)id=5 (not connected, accepting connect from any host)id=6 (not connected, accepting connect from any host)

ndb_mgm> showCluster Configuration---------------------

Page 36: 4 High Availability y High Performance.docx

[ndbd(NDB)] 2 node(s)id=2 @140.148.3.214 (Version: 4.1.9, Nodegroup: 0, Master)id=3 @140.148.155.147 (Version: 4.1.9, Nodegroup: 0)[ndb_mgmd(MGM)] 1 node(s)id=1 @140.148.3.104 (Version: 4.1.9)[mysqld(API)] 3 node(s)id=4 (not connected, accepting connect from any host)id=5 (not connected, accepting connect from any host)id=6 (not connected, accepting connect from any host)

ndb_mgm> shutdown2 NDB Cluster storage node(s) have shutdown.NDB Cluster management server shutdown.

Page 37: 4 High Availability y High Performance.docx

4.3.3 Web Balancing

   

Bajar el servidor httpd, contenedor tomcat y connector jk1.2 de Apache

Instalar el apache./configure --prefix=/centia01/final/bin/apache --enable-modules="access actions alias auth cgi dir header imap info mime rewrite"makemake install

Descomprimimos el tar/zip de tomcat Compilar/descarga el módulo mod_jk.so e instalarlo en el

directorio "modules" del Apache

Cargar el módulo en el archivo httpd.conf de apache (generalmente ubicado en el directorio conf o bien en /etc/apache)

Page 38: 4 High Availability y High Performance.docx

LoadModule jk_module modules/mod_jk.so

y agregar al mismo httpd.conf el archivo de configuración generado al arrancar el tomcat (de ahí que se debe iniciar primero el tomcat y luego el apache)Include /centia01/final/bin/java/jakarta-tomcat/conf/auto/mod_jk.conf

En el directorio conf del tomcat crear un directorio "jk" y dentro un archivo workers.properties

workers.tomcat_home=/centia01/final/bin/java/jakarta-tomcatworkers.java_home=/centia01/common/java/jsdkps=/worker.list=lbajp13workerworker.lbajp13worker.type=lbworker.lbajp13worker.balanced_workers= worker1, worker2, worker3

worker.worker1.host=localhostworker.worker1.port=8009worker.worker1.type=ajp13worker.worker1.lbfactor=10worker.worker1.cachesize=20

worker.worker2.host=localhostworker.worker2.port=8010worker.worker2.type=ajp13worker.worker2.lbfactor=10worker.worker2.cachesize=20

worker.worker3.host=localhostworker.worker3.port=8011worker.worker3.type=ajp13worker.worker3.lbfactor=10worker.worker3.cachesize=20

Incluir en el server.xml<Server port="8005" shutdown="SHUTDOWN">

<Listener className="org.apache.jk.config.ApacheConfig"modJk="/centia01/final/bin/apache/modules/mod_jk-1.2.8-apache-2.0.52.so" jkDebug="debug"workersConfig="/centia01/final/bin/java/jakarta-tomcat/conf/jk/workers.properties"jkLog="/centia01/final/bin/java/jakarta-tomcat/conf/jk/mod_jk.log" />

<!-- Define an AJP 1.3 Connector on port 8009 --><Connector port="8009" enableLookups="false" redirectPort="8443" debug="10" protocol="AJP/1.3" /><Connector port="8010" enableLookups="false" redirectPort="8444" debug="10" protocol="AJP/1.3" /><Connector port="8011" enableLookups="false" redirectPort="8445" debug="10" protocol="AJP/1.3" />

Page 39: 4 High Availability y High Performance.docx

...

<!-- You should set jvmRoute to support load-balancing via JK/JK2 ie :<Engine name="Standalone" defaultHost="localhost" debug="0" jvmRoute="jvm1">-->

<Engine name="Standalone" defaultHost="localhost" debug="0" jmvRoute="worker1"/><Engine name="Standalone" defaultHost="localhost" debug="0" jmvRoute="worker2"/><Engine name="Standalone" defaultHost="localhost" debug="0" jmvRoute="worker3"/>

<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"xmlValidation="false" xmlNamespaceAware="false">

<Listener className="org.apache.jk.config.ApacheConfig" workersConfig="/home/digital/apache/jakarta-tomcat/conf/jk/workers.properties" modJk="/home/digital/apache/httpd/modules/mod_jk.so" jkDebug="debug"jkWorker="lbajp13worker" append="true" />

Ahora si, levantamos primero el tomcat y posteriormente el apache.

 Bitácora de funcionamiento normal (balanceo de cargas)

Thu Feb 10 11:52:05 2005] [jk_connect.c (136)]: Into jk_open_socket [Thu Feb 10 11:52:05 2005] [jk_connect.c (143)]: jk_open_socket, try to connect socket = 12 to 127.0.0.1:8009 [Thu Feb 10 11:52:05 2005] [jk_connect.c (159)]: jk_open_socket, after connect ret = 0 [Thu Feb 10 11:52:05 2005] [jk_connect.c (168)]: jk_open_socket, set TCP_NODELAY to on [Thu Feb 10 11:52:05 2005] [jk_connect.c (185)]: jk_open_socket, return, sd = 12 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (701)]: In jk_endpoint_t::ajp_connect_to_endpoint, connected sd = 12 to 127.0.0.1:8009 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (737)]: sending to ajp13 #391 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (1035)]: ajp_send_request 2: request body to send 0 - request body to resend 0 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (851)]: received from ajp13 #77 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (477)]: ajp_unmarshal_response: status = 302 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (483)]: ajp_unmarshal_response: Number of headers is = 1 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (537)]: ajp_unmarshal_response: Header[0] [Location] = [http://localhost:8888/jsp-examples/] [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (851)]: received from ajp13 #2 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (1716)]: Into jk_endpoint_t::done, recycling connection [Thu Feb 10 11:52:05 2005] [jk_lb_worker.c (374)]: Into jk_endpoint_t::done [Thu Feb 10 11:52:05 2005] [jk_uri_worker_map.c (445)]: Into

Page 40: 4 High Availability y High Performance.docx

jk_uri_worker_map_t::map_uri_to_worker [Thu Feb 10 11:52:05 2005] [jk_uri_worker_map.c (459)]: Attempting to map URI '/jsp-examples/' [Thu Feb 10 11:52:05 2005] [jk_uri_worker_map.c (483)]: jk_uri_worker_map_t::map_uri_to_worker, Found a context match lbajp13worker -> /jsp-examples/ [Thu Feb 10 11:52:05 2005] [mod_jk.c (1689)]: Into handler r->proxyreq=0 r->handler=jakarta-servlet r->notes=135831864 worker=lbajp13worker [Thu Feb 10 11:52:05 2005] [jk_worker.c (90)]: Into wc_get_worker_for_name lbajp13worker [Thu Feb 10 11:52:05 2005] [jk_worker.c (94)]: wc_get_worker_for_name, done found a worker [Thu Feb 10 11:52:05 2005] [mod_jk.c (472)]: agsp=8888 agsn=localhost hostn=localhost shostn=localhost cbsport=0 sport=0 [Thu Feb 10 11:52:05 2005] [jk_lb_worker.c (513)]: Into jk_worker_t::get_endpoint [Thu Feb 10 11:52:05 2005] [jk_lb_worker.c (283)]: Into jk_endpoint_t::service [Thu Feb 10 11:52:05 2005] [jk_lb_worker.c (299)]: Into jk_endpoint_t::service sticky_session=1 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (1741)]: Into jk_worker_t::get_endpoint [Thu Feb 10 11:52:05 2005] [jk_lb_worker.c (313)]: Into jk_endpoint_t::service worker=worker2 jvm_route=worker2 rc=1 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (1367)]: Into jk_endpoint_t::service [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (257)]: Into ajp_marshal_into_msgb [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (425)]: ajp_marshal_into_msgb - Done [Thu Feb 10 11:52:05 2005] [jk_connect.c (136)]: Into jk_open_socket [Thu Feb 10 11:52:05 2005] [jk_connect.c (143)]: jk_open_socket, try to connect socket = 13 to 127.0.0.1:8010 [Thu Feb 10 11:52:05 2005] [jk_connect.c (159)]: jk_open_socket, after connect ret = 0 [Thu Feb 10 11:52:05 2005] [jk_connect.c (168)]: jk_open_socket, set TCP_NODELAY to on [Thu Feb 10 11:52:05 2005] [jk_connect.c (185)]: jk_open_socket, return, sd = 13 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (701)]: In jk_endpoint_t::ajp_connect_to_endpoint, connected sd = 13 to 127.0.0.1:8010 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (737)]: sending to ajp13 #392 [Thu Feb 10 11:52:05 2005] [jk_ajp_common.c (1035)]: ajp_send_request 2: request body to send 0 - request body to resend 0 [Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (851)]: received from ajp13 #143

Page 41: 4 High Availability y High Performance.docx

[Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (477)]: ajp_unmarshal_response: status = 200 [Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (483)]: ajp_unmarshal_response: Number of headers is = 4 [Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (537)]: ajp_unmarshal_response: Header[0] [ETag] = [W/"16576-1106167226000"] [Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (537)]: ajp_unmarshal_response: Header[1] [Last-Modified] = [Wed, 19 Jan 2005 20:40:26 GMT] [Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (537)]: ajp_unmarshal_response: Header[2] [Content-Type] = [text/html] [Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (537)]: ajp_unmarshal_response: Header[3] [Content-Length] = [16576] [Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (851)]: received from ajp13 #8188 [Thu Feb 10 11:52:06 2005] [mod_jk.c (372)]: writing 4096 (4096) out of 8184 [Thu Feb 10 11:52:06 2005] [mod_jk.c (372)]: writing 4088 (4088) out of 4088 [Thu Feb 10 11:52:06 2005] [jk_uri_worker_map.c (445)]: Into jk_uri_worker_map_t::map_uri_to_worker [Thu Feb 10 11:52:06 2005] [jk_uri_worker_map.c (459)]: Attempting to map URI '/jsp-examples/images/execute.gif' [Thu Feb 10 11:52:06 2005] [jk_uri_worker_map.c (483)]: jk_uri_worker_map_t::map_uri_to_worker, Found a context match lbajp13worker -> /jsp-examples/ [Thu Feb 10 11:52:06 2005] [mod_jk.c (1689)]: Into handler r->proxyreq=0 r->handler=jakarta-servlet r->notes=135831864 worker=lbajp13worker [Thu Feb 10 11:52:06 2005] [jk_worker.c (90)]: Into wc_get_worker_for_name lbajp13worker [Thu Feb 10 11:52:06 2005] [jk_worker.c (94)]: wc_get_worker_for_name, done found a worker [Thu Feb 10 11:52:06 2005] [mod_jk.c (472)]: agsp=8888 agsn=localhost hostn=localhost shostn=localhost cbsport=0 sport=0 [Thu Feb 10 11:52:06 2005] [jk_lb_worker.c (513)]: Into jk_worker_t::get_endpoint [Thu Feb 10 11:52:06 2005] [jk_lb_worker.c (283)]: Into jk_endpoint_t::service [Thu Feb 10 11:52:06 2005] [jk_lb_worker.c (299)]: Into jk_endpoint_t::service sticky_session=1 [Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (1741)]: Into jk_worker_t::get_endpoint [Thu Feb 10 11:52:06 2005] [jk_lb_worker.c (313)]: Into jk_endpoint_t::service worker=worker1 jvm_route=worker1 rc=1 [Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (1367)]: Into jk_endpoint_t::service

Page 42: 4 High Availability y High Performance.docx

[Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (257)]: Into ajp_marshal_into_msgb [Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (425)]: ajp_marshal_into_msgb - Done

Bitácora de funcionamiento con un nodo caído y recuperación de conexión[Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (1468)]: sending request to tomcat failed in send loop. err=1 [Thu Feb 10 12:44:12 2005] [jk_connect.c (136)]: Into jk_open_socket [Thu Feb 10 12:44:12 2005] [jk_connect.c (143)]: jk_open_socket, try to connect socket = 12 to 140.148.3.56:8009 [Thu Feb 10 12:44:12 2005] [jk_connect.c (159)]: jk_open_socket, after connect ret = -1 [Thu Feb 10 12:44:12 2005] [jk_connect.c (188)]: jk_open_socket, connect() failed errno = 111 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (720)]: Error connecting to tomcat. Tomcat is probably not started or is listening on the wrong host/port (140.148.3.56:8009). Failed errno = 111 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (1024)]: Error connecting to the Tomcat process. [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (1468)]: sending request to tomcat failed in send loop. err=2 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (1477)]: Error connecting to tomcat. Tomcat is probably not started or is listening on the wrong port. worker=worker1 failed errno = 111 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (1724)]: Into jk_endpoint_t::done, closing connection 0 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (567)]: In jk_endpoint_t::ajp_close_endpoint [Thu Feb 10 12:44:12 2005] [jk_lb_worker.c (353)]: lb: recoverable error... will try to recover on other host [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (1741)]: Into jk_worker_t::get_endpoint [Thu Feb 10 12:44:12 2005] [jk_lb_worker.c (313)]: Into jk_endpoint_t::service worker=worker2 jvm_route=worker2 rc=1 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (1367)]: Into jk_endpoint_t::service [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (257)]: Into ajp_marshal_into_msgb [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (425)]: ajp_marshal_into_msgb - Done [Thu Feb 10 12:44:12 2005] [jk_connect.c (136)]: Into jk_open_socket [Thu Feb 10 12:44:12 2005] [jk_connect.c (143)]: jk_open_socket, try to connect socket = 12 to 127.0.0.1:8010 [Thu Feb 10 12:44:12 2005] [jk_connect.c

Page 43: 4 High Availability y High Performance.docx

(159)]: jk_open_socket, after connect ret = 0 [Thu Feb 10 12:44:12 2005] [jk_connect.c (168)]: jk_open_socket, set TCP_NODELAY to on [Thu Feb 10 12:44:12 2005] [jk_connect.c (185)]: jk_open_socket, return, sd = 12 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (701)]: In jk_endpoint_t::ajp_connect_to_endpoint, connected sd = 12 to 127.0.0.1:8010 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (737)]: sending to ajp13 #391 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (1035)]: ajp_send_request 2: request body to send 0 - request body to resend 0 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (851)]: received from ajp13 #77 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (477)]: ajp_unmarshal_response: status = 302 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (483)]: ajp_unmarshal_response: Number of headers is = 1 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (537)]: ajp_unmarshal_response: Header[0] [Location] = [http://localhost:8888/jsp-examples/] [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (851)]: received from ajp13 #2 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (1716)]: Into jk_endpoint_t::done, recycling connection [Thu Feb 10 12:44:12 2005] [jk_lb_worker.c (374)]: Into jk_endpoint_t::done [Thu Feb 10 12:44:12 2005] [jk_uri_worker_map.c (445)]: Into jk_uri_worker_map_t::map_uri_to_worker [Thu Feb 10 12:44:12 2005] [jk_uri_worker_map.c (459)]: Attempting to map URI '/jsp-examples/' [Thu Feb 10 12:44:12 2005] [jk_uri_worker_map.c (483)]: jk_uri_worker_map_t::map_uri_to_worker, Found a context match lbajp13worker -> /jsp-examples/ [Thu Feb 10 12:44:12 2005] [mod_jk.c (1689)]: Into handler r->proxyreq=0 r->handler=jakarta-servlet r->notes=135833800 worker=lbajp13worker [Thu Feb 10 12:44:12 2005] [jk_worker.c (90)]: Into wc_get_worker_for_name lbajp13worker [Thu Feb 10 12:44:12 2005] [jk_worker.c (94)]: wc_get_worker_for_name, done found a worker [Thu Feb 10 12:44:12 2005] [mod_jk.c (472)]: agsp=8888 agsn=localhost hostn=localhost shostn=localhost cbsport=0 sport=0 [Thu Feb 10 12:44:12 2005] [jk_lb_worker.c (513)]: Into jk_worker_t::get_endpoint [Thu Feb 10 12:44:12 2005] [jk_lb_worker.c (283)]: Into jk_endpoint_t::service [Thu Feb 10 12:44:12 2005] [jk_lb_worker.c (299)]: Into jk_endpoint_t::service sticky_session=1

Page 44: 4 High Availability y High Performance.docx

[Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (1741)]: Into jk_worker_t::get_endpoint [Thu Feb 10 12:44:12 2005] [jk_lb_worker.c (313)]: Into jk_endpoint_t::service worker=worker3 jvm_route=worker3 rc=1 [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (1367)]: Into jk_endpoint_t::service [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (257)]: Into ajp_marshal_into_msgb [Thu Feb 10 12:44:12 2005] [jk_ajp_common.c (425)]: ajp_marshal_into_msgb - Done