Sei sulla pagina 1di 52

4 High Availability y High Performance

4.1 Antecedentes
Estudios recientes (IDC) han encontrado que los "downtime" o "cadas" son las causas principales al hablar de los TCO en las empresas. Cadas de algunas aplicaciones puede significar considerables prdidas, por ejemplo:

Proveedores de telecomunicaciones y operadores de redes requieren brindar sus servicios sin parar, independientemente de la informacin que manejan, por el simple hecho de mantener un nivel competitivo. Intituciones financieras aumentan cada da el nmero de usuarios y transacciones, es importante atenderlos y en el menor tiempo posible. Web sites y compaas de portales en Internet crean comunidades que tambin 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 compaas un downtime puede ser crucial y algo que simplemente no pueden permitir, alta disponibilidad es la solucin central y crtica para su xito. Sin HA y HP se comprometen la satisfaccin del cliente y las ganancias.

4.2 High Performance


Hablando de Performance existen algunas soluciones conocidas:

Buen manejo de ndices y memoria Denormalizacin

4.2.1 Manejo de ndices y memoria


4.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 | | | 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

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 seccin global y otra dedicada cada conexin de los usuarios. session buffers

global buffers

sort_buffer myisam_soft_buffer read_buffer join_buffer read_rnd_buffer

key_buffer innodb_buffer_pool innodb_log_buffer innodb_additional_mem_pool net_buffer

# The following options will be passed to all MySQL clients [client] #password = your_password port = 3306 socket = /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 set-variable set-variable set-variable set-variable # Try number set-variable #log-bin

= read_buffer_size=2M = read_rnd_buffer_size=8M = myisam_sort_buffer_size=64M = thread_cache=8 = query_cache_size=32M of CPU's*2 for thread_concurrency = thread_concurrency=8

server-id = 1 # Point the following paths to different dedicated disks tmpdir = /var/tmp/ #log-update = /centia01/final/database/mysql/var/logcatarina # 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 [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

Configuracin my.cnf

4.2.2 Denormalizacin
Se puede definir como el proceso de poner la misma informacin en varios lugares.

Una normalizacin reduce problemas de integridad y optimiza las actualizaciones, quizs con el costo del tiempo de recuperacin. Cuando se pretende evitar esta demora resultado de la combinacin de muchas tablas entonces se puede utilizar la denormalizacin. Antes de denormalizar es importante considerar:

El sistema puede tener un desempeo aceptable sin la denormalizacin ? An con la denormalizacin el desempeo ser siendo malo ? El sistema ser menos confiable debido a la denormalizacin ?

Candidatos a denormalizacin:

Numerosas consultas crticas o reportes incluyen datos que incluyen ms de una tabla. Grupos repetidos de elementos necesitan ser procesados en un grupo en lugar de individualmente. Muchos clculos necesitan realizarse a una o ms 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 diseadas que requieren tiempo al usarlas en relaciones. Algunas columnas son interrogadas un gran porcentaje del tiempo.

Importante: nunca se realiza un denormalizacin en un modelo lgico. Prejoined Tables Cuando 2 tablas se mezclan (join) frecuentemente, considerar tener una tabla premezclada (prejoined) la cual debera:

Contener columnas que no sean redundantes Contener slo aquellas columnas absolutamente necesarias para las necesidades de la aplicacin Ser creada periodicamente utilizando las tablas normalizadas (que forman el join)

Ventaja: consultas rpidas y eficientes Desventaja: la tabla puede quedar inconsistente rapidamente, se recomienda para datos ms estticos que dinmicos. Report Tables Mantener reportes en lnea 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 atmicos (1NF)

Mirror Tables En ocasiones algn departamento de la organizacin necesita consultar mientras otro hace modificaciones, se pueden usar dos tablas para balancear la carga y obtener buen tiempo de acceso y modificacin. Se debe tener un esquema de duplicacin que permita actualizar el espejo de manera eficiente, esto puede hacerse:

