Top Banner
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | MySQL en un USB Fabric: Maestro Esclavo & Switchover Seguro Keith Hollman Principal Sales Consultant EMEA MySQL [email protected]
48
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

MySQL en un USB Fabric: Maestro Esclavo & Switchover Seguro Keith Hollman Principal Sales Consultant EMEA MySQL [email protected]

Page 2: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Objetivo

• Disponer de una instancia de MySQL funcionando como Maestro en un USB pen drive, extraíble.

• Local al servidor, una instancia de MySQL Esclavo, que pueda servir de maestro en caso de necesitarlo.

• Poder promocionar el esclavo, desacoplar el maestro, y luego poder sincronizar el maestro con el esclavo una vez enchufado otra vez. Y promocionar el maestro de nuevo.

2

Page 3: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Agenda

1

2

3

Instalación de componentes

Instalando MySQL

Configurando Fabric

Switchover seguro / Expulsando el USB, y switchback.

3

4

Page 4: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalación de componentes

4

Page 5: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalación de Componentes Básicamente

• Hay que configurar una réplica de MySQL maestro esclavo.

• Para realizar el switchover & switchback de manera transparente, la forma mas sencilla es mediante MySQL Fabric.

• Esto requiere que instalemos:

– MySQL Python Connector

– MySQL Utilities (MySQL Fabric)

– 1x MySQL binary (5.7.7 RC)

• Hay una instalación de MySQL Server en el servidor: python, Utilities (Fabric), MySQL Server para el esclavo.

• En el USB están los datos del maestro y fichero de configuración.

5

Page 6: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalando el Python Connector

• Bajar los binarios de http://dev.mysql.com/downloads/connector/python/.

• http://dev.mysql.com/doc/connector-python/en/connector-python-installation-source.html

“Installing Connector/Python from Source on Unix and Unix-Like Systems”

shell> tar xzf mysql-connector-python-1.2.2.tar.gz

shell> cd mysql-connector-python-1.2.2

shell> sudo python setup.py install

• http://dev.mysql.com/doc/connector-python/en/connector-python-verification.html

shell> ls –l /usr/lib/python2.7/dist-packages/mysql*

6

Page 7: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalando las MySQL Utilities

• Bajar el código fuente desde http://dev.mysql.com/downloads/tools/utilities/1.6.html.

• http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysql-utils-install-source.html

“1.2. Source Code”

• Son scripts de python, con lo que compilamos desde el fuente: shell> tar zxvf mysql-utilities-1.6.1.tar.gz

shell> cd /home/khollman/ofi/_MySQL/sw/utils/mysql-utilities-1.6.1

shell> python ./setup.py build

shell> sudo python ./setup.py install

shell> mysqluc –version

MySQL Utilities mysqluc version 1.6.1

License type: GPLv2

7

Page 8: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Confirmación de MySQL Fabric

• Comprobar que se puede ejecutar Fabric con lo siguiente: shell> mysqlfabric –version

mysqlfabric 1.6.1

• Comprobar la existencia del fichero: shell> ls -lt /etc/mysql/fabric.cfg

8

Page 9: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Agenda

1

2

3

Instalación de componentes

Instalando MySQL

Configurando Fabric

Switchover seguro / Expulsando el USB, y switchback.

9

4

Page 10: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalando MySQL

10

Page 11: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalando MySQL Requisitos

• Las instancias MySQL tendrán los datadir y configuración:

– Instalado local al servidor: MySQL Fabric ‘state store’ repositorio.

– Instalado en el USB: Instancia MySQL para el entorno Maestro ‘desenchufable’.

– Instalado local al servidor: Instancia MySQL para el entorno Esclavo.

• En éste ejemplo, se usará los binarios instalados local al servidor, no está instalado el software en el USB. Sólo estarán los datos y configuración.

• Dependerá de las necesidades del entorno, espacio libre, requerimientos de separar binarios y versiones de la aplicación final, seguridad, etc.

