配置percona XtraDB Cluster

机器:2台

操作系统:Ubuntu 14.04 server

节点IP:

节点1:    172.16.53.136
节点2:    172.16.53.137

两台机器最好是干净的之前不要安装mysql,就是安装过最后也要删除干净。

安装用官网给的方法就行,我的操作系统是ubuntu所以用的apt安装,具体方法见下面的链接:

http://www.percona.com/doc/percona-xtradb-cluster/5.6/installation.html#installation

安装完后配置:

[节点1]

写在[mysqld]下:

[mysqld] 

user = mysql 

pid-file = /var/run/mysqld/mysqld.pid 

socket = /var/run/mysqld/mysqld.sock 

port = 3306 

basedir = /usr 

datadir = /var/lib/mysql 

tmpdir = /tmp 

lc-messages-dir = /usr/share/mysql 

skip-external-locking 


wsrep_provider=/usr/lib/libgalera_smm.so 

wsrep_cluster_address=gcomm:// 172.16.53.136 , 172.16.53.137


binlog_format=ROW 

default_storage_engine=InnoDB 

innodb_autoinc_lock_mode=2 

wsrep_node_name=db01.com       

wsrep_node_address=172.16.53.136   

wsrep_sst_method=xtrabackup-v2   

wsrep_cluster_name=my_ubuntu_cluster   

wsrep_sst_auth="test:123456" 


key_buffer = 16M 

max_allowed_packet = 16M 

thread_stack = 192K 

thread_cache_size       = 8 

myisam-recover         = BACKUP 

query_cache_limit = 1M 

query_cache_size        = 16M 

log_error = /var/log/mysql/error.log 

server-id = 1      数据库的ID  下一台就不能为1了

expire_logs_days = 10 

max_binlog_size         = 100M 

(注):

wsrep_node_name=db01.com       数据库的主机名

wsrep_node_address=172.16.53.136   数据库的IP

wsrep_cluster_name=my_ubuntu_cluster   所有数据库上都要统一

server-id = 1      数据库的ID  下一台就不能为1了

启动 :

/etc/init.d/mysql bootstrap-pxc

或:

mysqld_safe  --wsrep-cluster-address="gcomm://" &


查询状态:

这几个参数正确为启动成功

mysql> show status like 'wsrep%';

+----------------------------+--------------------------------------+

| Variable_name              | Value                                |

+----------------------------+--------------------------------------+

| wsrep_local_state_uuid     | b598af3e-ace3-11e2-0800-3e90eb9cd5d3 |

...

| wsrep_local_state          | 4                                    |

| wsrep_local_state_comment  | Synced                               |

...

| wsrep_cluster_size         | 1                                    |

| wsrep_cluster_status       | Primary                              |

| wsrep_connected            | ON                                   |

...

| wsrep_ready                | ON                                   |

+----------------------------+--------------------------------------+


mysql>CREATE USER 'test'@'%' IDENTIFIED BY '123456';

mysql>GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'test''@'%';

mysql>FLUSH PRIVILEGES;

(test用户要在第二台数据库上能登录,为了方便我个人直接就用%了)


[节点2]

[mysqld] 

user = mysql 

pid-file = /var/run/mysqld/mysqld.pid 

socket = /var/run/mysqld/mysqld.sock 

port = 3306 

basedir = /usr 

datadir = /var/lib/mysql 

tmpdir = /tmp 

lc-messages-dir = /usr/share/mysql 

skip-external-locking 


wsrep_provider=/usr/lib/libgalera_smm.so 

wsrep_cluster_address=gcomm://172.16.53.136,172.16.53.137 

binlog_format=ROW 

default_storage_engine=InnoDB 

innodb_autoinc_lock_mode=2 

wsrep_node_name=db02.com  节点2的主机名

wsrep_node_address=172.16.53.137 节点2的IP

wsrep_sst_method=xtrabackup-v2 

wsrep_cluster_name=my_ubuntu_cluster  所有数据库上都要 统一

wsrep_sst_auth="test:123456" 



key_buffer = 16M 

max_allowed_packet = 16M 

thread_stack = 192K 

thread_cache_size       = 8 

myisam-recover         = BACKUP 

query_cache_limit = 1M 

query_cache_size        = 16M 

log_error = /var/log/mysql/error.log 

server-id = 2    这个不能和别的重复

expire_logs_days = 10 

max_binlog_size         = 100M 



节点2启动

/etc/init.d/mysql start

nohup mysqld_safe --wsrep-cluster-address=gcomm://主IP:4567 &

查询状态:


mysql> show status like 'wsrep%';

+----------------------------+--------------------------------------+

| Variable_name              | Value                                |

+----------------------------+--------------------------------------+

| wsrep_local_state_uuid     | b598af3e-ace3-11e2-0800-3e90eb9cd5d3 |

...

| wsrep_local_state          | 4                                    |

| wsrep_local_state_comment  | Synced                               |

...

| wsrep_cluster_size         | 2                                    |

| wsrep_cluster_status       | Primary                              |

| wsrep_connected            | ON                                   |

...

| wsrep_ready                | ON                                   |

+----------------------------+--------------------------------------+

40 rows in set (0.01 sec)



第一个库启动正常,

第二个报错

报的错误:

WSREP_SST: [ERROR] Cleanup after exit with status:1 (20150121 09:31:50.227) 

2015-01-21 09:31:50 3776 [ERROR] WSREP: Process completed with error: wsrep_sst_xtrabackup-v2 --role 'joiner' --address '172.16.53.137' --auth 'hans:123456' --datadir '/var/lib/mysql/' --defaults-file '/etc/mysql/my.cnf' --parent '3776'  '' : 1 (Operation not permitted)


150121 09:31:50 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 


一直提示:xtrabackup-v2 相关错误在网上找了一些方法没有解决,

最后我把wsrep_sst_method改成

wsrep_sst_method          = rsync

启动成功.

随后又 rsync在改成 xtrabackup-v2 居然也启动成功了,不知道为什么这样,问同事他们也遇到过,他们是把机器重启后就好了。


你可能感兴趣的:(mysql,cluster,ubuntu,percona,XtraDB)