Instalando Percona XtraDB Cluster
Dicas MySQL

Instalando Percona XtraDB Cluster


Original post: http://anothermysqldba.blogspot.com/2014/06/installing-percona-xtradb-cluster.html

Então, é claro Percona tem documentação que explique o processo. O objetivo deste blog é para entrar em um pouco mais detalhadamente na esperança de que possa ajudar alguém. 

Hyperlinks para a revisão: 
  • CentOS - http://www.percona.com/doc/percona-xtradb-cluster/5.5/howtos/cenots_howto.html
  • Ubuntu - http://www.percona.com/doc/percona-xtradb-cluster/5.5/howtos/ubuntu_howto.html
  • Instalando Percona XtraDB Cluster de Binários -
    • http://www.percona.com/doc/percona-xtradb-cluster/5.5/installation.html
Pré-requisitos 
  • Firewall foi criado para permitir a conexão com portas 3306, 4444, 4567 e 4568
  • Pare de iptables para redes locais internos ou ajustar as regras Iptable.
/etc/init.d/iptables stop 

  • SELinux está desativado
echo 0 >/selinux/enforce 
vi /etc/selinux/config 

  • Configurar SSH Keys e coloque em authorized_keys para que todos os valores estão em id_rsa.pub authorized_keys em todos os servidores.
# ssh-keygen -t rsa 
# cd /root/.ssh/ 
# cp id_rsa.pub authorized_keys 
# chmod 600 /root/.ssh/authorized_keys 
# chmod 700 /root/.ssh/ 


Então eu comecei com um servidor de instalação básica do CentOS 6.5. 
# yum -y install http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm 
# yum -y install http://mirror.pnl.gov/epel/6/x86_64/epel-release-6-8.noarch.rpm 
# wget http://www.percona.com/downloads/RPM-GPG-KEY-percona /etc/pki/rpm-gpg/RPM-GPG-KEY-percona 
# wget http://www.percona.com/downloads/RPM-GPG-KEY-percona /etc/pki/rpm-gpg/RPM-GPG-KEY-percona 
# yum -y install socat 


Para evitar quaisquer conflitos Tirei o mysql-libs e dependências relacionados 
# rpm -e mysql-libs postfix cronie redhat-lsb-core redhat-lsb-printing redhat-lsb-graphics libcgroup numad redhat-lsb sysstat crontabs cronie-anacron redhat-lsb-compat


Então eu instalei os pacotes Cluster Percona. 
# yum -y install Percona-XtraDB-Cluster-full-56 
[[email protected] ~]# /etc/init.d/mysql start 
Starting MySQL (Percona XtraDB Cluster)......... SUCCESS! 
mysql -e "CREATE FUNCTION fnv1a_64 RETURNS INTEGER SONAME 'libfnv1a_udf.so'" 
mysql -e "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'" 
mysql -e "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'" 


Assim, podemos substituir os itens que removidos por nó .. 
yum -y install postfix cronie redhat-lsb-core redhat-lsb-printing redhat-lsb-graphics libcgroup numad redhat-lsb sysstat crontabs cronie-anacron redhat-lsb-compat 


Então, repetindo os passos acima irá instalar os pacotes para que possamos configurar o cluster seguinte. 

[[email protected] ~]# /etc/init.d/mysql start 
Starting MySQL (Percona XtraDB Cluster)......... SUCCESS! 
[[email protected] ~]# /etc/init.d/mysql start 
Starting MySQL (Percona XtraDB Cluster)........ SUCCESS! 

Enquanto nós temos três instâncias do MySQL em execução que ainda não é um cluster. 

Configurando os nós
  • http://www.percona.com/doc/percona-xtradb-cluster/5.5/howtos/cenots_howto.html
  • http://galeracluster.com/documentation-webpages/configuration.html
  • http://galeracluster.com/documentation-webpages/search.html
  • http://www.magicposition.com/2012/01/16/installing-galera-mysql-clustering-on-ubuntu-10/

Nó 1 / etc / my.cnf 
[mysqld] 

datadir=/var/lib/mysql 
user=mysql 