11

Page 12: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalando MySQL Tareas comunes

• Primero prepararemos el entorno, e instalamos en local:

shell> groupadd mysql

shell> useradd -r -g mysql mysql

shell> cd /usr/local

shell> tar zxvf mysql-5.7.7-rc-linux-glibc2.5-x86_64.tar.gz

shell> ln -s /usr/local/mysql-5.7.7-rc-linux-glibc2.5-x86_64 /usr/local/mysql

shell> cd mysql

shell> mkdir mysql-files

shell> chmod 770 mysql-files

shell> chown -R mysql .

shell> chgrp -R mysql .

12

Page 13: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalando MySQL Tareas particulares al entorno Fabric

• Crear un fichero my.cnf para Fabric:

• Ej. vi /usr/local/mysql/my.cnf

• Identificar el repositorio de manera única:

– port, server-id, y en la ruta del datadir “/opt/mysql/fabric/63301/data”, etc.

– Véase anexo “Fabric my.cnf”

• Estamos usando 5.7, por lo que la instalación ya no usa mysql_install_db: shell> mysqld --defaults-file=/usr/local/mysql/my.cnf --initialize --user=mysql

13

Page 14: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalando MySQL Tareas particulares al entorno Fabric

• Y en 5.7 hay una seguridad mejorada y hemos de encontrar la contraseña de root y cambiárselo:

shell> tail /opt/mysql/fabric/63301/data/mysqld.err

shell> mysqladmin --defaults-file=/usr/local/mysql/my.cnf --ssl=0 -uroot –S

/opt/mysql/fabric/63301/mysql.sock –p’JHjuyTnq3=Sk’ password ‘contraseña‘

shell> mysql_ssl_rsa_setup --defaults-file=/usr/local/mysql/my.cnf

shell> chown -R root .

shell> chown -R mysql mysql-files (data está en /opt/mysql/fabric/63301)

• Iniciamos la instancia para funcionar con Fabric: shell> mysqld_safe --defaults-file=/usr/local/mysql/my.cnf --user=mysql &

14

Page 15: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalando MySQL Preparando el Maestro

• Ahora vamos a preparar el USB para instalar el software para el Maestro.

• Determinamos el UUID del USB:

shell> ls -lrt /dev/disk/by-UUID

• Obtenemos el UUID para insertarlo en el /etc/fstab:

UUID=0012-D687 /media/usb_externo vfat

users,rw,noauto,exec,nofail,mand,suid 0 0

• Y lo montamos como el usuario del s.o. ‘mysql’:

shell> mount /media/usb_externo

15

Page 16: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalando MySQL Preparando el Maestro I

shell> cd /media/external_usb/

shell> mkdir mysql

shell> cp /usr/local/mysql/my.cnf /media/external_usb/mysql/my3306.cnf

shell> ln -s /media/usb_externo/mysql/my3306.cnf

/usr/local/mysql/my3306.cnf

• Nos aseguramos las rutas apuntan al USB externo en la instancia que interesa:

shell> vi my3306.cnf

:1,$ s!/opt/mysql/fabric/63301!/media/external_usb/mysql!g

• Y qué el socket esté ubicado en almacenamiento local, no en el disco externo.

– Véase anexo “my3306.cnf”

16

Page 17: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalando MySQL Preparando el Maestro II

• Instanciamos el entorno para el Maestro: shell> mysqld --defaults-file=/usr/local/mysql/my3306.cnf --initialize --

user=mysql

shell> tail /media/usb_externo/mysql/data/mysqld.err

shell> mysqladmin -S /tmp/mysql3306.sock -uroot –p’FjfLxwNfh0_t’ password

‘contraseña'

• Acabamos la instalación segura para el Maestro:

shell> mysql_ssl_rsa_setup --defaults-file=/usr/local/mysql/my3306.cnf

