安装percona pxc yum源:
sudo yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
这一步会安装一个percona-release包,然后你可以运行percona-release命令去配置你想yum安装的Percona产品。
这里是percona-release语法:
sudo percona-release
官方对command的说明如下(我就不翻译了):
Available commands are enable, enable-only, disable, and setup:
enable command turns on an additional Percona repository location. For example, the following command enables the ps-80 release repository location:
$ sudo percona-release enable ps-80 release
enable-only command turns off all Percona repository locations, and enables the listed repository location after that. The following example first disables all Percona repository locations and then enables psmdb-40 experimental:
$ sudo percona-release enable-only psmdb-40 experimental
disable disables the specified repositories (or just all of them). For example, following command will disable all repository locations:
$ sudo percona-release disable all
setup
$ percona-release setup ps80
我想装mysql5.7版,所以我这里运行
percona-release setup pxc57
percona-release enable tools release
之后再运行:
sudo yum install Percona-XtraDB-Cluster-57
这样会安装pxc server 和pxc backup等程序。
官方教程让你配置/etc/my.cnf
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
wsrep_cluster_name=pxc-cluster
wsrep_cluster_address=gcomm://192.168.70.61,192.168.70.62,192.168.70.63
wsrep_node_name=pxc1
wsrep_node_address=192.168.70.61
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sstuser:passw0rd
pxc_strict_mode=ENFORCING
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
以下这两个配置项每个节点不一样:
wsrep_node_name=pxc1
wsrep_node_address=192.168.70.61
配置完my.cnf之后,要在你新添加的配置项之前加上[mysqld]要不然会报错。
我这样配置完三个节点之后启动第一个节点:
systemctl start [email protected]
启动是启动了,但是其他节点启动不起来。(其他节点启动命令:service mysql start)
需要你再配置以下几个文件:
/etc/percona-xtradb-cluster.conf.d/mysqld.cnf
/etc/percona-xtradb-cluster.conf.d/wsrep.cnf
最后,如果还是启动不了,你可以尝试telnet一下你的node1.
如果没安装telnet可以用命令:yum install -y telnet*
你只有telnet通了mysql才能正常连接。
关闭所有的防火墙或者打开防火墙对应的接口。
iptables -F这个命令去掉所有的防火墙规则。(慎用!!!)
如果还是连接不上,要检查node1上的mysql用户是不是允许外部机器访问。
use mysql;
update user set host = ’%’ where user = ’sstuser’;
grant all privileges on *.* to root@'%' identified by "password";
flush privileges;
剩下的如何配置和测试pxc网上都有教程,大家自行搜索。如果步骤不对,总是安装不成功。