# Path to Galera library 
wsrep_provider=/usr/lib64/libgalera_smm.so 

# Cluster connection URL contains the IPs of node#1, node#2 and node#3 
# node 1 192.168.0.33 
# nod3 2 192.168.0.34 
# nod3 3 192.168.0.35 
wsrep_cluster_address=gcomm://192.168.0.33,192.168.0.34,192.168.0.35 

# In order for Galera to work correctly binlog format should be ROW 
binlog_format=ROW 

# MyISAM storage engine has only experimental support 
default_storage_engine=InnoDB 

# This changes how InnoDB auto increment locks are managed and is a requirement for Galera 
innodb_autoinc_lock_mode=2 

# Node #1 address 
wsrep_node_address=192.168.0.33 

# SST method 
#wsrep_sst_method=xtrabackup 
wsrep_sst_method=rsync # 
# wsrep_sst_method=rsync_wan # 
# wsrep_sst_method=mysqldump # SLOW 

# Cluster name 
wsrep_cluster_name=percona_cluster 

# Authentication for SST method 
wsrep_sst_auth="root:<password_here>" 

# server_id 
server_id=3232235553 #SELECT INET_ATON('192.168.0.33') 

#[client] 
socket=/var/lib/mysql/mysql.sock 


Iniciando o primeiro nó de cluster 
/etc/init.d/mysql start --wsrep-cluster-address="gcomm://" 
Starting MySQL (Percona XtraDB Cluster)...................................... SUCCESS! 

[[email protected] mysql]# cat grastate.dat 
# GALERA saved state 
version: 2.1 
uuid: 97c457f8-f3d2-11e3-9b4e-374ebb7427e6 
seqno: -1 
cert_index: 


O aglomerado é apenas um nó no momento. 
mysql> select @@hostname\G show global status like 'wsrep_cluster_size' \G 
*************************** 1. row *************************** 
@@hostname: node1.localdomain 
1 row in set (0.01 sec) 

*************************** 1. row *************************** 
Variable_name: wsrep_cluster_size 
Value: 1 


OK agora agora um está instalado e funcionando, podemos iniciar o nó 2 
Nó 2 / etc / my.cnf 
[mysqld] 

datadir=/var/lib/mysql 
user=mysql 

# Path to Galera library 
wsrep_provider=/usr/lib64/libgalera_smm.so 

# Cluster connection URL contains the IPs of node#1, node#2 and node#3 
# node 1 192.168.0.33 
# nod3 2 192.168.0.34 
# nod3 3 192.168.0.35 
wsrep_cluster_address=gcomm://192.168.0.33,192.168.0.34,192.168.0.35 

# In order for Galera to work correctly binlog format should be ROW 
binlog_format=ROW 

# MyISAM storage engine has only experimental support 
default_storage_engine=InnoDB 

# This changes how InnoDB auto increment locks are managed and is a requirement for Galera 
innodb_autoinc_lock_mode=2 

# Node #1 address 
wsrep_node_address=192.168.0.34 

# SST method 
#wsrep_sst_method=xtrabackup 
wsrep_sst_method=rsync # 
# wsrep_sst_method=rsync_wan # 
# wsrep_sst_method=mysqldump # SLOW 


# Cluster name 
wsrep_cluster_name=percona_cluster 

# Authentication for SST method 
wsrep_sst_auth="root:" 

# to enable debug level logging, set this to 1 
wsrep_debug=1 

# server_id 
server_id=3232235554 # SELECT INET_ATON('192.168.0.34') 

#[client] 
socket=/var/lib/mysql/mysql.sock 

[[email protected] mysql]#/etc/init.d/mysql start 
Starting MySQL (Percona XtraDB Cluster)........................... SUCCESS! 


Agora compare os nossos valores em cada nó. 
mysql> select @@hostname\G show global status like 'wsrep_cluster_size' \G 
*************************** 1. row *************************** 
@@hostname: node1.localdomain 
1 row in set (0.01 sec) 

*************************** 1. row *************************** 
Variable_name: wsrep_cluster_size 
Value: 2 