• Iniciamos la instancia Maestra:

shell> mysqld_safe --defaults-file=/usr/local/mysql/my3306.cnf --

user=mysql &

17

Page 18: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalando MySQL Preparando el Esclavo

• Ahora a crear el entorno para el Esclavo: shell> cd /usr/local/mysql

shell> cp my.cnf my3307.cnf

• Nos aseguramos que las rutas apuntan a la instancia 3307:

shell> vi my3307.cnf (anexo my3307.cnf) :1,$ s!/opt/mysql/fabric/63301!/opt/mysql/fabric/3307!g

• Instanciamos el entorno: shell> mysqld --defaults-file=/usr/local/mysql/my3307.cnf --initialize --user=mysql

tail /opt/mysql/fabric/3307/data/mysqld.err

shell> mysql_ssl_rsa_setup --defaults-file=/usr/local/mysql/my3307.cnf

shell> mysqld_safe --defaults-file=/usr/local/mysql/my3307.cnf --user=mysql &

shell> mysqladmin -S /tmp/mysql3306.sock -uroot -p'orL&qYnT26A!' password

‘contraseña'

18

Page 19: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Instalando MySQL Recordando

• Para arrancar: mysqld_safe --defaults-file=/usr/local/mysql/my.cnf --user=mysql &

mysqld_safe --defaults-file=/usr/local/mysql/my3306.cnf --user=mysql &

mysqld_safe --defaults-file=/usr/local/mysql/my3307.cnf --user=mysql &

• Para parar: mysqladmin -S /tmp/mysql3306.sock -uroot -p shutdown

mysqladmin -S /opt/mysql/fabric/3307/mysql.sock -uroot -p shutdown

mysqladmin -S /opt/mysql/fabric/63301/mysql.sock -uroot -p shutdown

• mysql CLI mysql –S /tmp/mysql3306.sock –uroot

mysql –S /opt/mysql/fabric/3307/mysql.sock –uroot

mysql –S /opt/mysql/fabric/63301/mysql.sock -uroot

19

Page 20: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Agenda

1

2

3

Instalación de componentes

Instalando MySQL

Configurando Fabric

Switchover seguro / Expulsando el USB, y switchback.

20

4

Page 21: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 21

Configurando Fabric

Page 22: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Configurando Fabric Usuarios

• Damos permiso a root a conectarse desde cada otra instancia, en las 3 instancias (a ejectuar en cada una):

mysql> GRANT ALL ON *.* TO root@'%' identified by ‘contraseña‘;

– Ignorar los avisos de "Warning (Code 1287): Using GRANT for creating new user is deprecated and will be removed in future release. Create new user with CREATE USER

statement."

• Creamos el usuario que los procesos Fabric que se va a necesitar, en las 3 instancias (a ejectuar en cada una) y por facilidad:

mysql> GRANT ALL ON *.* TO fabric@'%' identified by 'fabric‘;

22

Page 23: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Configurando Fabric Usuarios I

• Comprobrando el acceso: shell> mysql -S /opt/mysql/fabric/63301/mysql.sock -ufabric –pfabric

Permisos recomendados: http://dev.mysql.com/doc/mysql-fabric/1.6/en/fabric-create-user.html

• Configuramos el fabric.cfg y ajustamos el puerto (63301) y las contraseñas: shell> vi /etc/mysql/fabric.cfg

• Empezamos la configuración lógica, dentro de Fabric: shell> mysqlfabric --config=/etc/mysql/fabric.cfg manage setup

[INFO] 1437133916.793842 - MainThread - Initializing persister: user (fabric), server (localhost:63301), database

(fabric).

Finishing initial setup

=======================

Password for admin user is not yet set.

Password for admin/xmlrpc:

23

Page 24: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Configurando Fabric Usuarios II

• Hay que teclear la contraseña que se quiera para el usuario admin en el protocolo xmlrpc 2 veces.

