Percona-XtraDB-Cluster安装

房东的猫 提交于 2020-03-02 04:54:56

一、PXC安装

1.1 PXC集群信息

主机 IP 所需包

bdc212

bdc213

bdc214

192.168.13.212

192.168.13.213

192.168.13.214

Percona-XtraBackup-2.2.12-r8726828-el6-x86_64-bundle.tar

Percona-XtraDB-Cluster-5.6.29-25.15-rb60e98d-el7-x86_64-bundle.tar

1.2 准备安装包

上传两个PXC安装所需的压缩包到/opt目录

    Percona-XtraBackup-2.2.12-r8726828-el6-x86_64-bundle.tar

    Percona-XtraDB-Cluster-5.6.29-25.15-rb60e98d-el7-x86_64-bundle.tar

1.3 安装PXC

    安装PXC备份软件

tar xvf Percona-XtraDB-Cluster-server-56-5.6.29-25.15.1.el7.x86_64.rpm
rpm -ivh percona-xtrabackup-debuginfo-2.2.12-1.el6.x86_64.rpm
rpm -ivh percona-xtrabackup-2.2.12-1.el6.x86_64.rpm

    安装PXC工具包

tar -xvf Percona-XtraDB-Cluster-5.6.22-25.8-r978-el6-x86_64-bundle.tar
rpm -ivh Percona-XtraDB-Cluster-devel-56-5.6.29-25.15.1.el7.x86_64.rpm
rpm -ivh Percona-XtraDB-Cluster-56-debuginfo-5.6.29-25.15.1.el7.x86_64.rpm
rpm -ivh Percona-XtraDB-Cluster-client-56-5.6.29-25.15.1.el7.x86_64.rpm
rpm -ivh Percona-XtraDB-Cluster-shared-56-5.6.29-25.15.1.el7.x86_64.rpm
rpm -ivh Percona-XtraDB-Cluster-galera-3-3.15-1.rhel7.x86_64.rpm

1.4 配置my.cnf

修改/etc/my.cnf控制文件(红色标记着重注意修改)

[client]
port = 3306
socket = /var/lib/mysql/mysql.sock

[mysqld]  
port=3306 
socket= /var/lib/mysql/mysql.sock
log_error=/opt/percona/error.log
wait_timeout=60 
interactive_timeout = 3600 
character-set-server = utf8 
skip-name-resolve 
datadir=/opt/percona/data   #edit
user=mysql                  #edit

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

# Cluster connection URL contains the IPs of node#1, node#2 and node#3 
wsrep_cluster_address=gcomm://192.168.8.212,192.168.252.213,192.168.8.214   #edit

# 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 autoincrement locks are managed and is requirement for Galera 
innodb_autoinc_lock_mode=2 

# Node #1 address 
wsrep_node_address=192.168.8.212   #edit
#SST method 

#wsrep_sst_method=rsync 
wsrep_sst_method=xtrabackup-v2 

# Cluster name 
wsrep_cluster_name=my_percona_cluster 

#Authentication for SST method 
wsrep_sst_auth="sst:sst"    #edit

wsrep_max_ws_size=4294901759 
#wsrep_max_ws_rows=13107200 
wsrep_max_ws_rows=1048576 
net_retry_count=10 
net_write_timeout=300 
net_read_timeout=180

1.5 安装服务

rpm -ivh Percona-XtraDB-Cluster-server-56-5.6.24-25.11.1.el6.x86_64.rpm

  注:配置my.cnf之后再安装服务组件是为了让mysql按照my.cnf的配置数据目录进行安装。

 

二、第一节点启动

2.1 启动服务

    如果是最先启动的服务器使用

/opt/percona/support-files/mysql.server bootstrap-pxc

    其他服务器使用

/opt/percona/support-files/mysql.server start

    重要:每一次启动集群都要从上次最后关闭的节点开始。

2.2 启动客户端

./mysql –uroot -p

    查看集群状况

    mysql>Show status like 'wsrep%'

2.3 添加远程同步用户

    第一个节点启动之后第二个节点启动之前,需要配置备份用户,否则第二节点无法启动。

    因为第二节点通过xtrabackup进行拉数据,需要通过配置文件中的sst用户

CREATE USER 'sst'@'localhost' IDENTIFIED BY 'sst';
GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'sst'@'localhost';
FLUSH PRIVILEGES;

 

三、二三节点启动

    二三节点软件安装配置与第一个节点完全一致

    3.1 修改my.cnf(其余部分设置与一节点保持一致)

        vi /etc/my.cnf

        wsrep_node_address=本机Ip地址

    3.2 启动mysql服务

        /opt/percona/support-files/mysql.server start

    3.3 启动mysql客户端

        ./mysql

    3.4 查看集群情况

        mysql>show status like 'wsrep%';

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!