01pxc集群的部署

尽可能的控制pxc集群的规模,pxc集群节点越多,数据同步的速度就越慢

所有pxc节点的硬件配置最好相同,pxc集群数据同步的速度取决于配置最低的节点

Pxc集群只支持innodb引擎

安装pxc集群

第一个集群,作为mycat的第一个分片

安装前的准备,因为centos默认安装了mariadb-libs,要删除

yum remove mari* -y

pxc依赖的端口:

pxc集群要使用四个端口,所以防火墙要放行这些端口

下载pxc的地址:https://www.percona.com/downloads/Percona-XtraDB-Cluster-LATEST/

下载安装依赖yum localinstall –y percona-xtrabackup-24-2.4.11-1.el7.x86_64.rpm

 

下载安装qpress

ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/AndreasStieger:/branches:/Archiving/CentOS_CentOS-7/x86_64/qpress-1.1-8.1.x86_64.rpm

yum localinstall –y qpress-1.1-8.1.x86_64.rpm

 

gzip Percona-XtraDB-Cluster-5.7.21-29.26-r390-el7-x86_64-bundle.tar

tar –zxf Percona-XtraDB-Cluster-5.7.21-29.26-r390-el7-x86_64-bundle.tar.gz

保留下面的安装包:

Percona-XtraDB-Cluster-57-5.7.21-29.26.1.el7.x86_64.rpm

Percona-XtraDB-Cluster-client-57-5.7.21-29.26.1.el7.x86_64.rpm

Percona-XtraDB-Cluster-server-57-5.7.21-29.26.1.el7.x86_64.rpm

Percona-XtraDB-Cluster-shared-57-5.7.21-29.26.1.el7.x86_64.rpm

Percona-XtraDB-Cluster-shared-compat-57-5.7.21-29.26.1.el7.x86_64.rpm

# 安装集群

yum localinstall –y Percona-XtraDB-Cluster-*.rpm

 

# 添加配置,原本的配置分散集中到/etc/my.cnf中

# 配置文件

 

[root@node1 ~]# cat /etc/my.cnf

[client]

socket=/var/lib/mysql/mysql.sock

 

[mysqld]

# 每个节点要不同

server-id=1

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log

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

log-bin

log_slave_updates

expire_logs_days=7

 

# 数据库字符集

character_set_server = utf8

bind-address = 0.0.0.0

#跳过DNS解析

skip-name-resolve

 

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

 

wsrep_provider=/usr/lib64/galera3/libgalera_smm.so

wsrep_cluster_name=pxc-cluster

# 集群的IP地址

wsrep_cluster_address=gcomm://10.11.0.210,10.11.0.212,10.11.0.215

wsrep_node_name=pxc1

# 本机IP地址

wsrep_node_address=10.11.0.210

wsrep_sst_method=xtrabackup-v2

wsrep_sst_auth= admin:Abc_123456

pxc_strict_mode=ENFORCING

binlog_format=ROW

default_storage_engine=InnoDB

innodb_autoinc_lock_mode=2

 

 

# 启动主节点10.11.0.210

systemctl start mysql@bootstrap.service

# 找到mysql的root密码

[root@node1 ~]# cat /var/log/mysqld.log |grep pass

2018-11-27T09:48:59.769033Z 1 [Note] A temporary password is generated for root@localhost: =K%uzAZda55f

# 登录mysql重置root密码

alter user 'root'@'localhost' identified by 'root';

# 添加同步用户,启动从节点root密码和admin的账号信息就同步到了从节点

create user 'admin'@'localhost' identified by 'Abc_123456';

grant reload,lock tables,replication client,process on *.* to 'admin'@'localhost';

flush privileges;

# 启动从节点

systemctl start mysql

 

查询集群状态show status like 'wsrep_cluster%';

数据库复制的相关信息

在pxc01上创建库,表并且插入数据,可以看到能够正常同步

create database chinasoft charset='utf8mb4';

use chinasoft;

create table students(id int primary key, name varchar(200));

insert into students(id,name) values(1,'jack');

同理在pxc02和pxc03上插入数据,也可以同步到其他节点

 

数据复制的相关信息

队列的相关信息

posted @ 2019-01-30 15:53  reblue520  阅读(862)  评论(1编辑  收藏  举报