• Luego, se puede configurar en el /etc/mysql/fabric.cfg para facilitar las tareas de administración. Si no, nos pide la contraseña de ‘admin’ cada vez.

• Hasta aquí, lo único que ha hecho es crear en el repositorio, en el esquema ‘fabric’ las tablas que guardan la configuración del ‘backing store’.

shell> mysql -S /opt/mysql/fabric/63301/mysql.sock -ufabric -pfabric fabric

mysql> show tables;

24

Page 25: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Configurando Fabric Configurando la topologia

• Ahora iniciamos los procesos Fabric, en modo demonio: shell> mysqlfabric manage start –daemonize

• Creamos la lógica. “mygroup” es el nombre del grupo: shell> mysqlfabric group create mygroup

Password for admin:

Fabric UUID: 5ca1ab1e-a007-feed-f00d-cab3fe13249e

Time-To-Live: 1

uuid finished success result

------------------------------------ -------- ------- ------

a46e3609-baa2-4ef4-a0d3-7d364b2a102f 1 1 1

state success when description

----- ------- ------------- ------------------------------------------------------------------

3 2 1437134826.51 Triggered by <mysql.fabric.events.Event object at 0x7f7d970ac710>.

4 2 1437134826.51 Executing action (_create_group).

5 2 1437134826.52 Executed action (_create_group).

25

Page 26: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Configurando Fabric Configurando la topologia I

• Comprobamos que se haya creado el grupo bien: shell> mysqlfabric group lookup_groups

• Añadimos los 2 servidores al grupo: shell> mysqlfabric group add mygroup 127.0.0.1:3306

shell> mysqlfabric group add mygroup 127.0.0.1:3307

• Comprobamos: shell> mysqlfabric group lookup_servers mygroup

• Tomamos nota del “server_uuid”. Y promocionamos el que queremos como Maestro:

mysqlfabric group promote mygroup --slave_id 247608f4-2be8-11e5-b6a5-7c7a91bc3176

26

Page 27: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Configurando Fabric Configurando la topologia II

• Volvemos a comprobar: shell> mysqlfabric group lookup_servers mygroup

server_uuid address status mode weight

------------------------------------ -------------- --------- ---------- ------

247608f4-2be8-11e5-b6a5-7c7a91bc3176 127.0.0.1:3306 PRIMARY READ_WRITE 1.0

fdd78d44-2bfb-11e5-b8d1-fcab64f39719 127.0.0.1:3307 SECONDARY READ_ONLY 1.0

• Ahora que está todo configurado, falta activar la monitorización por parte de Fabric:

shell> mysqlfabric group activate mygroup

27

Page 28: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Configurando Fabric Configurando la topologia III

• Ver que la réplica funciona: mysql -uroot -p -P3306 -h127.0.0.1

create database ant; create table master_info (id int(5), descr varchar(30));

insert into master_info values (1,'algo de descripcion'),(2,'otra descripcion');

select * from master_info;

• Observamos el esclavo : shell> mysql -uroot -p -P3307 -h127.0.0.1 -e "use ant; select * from

master_info;"

• Al configurar las 2 instancias y promocionar uno, se ha activado replica internamente.

• Ahora vamos a observar que ocurre al extraer el USB, es decir, apagar el Maestro y promocionar.

28

Page 29: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Agenda

1

2

3

Instalación de componentes

Instalando MySQL

Configurando Fabric

Switchover seguro / Expulsando el USB, y switchback.

29

4

Page 30: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Switchover seguro / Expulsando el USB, y switchback

30

Page 31: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Switchover Seguro Expulsando el USB

• Al tener los datos claves en el maestro, querremos extraer el USB y los datos de una forma u otra.

• Vamos a proceder a realizarlo de forma segura, donde si se hiciera de manera no-segura, Fabric se comportaría igual.

