系统相关
首页 > 系统相关> > Linux - Galera Cluster

Linux - Galera Cluster

作者:互联网

# 实验准备三台机器,(centos8不支持 Percona XtraDB Cluster 5.7)
# pxc1: 10.0.0.21
# pxc2: 10.0.0.22
# pxc3: 10.0.0.23

# 首先配置 Percona XtraDB Cluster 5.7需要用的yum 源
[percona]
name=percona-repo
baseurl=https://mirrors.tuna.tsinghua.edu.cn/percona/release/$releasever/RPMS/$basearch
enabled=1
gpgcheck=0

# 再copy到其他节点
  125  scp /etc/yum.repos.d/Centos-7.repo 10.0.0.22:/etc/yum.repos.d/
  126  scp /etc/yum.repos.d/Centos-7.repo 10.0.0.23:/etc/yum.repos.d/


# 安装
yum -y install Percona-XtraDB-Cluster-57

# 更改server-id,使其保持唯一(一般用当前ip最后一位)
[21:04:34 root@centos7 ~]#cat  /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=21
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

# 编辑配置文件
[21:07:11 root@centos7 ~]#cat /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
wsrep_cluster_address=gcomm://10.0.0.21,10.0.0.22,10.0.0.23

# 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
wsrep_node_address=10.0.0.21
# Cluster name
wsrep_cluster_name=pxc-cluster

#If wsrep_node_name is not specified,  then system hostname will be used
wsrep_node_name=pxc-cluster-node-1

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

# SST method
wsrep_sst_method=xtrabackup-v2

#Authentication for SST method
wsrep_sst_auth="sstuser:s3cretPass"


# copy到其他节点类似修改其节点ip,node名字
scp wsrep.cnf 10.0.0.22:/etc/percona-xtradb-cluster.conf.d/
scp wsrep.cnf 10.0.0.23:/etc/percona-xtradb-cluster.conf.d/


# 更改mysql密码
grep "temporary password" /var/log/mysqld.log
mysql -uroot -p"CW7Oy(s;ERyD"
# 记住进入mysql里面修改
alter user 'root'@'localhost' IDENTIFIED BY ''123456';

# 创建repluser, 名字和密码应该同wsrep最后那么sstuer一样
create user 'sstuser'@'localhost' IDENTIFIED BY 's3cretPass' 


# 给与权限
grant RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.*  TO 'sstuser'@'localhost';


# 查看集群
 show status like "wsrep%";

 

标签:Galera,10.0,log,cluster,wsrep,mysql,Cluster,Linux,etc
来源: https://www.cnblogs.com/noise/p/14905008.html