Centos 7 PXC安装集群

13 篇文章 1 订阅

1.配置ip

vim /etc/hosts

在这里插入图片描述

vim /etc/selinux/config

在这里插入图片描述

2.添加防火墙端口

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --zone=public --add-port=4567/tcp --permanent
firewall-cmd --zone=public --add-port=4568/tcp --permanent
firewall-cmd --zone=public --add-port=4444/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-port

3.安装

首先卸载已安装的mysql
rpm -qa | grep mysql
rpm -e 服务名

sudo rpm -Uvh https://www.percona.com/downloads/percona-release/redhat/latest
sudo yum install Percona-XtraDB-Cluster-57
sudo  yum install Percona-XtraDB-Cluster-garbd-57

4.修改配置

sudo rpm -Uvh https://www.percona.com/downloads/percona-release/redhat/latest
sudo yum install Percona-XtraDB-Cluster-57
修改mysql的配置
vim /etc/percona-xtradb-cluster.conf.d/mysqld.cnf

#Template my.cnf for PXC
#Edit to your requirements.
[client]
socket=/var/lib/mysql/mysql.sock

[mysqld]
server-id=199
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

#Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log_bin_trust_function_creators=on
character_set_server = utf8
collation_server = utf8_bin

vim /etc/percona-xtradb-cluster.conf.d/wsrep.cnf

[mysqld]
#Path to Galera library
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so

#Cluster connection URL contains IPs of nodes
#If no IP is found, this implies that a new cluster needs to be created,
#in order to do that you need to bootstrap this node 所有节点的ip地址
wsrep_cluster_address=gcomm://192.168.31.199,192.168.31.197,192.168.31.198

#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

#Slave thread to use
wsrep_slave_threads= 8

wsrep_log_conflicts

#This changes how InnoDB autoincrement locks are managed and is a requirement for Galera
innodb_autoinc_lock_mode=2

#Node IP address 当前节点的ip
wsrep_node_address=192.168.31.199
#Cluster name 统一的集群名称
wsrep_cluster_name=pxc-cluster

#If wsrep_node_name is not specified, then system hostname will be used 当前节点的名称
wsrep_node_name=pxc-node-199

#pxc_strict_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER
pxc_strict_mode=PERMISSIVE

#SST method
wsrep_sst_method=xtrabackup-v2

#Authentication for SST method 这里是mysql用于同步数据的账户需要在所有节点上都注册该账户,账户:密码
wsrep_sst_auth=“sstuser:s3cretPass”

5.启动mysql

启动第一个主节点mysql服务
systemctl start mysql@bootstrap.service

修改密码创建用户查看这篇文章
https://blog.csdn.net/zhaohan___/article/details/105794735

启动剩余节点
service mysql start

查看集群状态
show status like ‘%wsrep_clust%’;

6.常见错误

  • 端口未开放
  • IP地址不正确
  • 同步数据的账户不正确
    mysql启动不起来或者出现错误直接看mysql日志
    /var/log/mysqld.log
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

I'm the future

希望有幸帮到解决问题

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值