• Sabiendo que vamos a extraer el USB, promocionamos el Esclavo: shell> mysqlfabric group promote mygroup --slave_id=fdd78d44-2bfb-11e5-b8d1-

fcab64f39719

server_uuid address status mode weight

------------------------------------ -------------- --------- ---------- ------

247608f4-2be8-11e5-b6a5-7c7a91bc3176 127.0.0.1:3306 SECONDARY READ_ONLY 1.0

fdd78d44-2bfb-11e5-b8d1-fcab64f39719 127.0.0.1:3307 PRIMARY READ_WRITE 1.0

31

Page 32: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Switchover Seguro Expulsando el USB I

• Ahora podemos parar la instancia del USB: shell> mysqladmin -S /tmp/mysql3306.sock -uroot -p shutdown

• Cual es el estado ahora: shell> mysqlfabric group health mygroup

uuid is_alive status is_not_running is_not_configured io_not_running

sql_not_running io_error sql_error

------------------------------------ -------- ------- -------------- ----------------- -------------- --

------------- -------- ---------

247608f4-2be8-11e5-b6a5-7c7a91bc3176 0 FAULTY 0 0 0

0 False False

fdd78d44-2bfb-11e5-b8d1-fcab64f39719 1 PRIMARY 0 0 0

0 False False

• Ahora podemos extraer el USB, con el datadir & my3306.cnf del Maestro sin problemas.

32

Page 33: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Switchover Seguro Switchback – promocionando el antiguo Maestro

• Insertamos algún dato adicional en el nuevo master (-P3307 / UUID...9719):

mysql> insert into ant.master_info values (3,'some more info');

• Confirmamos: mysql -uroot -p -P3307 -h127.0.0.1 -e "use ant; select * from master_info;"

• Arrancamos el antiguo Maestro: mysqld_safe --defaults-file=/usr/local/mysql/my3306.cnf --user=mysql &

• Aunque Fabric aun lo considera “FAULTY” al haberse quedado como Esclavo, nada mas iniciarse, la réplica funciona y está sincronizándose.

mysql -uroot -p -P3306 -h127.0.0.1 -e “select * from ant.master_info;"

33

Page 34: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Switchover Seguro Switchback – promocionando el antiguo Maestro

• Cambiamos el estado en Fabric: mysqlfabric server set_status 247608f4-2be8-11e5-b6a5-7c7a91bc3176 spare

• Fabric incluye en entorno como SPARE al detectar que todo está bien con la instancia. Ahora podemos hacer el paso hacia SECONDARY:

mysqlfabric server set_status 247608f4-2be8-11e5-b6a5-7c7a91bc3176 secondary

• Aseguramos que la réplica sigue funcionando: mysql -uroot -p -P3307 -h127.0.0.1 -e "insert into ant.master_info values

(4,'additional');“

mysql -uroot -p -P3306 -h127.0.0.1 -e “select * from ant.master_info;"

• Promocionamos el Maestro otra vez: mysqlfabric group promote mygroup --slave_id=247608f4-2be8-11e5-b6a5-7c7a91bc3176

34

Page 35: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Switchover Seguro Switchback – promocionando el antiguo Maestro

• Comprobamos el estado de todo: mysqlfabric group health mygroup

uuid is_alive status is_not_running is_not_configured io_not_running sql_not_running io_error

sql_error

------------------------------------ -------- --------- -------------- ----------------- --------------

--------------- -------- ---------

247608f4-2be8-11e5-b6a5-7c7a91bc3176 1 PRIMARY 0 0 0

0 False False

fdd78d44-2bfb-11e5-b8d1-fcab64f39719 1 SECONDARY 0 0 0

0 False False

35

Page 36: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Arranque y parada de entorno pre-configurado

36

Page 37: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Iniciando el entorno pre-configurado

• Si hubiera alguna duda, antes de empezar, confirmar que todo se paró correctamente:

– Revisar el log de Fabric: /var/log/fabric.log

