Mycat实现读写分离架构图:
创新互联主要从事网站制作、成都网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务革吉,十载网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792Mycat主从自动切换架构图:
Mycat下载地址:http://dl.mycat.io/1.6.7.3/20190828135747/Mycat-server-1.6.7.3-release-20190828135747-linux.tar.gz
Percona-XtraDB-Cluster下载地址:https://www.percona.com/downloads/Percona-XtraDB-Cluster-57/LATEST/
Percona-XtraBackup下载地址: https://www.percona.com/downloads/Percona-XtraBackup-2.4/LATEST/
yum仓库地址:https://www.percona.com/downloads/percona-release/redhat/
1.下载,安装Percona-XtraDB-Cluster(三台都需要装)
[root@k8s01 ~]# rpm -ivh https://www.percona.com/redir/downloads/percona-release/redhat/1.0-13/percona-release-1.0-13.noarch.rpm
[root@k8s01 ~]# yum repolist
[root@k8s01 ~]# rpm -ivh percona-xtrabackup-24-2.4.13-1.el7.x86_64.rpm
[root@k8s01 ~]# yum install Percona-XtraDB-Cluster-57 -y
2.修改配置,启动服务(k8s01节点)
[root@k8s01 ~]# vim /etc/percona-xtradb-cluster.conf.d/mysqld.cnf
log-bin=k8s01-bin
log-bin-index=k8s01-bin-index
[root@k8s01 ~]# vim /etc/percona-xtradb-cluster.conf.d/wsrep.cnf
[mysqld]
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.54.129,192.168.54.130,192.168.54.128
binlog_format=ROW
default_storage_engine=InnoDB
wsrep_slave_threads= 8
wsrep_log_conflicts
innodb_autoinc_lock_mode=2
wsrep_node_address=192.168.54.128 --三个节点值不一样
wsrep_cluster_name=mycluster
wsrep_node_name=k8s01
pxc_strict_mode=ENFORCING
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth="sstuser:s3cretPass"
[root@k8s01 ~]# mysql_install_db --defaults-file=/etc/percona-xtradb-cluster.cnf --datadir=/var/lib/mysql --初使化数据
[root@k8s01 ~]# systemctl start
mysql@bootstrap.service --第一次启动,不需要同步数据
[root@k8s01 ~]# ps -ef | grep mysql
root 60672 54285 0 14:56 pts/1 00:00:00 tailf /var/log/mysqld.log
root 66031 1 0 15:03 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr --wsrep-new-cluster
mysql 66568 66031 6 15:03 ? 00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --wsrep-provider=/usr/lib64/galera3/libgalera_smm.so --wsrep-new-cluster --log-error=
/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock --wsrep_start_position=00000000-0000-0000-0000-000000000000:-1root 66763 33815 0 15:04 pts/0 00:00:00 grep --color=auto mysql