A travs de un proceso batch, que es bastante rpido Directamente con herramientas de replicacin y propagacin del dbms

Split Tables Si la cantidad de informacin 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.

Tambin se puede considerar el separar columnas:


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

se dividira 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))

Combined Tables Dada una relacion 1-1, combinar las 2 tablas en una sola Se complica si hay otras relaciones involucradas, otra relacin 1-m implicara demasiada redundancia y un aumento considerable del tiempo para actualizaciones. Redundant Data Cuando 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 sern redundantes y debern cumplir con:

Slo ser pocas las columnas involucradas No deben necesitan actualizaciones frecuentes Deben usarse por un gran nmero de usuarios y por pocos pero importantes

Repeating Groups Muchas veces la repeticin 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 esttico y bajo un patrn Se puede calcular el nmero de ocurrencias Los datos se accesan colectivamente (grupos)

Derivable Data Similar al de reportes para minimizar muchas frmulas, se usa cuando:

La fuente de los datos involucrados son relativamente estticos. El costo de aplicar el clculo es demasiado alto. Es factible realizar el reclculo 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 numrico indicando el nivel dentro de la jerarqua del childdeptnum; si el hijo reside 2 niveles abajo en la jerarqua del padre entonces el level ser 2. detail, contiene una "Y" si el childdeptnum esta hasta abajo de la jerarqua, "N" de otra manera.

Implementacin fsica especial Partir una tabla de manera que su tamao se aproxime al de la pgina que maneja el dbms.

4.3 High Availability


Respecto a disponibilidad existen tambin 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 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: $ 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

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', 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 Clustering
4.3.2.1 Definicin Qu es Clustering ?