– Revisar los logs de las instancias de MySQL: • Maestro: /media/usb_externo/mysql/mysqld_safe.log

• Esclavo: /opt/mysql/fabric/3307/mysqld_safe.log

• Arrancamos Primero la instancia de Fabric: mysqld_safe --defaults-file=/usr/local/mysql/my.cnf --user=mysql &

• Iniciamos la monitorización de Fabric: mysqlfabric manage start --daemonize

37

Page 38: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Iniciando el entorno pre-configurado

• Luego, arrancamos las instancias Master & Esclavo: mysqld_safe --defaults-file=/usr/local/mysql/my3306.cnf --user=mysql &

mysqld_safe --defaults-file=/usr/local/mysql/my3307.cnf --user=mysql &

• Comprobamos los logs:

vi + /var/log/fabric.log

• Veamos como quedó la réplica: mysqlfabric group health mygroup

uuid is_alive status is_not_running is_not_configured io_not_running sql_not_running io_error

sql_error

------------------------------------ -------- --------- -------------- ----------------- --------------

--------------- -------- ---------

247608f4-2be8-11e5-b6a5-7c7a91bc3176 1 PRIMARY 0 0 0

0 False False

fdd78d44-2bfb-11e5-b8d1-fcab64f39719 1 SECONDARY 0 0 0

0 False False

38

Page 39: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Parada controlada

• Dependiendo de como queremos parar el entorno, y cuales son los motivos, se puede hacer en un orden u otro. Si paramos Fabric primero, no queda registrado las paradas de las otras instancias. Si paramos las instancias primero, en el arranque siguiente, habrá que activar cada uno dentro de Fabric.

• Paramos las instancias Maestro y Esclavo como siempre:

mysqladmin -S /tmp/mysql3306.sock -uroot -p shutdown

mysqladmin -S /opt/mysql/fabric/3307/mysql.sock -uroot -p shutdown

39

Page 40: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Parada controlada

• Fabric: mysqlfabric manage ping

Fabric UUID: 5ca1ab1e-a007-feed-f00d-cab3fe13249e

Time-To-Live: 1

mysqlfabric manage stop

Fabric UUID: 5ca1ab1e-a007-feed-f00d-cab3fe13249e

Time-To-Live: 1

mysqlfabric manage ping

<urlopen error [Errno 111] Connection refused>

• Una vez parado el proceso de Fabric, paramos la instancia / el repositorio: mysqladmin -S /opt/mysql/fabric/63301/mysql.sock -uroot -p shutdown

40

Page 41: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Anexos

41

Page 42: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Anexo: Fabric my.cnf 63301 [mysqld_safe]

log-error =/opt/mysql/fabric/63301/mysqld_safe.log

lc-messages-dir =/usr/local/mysql/share/english/errmsg.sys

[mysqld]

performance-schema-instrument ='%=ON'

server-id =63301

port =63301

pid-file =/opt/mysql/fabric/63301/khollman-es_63301.pid

socket =/opt/mysql/fabric/63301/mysql.sock

datadir =/opt/mysql/fabric/63301/data

log-error =/opt/mysql/fabric/63301/data/mysqld.err

general-log =TRUE

innodb_buffer_pool_size =40M

innodb_file_per_table =1

innodb_log_buffer_size =8M

innodb_log_file_size =12M

innodb_flush_log_at_trx_commit =2

innodb_data_file_path =ibdata1:12M;ibdata2:12M:autoextend

innodb_open_files =150

table_open_cache =80

open_files_limit =300

query_cache_size =0

max_connections =100

user =mysql

read_buffer_size =2M

sort_buffer_size =2M

42

Page 43: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Anexo: Fabric my3306.cnf 3306 [mysqld_safe]

log-error =/media/usb_externo/mysql/mysqld_safe.log

lc-messages-dir =/usr/local/mysql/share/english/errmsg.sys

[mysqld]

