Centos7 Percona XtraDB cluster 5.7 YUM安装

node1    10.0.3.111
node2    10.0.3.112
node3    10.0.3.113
注意:避免创建两个或任意偶数个节点集群,因为这可能会导致脑裂。


# 关闭selinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0


# 设置防火墙

确保以下端口未被防火墙阻止或其他软件使用。Percona XtraDB集群需要它们进行通信。
3306
4444
4567
4568


# 安装 node1 

yum install -y http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
yum install -y Percona-XtraDB-Cluster-57
mkdir -p /data/data/mysql/xtradb/{data,logs}
touch /data/data/mysql/xtradb/logs/{data-slow.log,error.log}
chown mysql:mysql /data/data/mysql/xtradb -R
mysqld --initialize --datadir=/data/data/mysql/xtradb/data --user=mysql
mv /etc/my.cnf /etc/my.cnf_bak
mv /etc/percona-xtradb-cluster.cnf /etc/percona-xtradb-cluster.cnf_bak
vi /etc/my.cnf
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8
[mysqld_safe]
socket=/var/lib/mysql/mysql.sock
nice=0
[mysqld]
server-id=111
user=mysql
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/lib/mysql/mysql.sock
port=3306
datadir=/data/data/mysql/xtradb/data/
log_error = /data/data/mysql/xtradb/logs/error.log
skip-external-locking
character-set-server=utf8
max_connections=10000
slow_query_log=1
slow_query_log_file=/data/data/mysql/xtradb/logs/data-slow.log
long_query_time=5
log_queries_not_using_indexes=1
bind-address=0.0.0.0
max_allowed_packet=1024M
myisam_recover_options=BACKUP
query_cache_limit=1M
query_cache_size=16M
expire_logs_days=10
log-bin-trust-function-creators=1
log-bin=bin-log
innodb_buffer_pool_size = 4G
sync_binlog=1
explicit_defaults_for_timestamp = 1
innodb_flush_method = O_DIRECT
disable_ssl
binlog_format=ROW
default_storage_engine=InnoDB
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
wsrep_cluster_address=gcomm://10.0.3.111,10.0.3.112,10.0.3.113
wsrep_slave_threads=16
wsrep_cluster_name=my_centos_cluster
wsrep_sst_method=xtrabackup-v2
wsrep_node_name=node1
wsrep_node_address=10.0.3.111
wsrep_sst_auth="sstuser:P@ssw0rd"
innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
systemctl start mysql@bootstrap.service
mysqladmin -uroot -p`cat /var/log/mysqld.log | grep 'temporary password' | awk '{print $NF}'` password 'P@ssw0rd'
mysql -uroot -p'P@ssw0rd'
mysql> CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'P@ssw0rd';
mysql> GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';
mysql> FLUSH PRIVILEGES;


# 安装 node2

yum install -y http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
yum install -y Percona-XtraDB-Cluster-57
mkdir -p /data/data/mysql/xtradb/{data,logs}
touch /data/data/mysql/xtradb/logs/{data-slow.log,error.log}
chown mysql:mysql /data/data/mysql/xtradb -R
mysqld --initialize --datadir=/data/data/mysql/xtradb/data --user=mysql
mv /etc/my.cnf /etc/my.cnf_bak
mv /etc/percona-xtradb-cluster.cnf /etc/percona-xtradb-cluster.cnf_bak
vi /etc/my.cnf
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8
[mysqld_safe]
socket=/var/lib/mysql/mysql.sock
nice=0
[mysqld]
server-id=112
user=mysql
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/lib/mysql/mysql.sock
port=3306
datadir=/data/data/mysql/xtradb/data/
log_error = /data/data/mysql/xtradb/logs/error.log
skip-external-locking
character-set-server=utf8
max_connections=10000
slow_query_log=1
slow_query_log_file=/data/data/mysql/xtradb/logs/data-slow.log
long_query_time=5
log_queries_not_using_indexes=1
bind-address=0.0.0.0
max_allowed_packet=1024M
myisam_recover_options=BACKUP
query_cache_limit=1M
query_cache_size=16M
expire_logs_days=10
log-bin-trust-function-creators=1
log-bin=bin-log
innodb_buffer_pool_size = 4G
sync_binlog=1
explicit_defaults_for_timestamp = 1
innodb_flush_method = O_DIRECT
disable_ssl
binlog_format=ROW
default_storage_engine=InnoDB
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
wsrep_cluster_address=gcomm://10.0.3.111,10.0.3.112,10.0.3.113
wsrep_slave_threads=16
wsrep_cluster_name=my_centos_cluster
wsrep_sst_method=xtrabackup-v2
wsrep_node_name=node2
wsrep_node_address=10.0.3.112
wsrep_sst_auth="sstuser:P@ssw0rd"
innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
systemctl start mysql.service


# 安装 node3 

yum install -y http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
yum install -y Percona-XtraDB-Cluster-57
mkdir -p /data/data/mysql/xtradb/{data,logs}
touch /data/data/mysql/xtradb/logs/{data-slow.log,error.log}
chown mysql:mysql /data/data/mysql/xtradb -R
mv /etc/my.cnf /etc/my.cnf_bak
mv /etc/percona-xtradb-cluster.cnf /etc/percona-xtradb-cluster.cnf_bak
vi /etc/my.cnf
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8
[mysqld_safe]
socket=/var/lib/mysql/mysql.sock
nice=0
[mysqld]
server-id=113
user=mysql
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/lib/mysql/mysql.sock
port=3306
datadir=/data/data/mysql/xtradb/data/
log_error = /data/data/mysql/xtradb/logs/error.log
skip-external-locking
character-set-server=utf8
max_connections=10000
slow_query_log=1
slow_query_log_file=/data/data/mysql/xtradb/logs/data-slow.log
long_query_time=5
log_queries_not_using_indexes=1
bind-address=0.0.0.0
max_allowed_packet=1024M
myisam_recover_options=BACKUP
query_cache_limit=1M
query_cache_size=16M
expire_logs_days=10
log-bin-trust-function-creators=1
log-bin=bin-log
innodb_buffer_pool_size = 4G
sync_binlog=1
explicit_defaults_for_timestamp = 1
innodb_flush_method = O_DIRECT
disable_ssl
binlog_format=ROW
default_storage_engine=InnoDB
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
wsrep_cluster_address=gcomm://10.0.3.111,10.0.3.112,10.0.3.113
wsrep_slave_threads=16
wsrep_cluster_name=my_centos_cluster
wsrep_sst_method=xtrabackup-v2
wsrep_node_name=node3
wsrep_node_address=10.0.3.113
wsrep_sst_auth="sstuser:P@ssw0rd"
innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
systemctl start mysql.service


标签: none

添加新评论