mysql> select @@hostname\G show global status like 'wsrep_cluster_size' \G 
*************************** 1. row *************************** 
@@hostname: node2.localdomain 
1 row in set (0.00 sec) 

*************************** 1. row *************************** 
Variable_name: wsrep_cluster_size 
Value: 2 
1 row in set (0.18 sec) 


Agora vamos adicionar o nó 3 na mistura. 

Nó 3 / etc / my.cnf 
[mysqld] 

datadir=/var/lib/mysql 
user=mysql 

# Path to Galera library 
wsrep_provider=/usr/lib64/libgalera_smm.so 

# Cluster connection URL contains the IPs of node#1, node#2 and node#3 
# node 1 192.168.0.33 
# nod3 2 192.168.0.34 
# nod3 3 192.168.0.35 
wsrep_cluster_address=gcomm://192.168.0.33,192.168.0.34,192.168.0.35 

# In order for Galera to work correctly binlog format should be ROW 
binlog_format=ROW 

# MyISAM storage engine has only experimental support 
default_storage_engine=InnoDB 

# This changes how InnoDB auto increment locks are managed and is a requirement for Galera 
innodb_autoinc_lock_mode=2 

# Node #1 address 
wsrep_node_address=192.168.0.35 

# SST method 
# wsrep_sst_method=xtrabackup 
wsrep_sst_method=rsync # 
# wsrep_sst_method=rsync_wan # 
# wsrep_sst_method=mysqldump # SLOW 


# Cluster name 
wsrep_cluster_name=percona_cluster 

# Authentication for SST method 
wsrep_sst_auth="root:" 

# to enable debug level logging, set this to 1 
wsrep_debug=1 

# server_id 
server_id=3232235555 # SELECT INET_ATON('192.168.0.35') 

#[client] 
socket=/var/lib/mysql/mysql.sock 

[[email protected] mysql]#/etc/init.d/mysql start 
Starting MySQL (Percona XtraDB Cluster)........................... SUCCESS! 

[[email protected] mysql]# cat grastate.dat 
# GALERA saved state 
version: 2.1 
uuid: 97c457f8-f3d2-11e3-9b4e-374ebb7427e6 
seqno: -1 
cert_index: 


Assim como todos os nossos nós olhar como agora. 
mysql> select @@hostname\G show global status like 'wsrep_cluster_size' \G 
*************************** 1. row *************************** 
@@hostname: node1.localdomain 
1 row in set (0.01 sec) 

*************************** 1. row *************************** 
Variable_name: wsrep_cluster_size 
Value: 3 

mysql> select @@hostname\G show global status like 'wsrep_cluster_size' \G 
*************************** 1. row *************************** 
@@hostname: node2.localdomain 
1 row in set (0.00 sec) 

*************************** 1. row *************************** 
Variable_name: wsrep_cluster_size 
Value: 3 

mysql> select @@hostname\G show global status like 'wsrep_cluster_size' \G 
*************************** 1. row *************************** 
@@hostname: node3.localdomain 
1 row in set (0.00 sec) 

*************************** 1. row *************************** 
Variable_name: wsrep_cluster_size 
Value: 3 

Teste os nós 
Então agora podemos carregar alguns dados e testá-lo .. 
[[email protected] ~]# wget http://downloads.mysql.com/docs/world_innodb.sql.gz 
[[email protected] ~]# gzip -d world_innodb.sql.gz 
[[email protected] ~]# mysql -e "create database world" 
[[email protected] ~]# mysql world < world_innodb.sql 


Portanto, agora que tudo é carregado ... é todo o cluster? 
@@hostname: node1.localdomain 
DATABASE_SCHEMA: world 
ENGINE: InnoDB 
count_tables: 3 
TOTAL_DB_GB: 0.001 

@@hostname: node2.localdomain 
DATABASE_SCHEMA: world 
ENGINE: InnoDB 
count_tables: 3 
TOTAL_DB_GB: 0.001 

@@hostname: node3.localdomain 
DATABASE_SCHEMA: world 
ENGINE: InnoDB 
count_tables: 3 
TOTAL_DB_GB: 0.001 

Parece que ele está trabalhando.



loading...



Dicas MySQL








.