performance-schema-instrument ='%=ON'

server-id =3306

port =3306

pid-file =/media/usb_externo/mysql/khollman-es_3306.pid

socket =/tmp/mysql3306.sock

datadir =/media/usb_externo/mysql/data

log-error =/media/usb_externo/mysql/data/mysqld.err

general-log =TRUE

innodb_buffer_pool_size =40M

innodb_file_per_table =1

innodb_log_buffer_size =8M

innodb_log_file_size =12M

innodb_flush_log_at_trx_commit =2

innodb_data_file_path =ibdata1:12M;ibdata2:12M:autoextend

innodb_open_files =150

table_open_cache =80

open_files_limit =300

query_cache_size =0

max_connections =100

user =mysql

read_buffer_size =2M

sort_buffer_size =2M

# Replication

log-bin =fabric3306

binlog-row-image =minimal

binlog-rows-query-log-events =1

log-slave-updates =TRUE

43

gtid-mode =ON

enforce-gtid-consistency =TRUE

master-info-repository =TABLE

relay-log-info-repository =TABLE

sync_binlog =1

sync_master_info =1

slave-parallel-workers =2

slave_transaction_retries =0

binlog-checksum =CRC32

master-verify-checksum =1

slave-sql-verify-checksum =1

binlog-rows-query-log-events =1

binlog_format =ROW

report-host =khollman-es

report-port =3306

Page 44: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Anexo: Fabric my3307.cnf 3307 [mysqld_safe]

log-error =/opt/mysql/fabric/3307/mysqld_safe.log

lc-messages-dir =/usr/local/mysql/share/english/errmsg.sys

[mysqld]

performance-schema-instrument ='%=ON'

server-id =3307

port =3307

pid-file =/opt/mysql/fabric/3307/khollman-es_3307.pid

socket =/opt/mysql/fabric/3307/mysql.sock

datadir =/opt/mysql/fabric/3307/data

log-error =/opt/mysql/fabric/3307/data/mysqld.err

general-log =TRUE

innodb_buffer_pool_size =40M

innodb_file_per_table =1

innodb_log_buffer_size =8M

innodb_log_file_size =12M

innodb_flush_log_at_trx_commit =2

innodb_data_file_path =ibdata1:12M;ibdata2:12M:autoextend

innodb_open_files =150

table_open_cache =80

open_files_limit =300

query_cache_size =0

max_connections =100

user =mysql

read_buffer_size =2M

sort_buffer_size =2M

# Replication

log-bin =fabric3307

binlog-row-image =minimal

binlog-rows-query-log-events =1

log-slave-updates =TRUE

44

gtid-mode =ON

enforce-gtid-consistency =TRUE

master-info-repository =TABLE

relay-log-info-repository =TABLE

sync_binlog =1

sync_master_info =1

slave-parallel-workers =2

slave_transaction_retries =0

binlog-checksum =CRC32

master-verify-checksum =1

slave-sql-verify-checksum =1

binlog-rows-query-log-events =1

binlog_format =ROW

report-host =khollman-es

report-port =3307

Page 45: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Alguna Pregunta?

Page 46: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Siguientes Pasos

46

Aprender más:

• http://www.mysql.com/products/enterprise/fabric.html

• http://dev.mysql.com/doc/mysql-utilities/1.6/en/fabric.html

Pruébame:

• http://dev.mysql.com/downloads/utilities/

Dejadnos saber que opinas:

• http://forums.mysql.com/list.php?144

[email protected]

Page 47: MySQL Fabric en un USB

Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |

Recursos Adicionales

• MySQL High-Availability

– http://mysqlhighavailability.com

• Mats Kindahl

– http://mysqlmusings.blogspot.com

• Alfranio Correia – http://alfranio-distributed.blogspot.com

• Narayanan Venkateswaran

– http://vnwrites.blogspot.com

47

Page 48: MySQL Fabric en un USB