En general, cuando las personas hablan de clusters, se refieren a tecnologas que permiten a mltiples computadoras trabajar conjuntamente para resolver problemas comunes. Dichos problemas puede ser casi cualquier cosa, desde clculos complejos que implican uso intensivo del CPU, hasta manejar una enorme cantidad de procesos que no tienen nada en comn. Actualmente por ejemplo los clusters Beowulf (mltiples mquinas conectadas a travs 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 propsitos.


Formando un mquina 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. 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 solucin para HA y HP

Un NDB Cluster database consiste de una coleccin de nodos de 3 tipos: 1. Uno o ms management servers (MGM nodes) 2. Uno o ms database/storage nodes (DB nodes) 3. Uno o ms applications (API nodes) Un nodo es un programa ejecutndose en alguna computadora Los nodos pueden correr en diferentes computadoras (o en la misma) y se comunican a travs de mdulos de software llamados "transporters". Funcionamiento

Los datos son sncronamente replicados entre los storage nodes, esto reduce al mnimo problemas de cadas por fail-over. Los nodos estn diseados usando una arquitectura "share-nothing". No hay puntos de falla (points of failure). Cualquien nodo puede ser eliminado sin existir prdida 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 especficos de como se encuentra almacenada la informacin 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.

Node y System Recovery


Cuando un nodo presenta una falla, al recuperarse restaura toda la informacin auxilindose de otros nodos. Al igual que en la versin sin cluster, ste maneja bitcoras y errores que permiten mantener ntegra y consistente la inf El cluster utiliza "pessimistic concurrency control based on locking".

Ejemplos de configuraciones:

Failed Nodes {D2}

Computers Recovery Procedure System Restart

Failed Nodes

Computers Recovery Procedure

{D2}, {D3} {D2, D3}

Node Recovery System Restart Node Recovery (after computer is {C1}, {C2} replaced/restarted) {C3}, {C4}, {C3, Restart Applications and Management C4} Server

Failed Nodes Computers Recovery Procedure {D2}, {D3}, {D2, D4}, {D2, D5}, Node Recovery {D3, D4}, {D3,D5} {D2, D3}, {D4, D5}+ all three node System Restart failures Node Recovery (after computer is {C1}, {C2} replaced/restarted) Restart Applications and Management {C3}, {C4}, {C3, C4} Server

Failed Nodes {D2}, {D3}, ..., {D9} {D2,D3}, {D4,D5}, {D6,D7}, {D8,D9} {D2,D4}, {D2,D5}, {D2,D6}, {D2,D7}, {D2,D8}, {D2,D9} {D3,D4}, {D3,D5}, {D3,D6}, {D3,D7}, {D3,D8}, {D3,D9} {D4,D6}, {D4,D7}, {D4,D8}, {D4,D9} {D5,D6}, {D5,D7}, {D4,D8}, {D4,D9} {D6,D8}, {D6,D9} {D7,D8}, {D7,D9} {C1}, {C2} {C1}, {C2} {C3}, {C4}, {C3, C4}

Computers Recovery Procedure Node Recovery System Restart Node Recovery Node Recovery Node Recovery Node Recovery Node Recovery Node Recovery Node Recovery if Arbitrator survived System Restart if Arbitrator did not survive Restart Applications and Management Server

Implementacin Partimos de una configuracin bsica cona las siguientes mquinas

Funcin Manager Transport Monitor (Manager client) Storage y API Storage y API API Balancer

Host agua agua agua scanner ict santa ict

Port 9000 9099 9001 9002 9003 9999

Manager Storage1 agua scanner Bajar el binario de la plataforma, en este caso lo ms recomendable es la versin 4.1.9 Max de Solaris 8 Sparc 32 bits. mysql-max4.1.9-sunsolaris2.8sparc.tar.gz /carlos>gunzip mysql-max4.1.9-sunsolaris2.8sparc.tar.gz /carlos>tar -xvf mysql-max4.1.9-sunsolaris2.8sparc.tar .... /carlos>mv mysql-max4.1.9-sun-

Storage2 ict

API santa

Balancer ict

solaris2.8-sparc mysql_manager /carlos>cd mysql_manager editar el archivo nuevo config.ini /mysql_manage r>vi config.ini [NDBD DEFAULT] NoOfReplicas =2 [MYSQLD DEFAULT] [NDB_MGMD DEFAULT] [TCP DEFAULT] PortNumber=9 099 # Managment Server [NDB_MGMD ] HostName=ag ua.udlap.mx # the IP of THIS SERVER PortNumber=9 000 # Storage Engines [NDBD] HostName=sca nner.udlap.mx # the IP of the FIRST SERVER Bajar el binario de DataDir= la plataforma, /archivos/vol88 en este caso lo ms 0recomendable es la

Bajar el binario de la plataforma, en este caso lo ms recomendable es la

Bajar el binario de la plataforma, en este caso lo ms recomendable es la

12/carlos/mysq l_1/cluster [NDBD] HostName=ict. udlap.mx # the IP of the SECOND SERVER DataDir=/archi vos/vol88012/carlos/mysq l_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

versin 4.1.9 Max de Solaris 8 Sparc 32 bits.

versin 4.1.9 Max de Solaris 8 Sparc 32 bits.

versin 4.1.9 Max de Solaris 8 Sparc 32 bits.

mysql-max-4.1.9- mysql-max-4.1.9- mysql-max-4.1.9sun-solaris2.8sun-solaris2.8sun-solaris2.8sparc.tar.gz sparc.tar.gz sparc.tar.gz /carlos>gunzip mysql-max-4.1.9sun-solaris2.8sparc.tar.gz /carlos>tar -xvf mysql-max-4.1.9sun-solaris2.8sparc.tar .... /carlos>mv mysqlmax-4.1.9-sunsolaris2.8-sparc mysql_1 /carlos>gunzip mysql-max-4.1.9sun-solaris2.8sparc.tar.gz /carlos>tar -xvf mysql-max-4.1.9sun-solaris2.8sparc.tar .... /carlos>mv mysqlmax-4.1.9-sunsolaris2.8-sparc mysql_2 /carlos>gunzip mysql-max-4.1.9sun-solaris2.8sparc.tar.gz /carlos>tar -xvf mysql-max-4.1.9sun-solaris2.8sparc.tar .... /carlos>mv mysqlmax-4.1.9-sunsolaris2.8-sparc mysql_api

/carlos>cd mysql_1

/carlos>cd mysql_2

/carlos>cd mysql_api

/mysql_1>cp /mysql_2>cp /mysql_api>cp support-files/my- support-files/my- support-files/mymedium.cnf medium.cnf medium.cnf data/my.cnf data/my.cnf data/my.cnf /mysql_manage r>bin/ndb_mg md -f config.ini editamos el archivo editamos el archivo editamos el archivo de configuracion de configuracion de configuracion listo el manager /mysql_1>vi /mysql_2>vi /mysql_api>vi ya esta data/my.cnf data/my.cnf data/my.cnf corriendo /mysql_manage r>bin/ndb_mg m --connectstring=agua.udl ap.mx:9000 [client] #password = your_password port = 9001 socket = [client] #password = your_password port = 9002 socket = [client] #password = your_password port = 9003 socket =

ndb_mgm> show Connected to Management Server at: localhost:9000 Cluster Configuration -------------------[ndbd(NDB)] 2 node(s) id=2 (not connected, accepting connect from scanner.ud id=3 (not connected, accepting connect from ict.udlap.

/tmp/mysql_1.sock /tmp/mysql_2.sock /tmp/mysql_3.sock # Here follows # Here follows # Here follows entries for some entries for some entries for some specific programs specific programs specific programs # The MySQL server [mysqld] port = 9001 socket = /tmp/mysql_1.sock ndbcluster ndbconnectstring=agu a.udlap.mx:9000 .... # The MySQL server [mysqld] port = 9002 socket = /tmp/mysql_2.sock ndbcluster ndbconnectstring=agu a.udlap.mx:9000 .... [mysql_cluster] ndbconnectstring=agu a.udlap.mx:9000 [mysqldump] quick max_allowed_pac ket = 16M # The MySQL server [mysqld] port = 9003 socket = /tmp/mysql_3.sock ndbcluster ndbconnectstring=agu a.udlap.mx:9000 .... [mysql_cluster] ndbconnectstring=agu a.udlap.mx:9000 [mysqldump] quick max_allowed_pac ket = 16M

[mysql_cluster] ndbconnectstring=agu a.udlap.mx:9000 [ndb_mgmd(M [mysqldump] GM)] 1 node(s) quick id=1 max_allowed_pac @140.148.3.10 ket = 16M 4 (Version: 4.1.9) /mysql_1>scripts/ mysql_install_db [mysqld(API)] 3 node(s) /mysql_1>cp id=4 (not supportconnected, files/mysql.server . accepting connect from /mysql_1>vi any host) mysql.server id=5 (not connected, accepting basedir=/archivos/ connect from vol880any host) 12/carlos/mysql_1 id=6 (not connected, # The following accepting variables are only connect from set for letting

/mysql_2>scripts/ /mysql_api>scripts mysql_install_db /mysql_install_db /mysql_2>cp /mysql_api>cp supportsupportfiles/mysql.server . files/mysql.server . /mysql_2>vi mysql.server /mysql_api>vi mysql.server

basedir=/archivos/ basedir=/archivos/ vol880vol88012/carlos/mysql_2 12/carlos/mysql_a pi # The following variables are only # The following set for letting variables are only

any host)

mysql.server find mysql.server find set for letting things. things. mysql.server find ndb_mgm> things. show # Set some # Set some Cluster defaults defaults # Set some Configuration datadir=/archivos/ datadir=/archivos/ defaults ------------------- vol880vol880datadir=/archivos/ -12/carlos/mysql_1 12/carlos/mysql_2 vol880[ndbd(NDB)] 2 /data /data 12/carlos/mysql_a node(s) pi/data id=2 (not /mysql_1>chmod /mysql_2>chmod connected, 755 mysql.server 755 mysql.server /mysql_api>chmod accepting 755 mysql.server connect from /mysql_1>mkdir /mysql_2>mkdir scanner.udlap. cluster cluster mx) id=3 (not /mysql_1>bin/ndbd /mysql_api>./mysq connected, --connectl.server start accepting string=agua.udlap. connect from mx:9000 --initial ict.udlap.mx) /mysql_1>./mysql. [ndb_mgmd(M server start GM)] 1 node(s) id=1 @140.148.3.10 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)

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

/mysql_1>bin/mys ql -u root -protocol=tcp -P 9001 -p mysql Enter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.1.9-max-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases; +------------+ /mysql_2>bin/mys ql -u root -protocol=tcp -P 9002 -p mysql

| Database | Enter password: +------------+ Reading table | aplicacion | information for | mysql | completion of table | test | and column names ndb_mgm> +------------+ You can turn off show 3 rows in set (0.00 this feature to get a Cluster quicker startup Configuration sec) with -A ------------------mysql> create -[ndbd(NDB)] 2 database ejemplo; Welcome to the Query OK, 1 row MySQL monitor. node(s) affected (0.30 sec) Commands end id=2 with ; or \g. @140.148.3.21 Your MySQL 4 (Version: mysql> use connection id is 1 4.1.9, starting, ejemplo; Nodegroup: 0, Database changed to server version: Master) mysql> create table 4.1.9-max-log id=3 (not usuarios (id int) connected, ENGINE=NDBCL Type 'help;' or '\h' accepting USTER; for help. Type '\c' connect from Query OK, 0 rows to clear the buffer. ict.udlap.mx) affected (1.27 sec) mysql> show [ndb_mgmd(M insert into usuarios databases; GM)] 1 node(s) values (555); +------------+ id=1 Query OK, 1 row | Database | @140.148.3.10 affected (0.01 sec) +------------+ 4 (Version: | aplicacion | 4.1.9) | mysql | mysql> select * | test | from usuarios; +------------+ [mysqld(API)] +------+ 3 rows in set (0.01 /mysql_api>bin/my 3 node(s) | id | sec) id=4 (not +------+ sql -u root -connected, | 555 | protocol=tcp -P accepting +------+ mysql> create 9003 -p mysql connect from 1 row in set (0.00 database ejemplo; Enter password: any host) sec) Query OK, 1 row Reading table id=5 (not affected (0.09 sec) information for connected, mysql> completion of table accepting mysql> use and column names connect from ejemplo; You can turn off any host) Reading table this feature to get a id=6 (not information for quicker startup connected, completion of table with -A accepting and column names

connect from any host)

You can turn off this feature to get a quicker startup with -A

ndb_mgm> show Cluster Configuration -------------------[ndbd(NDB)] 2 node(s) id=2 @140.148.3.21 4 (Version: 4.1.9, starting, Nodegroup: 0) id=3 @140.148.155. 147 (Version: 4.1.9, starting, Nodegroup: 0, Master) [ndb_mgmd(M GM)] 1 node(s) id=1 @140.148.3.10 4 (Version: 4.1.9) [mysqld(API)] 3 node(s) id=4 (not connected, accepting connect from any host) id=5 (not connected, accepting

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

connect from any host) id=6 (not connected, accepting connect from any host)

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

mysql>set autocommit=0;

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

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)

Descargamos algun software de balanceo como: http://siag.nu/p en/ http://www.inla b.de/balance.ht ml En el caso de solaris recomiendo el primero. /carlos>tar -xvf pen-0.15.0.tar /carlos> cd pen-0.15.0

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

/pen-0.15.0> ./configure /pen-0.15.0> make mysql> select * from usuarios; +------+ | id | +------+ | 555 | +------+ | 455 | +------+ 2 row in set (0.03 sec) mysql> Si 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 /pen-0.15.0> ./pen -r 9999

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

mysql> quit Bye /mysql_2>bin/ndbd --connectstring=agua.udlap. mx:9000

ndb_mgm> show Cluster Configuration ------------------- mysql> delete from -user where [ndbd(NDB)] 2 host='scanner'; node(s) Query OK, 2 rows id=2 affected (0.01 sec) @140.148.3.21 4 (Version: mysql> delete from 4.1.9, user where user=''; Nodegroup: 0, Query OK, 1 row Master) affected (0.00 sec) id=3 /mysql_2>bin/mys @140.148.155. mysql> insert into ql -u root --

/mysql_x>bin/ mysql -u lolo -protocol=tcp -h ict -P 9999 -p ejemplo Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 to server version: 4.1.9max-log

147 (Version: user protocol=tcp -P Type 'help;' or 4.1.9, (host,user,passwor 9002 -p mysql '\h' for help. Nodegroup: 0) d) values Enter password: Type '\c' to ('%','lolo',password Reading table clear the buffer. information for [ndb_mgmd(M ('lolopass')); mysql> delete from GM)] 1 node(s) Query OK, 1 row completion of table user where mysql> show affected (0.01 sec) and column names host='santa'; id=1 tables; You can turn off Query OK, 2 rows +----------------@140.148.3.10 4 (Version: mysql> insert into this feature to get a affected (0.00 sec) --+ quicker startup 4.1.9) db values | ('%','ejemplo','lolo', with -A mysql> delete from Tables_in_eje [mysqld(API)] 'Y','Y','Y','Y','Y','Y' user where user=''; mplo | ,'Y','Y','Y','Y','Y','Y Welcome to the 3 node(s) Query OK, 1 row +----------------'); MySQL monitor. affected (0.00 sec) --+ id=4 | usuarios | @140.148.3.21 Query OK, 1 row Commands end affected (0.00 sec) with ; or \g. 4 (Version: mysql> insert into +----------------Your MySQL --+ 4.1.9) user connection id is 1 (host,user,passwor 1 row in set id=5 mysql> flush to server version: d) values (0.02 sec) @140.148.155. privileges; 147 (Version: Query OK, 0 rows 4.1.9-max-log ('%','lolo',password 4.1.9) affected (0.16 sec) ('lolopass')); id=6 Type 'help;' or '\h' Query OK, 1 row @140.148.3.24 for help. Type '\c' affected (0.00 sec) 7 (Version: to clear the buffer. mysql> insert 4.1.9) mysql> insert into into usuarios mysql> delete from db values values (123); ndb_mgm> user where ('%','ejemplo','lolo', Query OK, 1 host='ict'; 'Y','Y','Y','Y','Y','Y' row affected Query OK, 2 rows ,'Y','Y','Y','Y','Y','Y (0.01 sec) affected (0.11 sec) '); Query OK, 1 row mysql> select * mysql> delete from affected (0.02 sec) from usuarios; user where user=''; +------+ Query OK, 1 row mysql> flush | id | affected (0.00 sec) privileges; +------+ Query OK, 0 rows | 555 | mysql> insert into affected (0.21 sec) +------+ | 455 | user +------+ (host,user,passwor | 123 | d) values +------+ ('%','lolo',password 2 row in set ('lolopass')); (0.00 sec) 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.20 sec)

ndb_mgm> 3 stop Node 3 has shutdown. ndb_mgm> show Cluster Configuration -------------------[ndbd(NDB)] 2

mysql> show processlist; +----+------+----------------------+---------+--------+------+------+------------------+ | Id | User | Host | db | Command | mysql> quit Time Bye | State | Info | +----+------+----------------------ict:carlos:Drag +---------+--------- onCorp> +-----bin/mysql -u +-------+------------- lolo ------+ protocol=tcp -h | 1 | lolo | ict -P 9999 -p ict.pue.udlap.mx:6 ejemplo 0982 Enter

node(s) id=2 @140.148.3.21 4 (Version: 4.1.9, Nodegroup: 0, Master) id=3 (not connected, accepting connect from ict.udlap.mx) [ndb_mgmd(M GM)] 1 node(s) id=1 @140.148.3.10 4 (Version: 4.1.9) [mysqld(API)] 3 node(s) id=4 @140.148.3.21 4 (Version: 4.1.9) id=5 @140.148.155. 147 (Version: 4.1.9) id=6 @140.148.3.24 7 (Version: 4.1.9)

| ejemplo | Sleep password: | 19 | | NULL | Reading table | 2 | root | information for localhost:46899 completion of | mysql | Query | 0 table and | NULL | show column names processlist | You can turn +----+------+-------- off this feature ---------------to get a quicker +---------+--------- startup with -A +-----+-------+------------- Welcome to the -----+ MySQL 2 rows in set (0.00 monitor. sec) Commands end with ; or \g. mysql> Your MySQL connection id is 4 to server version: 4.1.9max-log Type 'help;' or mysql> quit '\h' for help. Bye /mysql_api>./mysq Type '\c' to clear the buffer. l.server stop Killing mysqld mysql> show with pid 18960 Wait for mysqld to tables; +----------------exit.. done --+ /mysql_ap> | Tables_in_eje mplo | +------------------+ | usuarios | +------------------+ 1 row in set (0.02 sec) mysql> select * from usuarios2; +------+ | id |

mysql> show processlist; +----+------+----------------------+---------+--------+-----+-------+-----------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+----------------------+---------+--------+-----+-------+-----------------+ | 1 | root | ndb_mgm> localhost:60102 show | mysql | Query | 0 Cluster Configuration | NULL | show ------------------- processlist | | 8 | lolo | -[ndbd(NDB)] 2 ict.pue.udlap.mx:6 0928 node(s) | ejemplo | Sleep | id=2 @140.148.3.21 18 | | NULL | 4 (Version: 4.1.9, starting, +----+------+-------Nodegroup: 0) ---------------+---------+--------id=3 @140.148.155. +-----147 (Version: +-------+------------4.1.9, starting, -----+ Nodegroup: 0, 2 rows in set (0.00 sec) Master) [ndb_mgmd(M GM)] 1 node(s) id=1 @140.148.3.10 mysql> quit 4 (Version: Bye 4.1.9)

+------+ | 555 | +------+ | 455 | +------+ | 123 | +------+ 2 row in set (0.00 sec)

mysql> select * from usuarios; ERROR 2013 (HY000): Lost connection to MySQL server during query mysql> select *

[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>

/mysq_1>./mysql.s erver stop Killing mysqld with pid 25010 Wait for mysqld to exit.. done /mysq_1>

from usuarios; ERROR 2006 (HY000): MySQL server has gone away No connection. Trying to reconnect... Connection id: 1 Current database: ejemplo +------+ | id | +------+ | 555 | +------+ | 455 | +------+ | 123 | +------+ 2 row in set (0.06 sec) mysql>

mysql> show processlist; +----+------+---------------+---------+--------+-----+-------+-----------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+---------------+---------+--------+------

ndb_mgm> show Cluster Configuration -------------------[ndbd(NDB)] 2 node(s) id=2 @140.148.3.21 4 (Version: 4.1.9, Nodegroup: 0, Master) id=3 @140.148.155. 147 (Version: 4.1.9, Nodegroup: 0) [ndb_mgmd(M GM)] 1 node(s) id=1 @140.148.3.10 4 (Version: 4.1.9) [mysqld(API)] 3 node(s) id=4 (not connected, accepting connect from any host) id=5 @140.148.3.24

+-------+-----------------+ | 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> quit Bye

/mysql_x>

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

7 (Version: 4.1.9) id=6 (Version: 4.1.9)

--------+-------+---------+----+-------+-----------------+ | 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_x>pkill pen

mysql> quit Bye

/mysql_2>./mysql.

ndb_mgm> show Cluster Configuration -------------------[ndbd(NDB)] 2 node(s) id=2 @140.148.3.21 4 (Version: 4.1.9, Nodegroup: 0, Master) id=3 @140.148.155. 147 (Version: 4.1.9, Nodegroup: 0) [ndb_mgmd(M GM)] 1 node(s) id=1 @140.148.3.10 4 (Version: 4.1.9) [mysqld(API)] 3 node(s) id=4 @140.148.3.21 4 (Version: 4.1.9) id=5 (Version: 4.1.9) id=6 (not connected, accepting connect from any host)

server stop Killing mysqld with pid 2860 Wait for mysqld to exit.. done /mysql_2>

ndb_mgm> show Cluster Configuration -------------------[ndbd(NDB)] 2 node(s) id=2 @140.148.3.21 4 (Version: 4.1.9,

Nodegroup: 0, Master) id=3 @140.148.155. 147 (Version: 4.1.9, Nodegroup: 0) [ndb_mgmd(M GM)] 1 node(s) id=1 @140.148.3.10 4 (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> show Cluster Configuration -------------------[ndbd(NDB)] 2 node(s) id=2 @140.148.3.21 4 (Version: 4.1.9, Nodegroup: 0, Master) id=3 @140.148.155. 147 (Version: 4.1.9, Nodegroup: 0) [ndb_mgmd(M GM)] 1 node(s) id=1 @140.148.3.10 4 (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> show Cluster Configuration -------------------[ndbd(NDB)] 2 node(s) id=2 @140.148.3.21 4 (Version: 4.1.9, Nodegroup: 0, Master) id=3 @140.148.155. 147 (Version: 4.1.9, Nodegroup: 0) [ndb_mgmd(M GM)] 1 node(s) id=1 @140.148.3.10 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> shutdown 2 NDB Cluster storage node(s) have shutdown. NDB Cluster management server shutdown.

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" make make install

Descomprimimos el tar/zip de tomcat Compilar/descarga el mdulo mod_jk.so e instalarlo en el directorio "modules" del Apache Cargar el mdulo en el archivo httpd.conf de apache

(generalmente ubicado en el directorio conf o bien en /etc/apache) LoadModule jk_module modules/mod_jk.so y agregar al mismo httpd.conf el archivo de configuracin generado al arrancar el tomcat (de ah que se debe iniciar primero el tomcat y luego el apache) Include /centia01/final/bin/java/jakartatomcat/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/jakartatomcat workers.java_home=/centia01/common/java/jsdk ps=/ worker.list=lbajp13worker worker.lbajp13worker.type=lb worker.lbajp13worker.balanced_workers= worker1, worker2, worker3 worker.worker1.host=localhost worker.worker1.port=8009 worker.worker1.type=ajp13 worker.worker1.lbfactor=10 worker.worker1.cachesize=20 worker.worker2.host=localhost worker.worker2.port=8010 worker.worker2.type=ajp13 worker.worker2.lbfactor=10 worker.worker2.cachesize=20 worker.worker3.host=localhost worker.worker3.port=8011 worker.worker3.type=ajp13 worker.worker3.lbfactor=10 worker.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" /> ... <!-- 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.

Bitcora 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 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 [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] [LastModified] = [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] [ContentType] = [text/html] [Thu Feb 10 11:52:06 2005] [jk_ajp_common.c (537)]: ajp_unmarshal_response: Header[3] [ContentLength] = [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 '/jspexamples/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 [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

Bitcora de funcionamiento con un nodo cado y recuperacin de conexin


[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 (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 [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

Potrebbero piacerti anche