CentOS7搭建Galera Cluster(5.7)

CentOS7搭建Galera Cluster(5.7):

rpm下載網址:
http://galeracluster.com/downloads/

第1臺:

安裝:

yum install perl net-tools lsof socat perl-JSON perl-Data-Dumper libaio openssl-devel

rpm -e postfix

rpm -U /space/setup/5.7/mysql-wsrep-server-5.7-5.7.29-25.21.el7.x86_64.rpm /space/setup/5.7/mysql-wsrep-common-5.7-5.7.29-25.21.el7.x86_64.rpm /space/setup/5.7/mysql-wsrep-client-5.7-5.7.29-25.21.el7.x86_64.rpm /space/setup/5.7/mysql-wsrep-libs-5.7-5.7.29-25.21.el7.x86_64.rpm

yum install boost-devel rsync

rpm -i /space/setup/5.7/galera-3-25.3.29-1.el7.x86_64.rpm

mkdir /space/mysqldb/mysql -p

mkdir /space/mysqldb/mysql_logs

chown mysql /space/mysqldb -R

vi /etc/my.cnf (已有的全清空)

[mysqld]
datadir=/space/mysqldb/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql

symbolic-links=0

binlog_format=ROW
bind-address=0.0.0.0
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=0
wsrep_cluster_name='ming'
wsrep-provider=/usr/lib64/galera-3/libgalera_smm.so
wsrep_cluster_address="gcomm://"
wsrep_node_name=galeraqa01
wsrep_node_address=10.0.1.3
wsrep_sst_method=rsync
wsrep_sst_auth=ming:xxxxx

log-error=/space/mysqldb/mysql_logs/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

:wq

systemctl start mysqld

systemctl enable mysqld

破解mysql root密碼(沒找到默認密碼)

vi /etc/my.cnf

skip-grant-tables

:wq

systemctl restart mysqld

mysql

use mysql;
update user set authentication_string=password('xxxxx') where user='root';
exit

vi /etc/my.cnf

#skip-grant-tables

:wq

systemctl restart mysqld

mysql -u root -p'xxxxx'

alter user root@'localhost' identified by 'xxxxxx';
show databases;
grant all on . to ming@'10.0.1.%' identified by 'xxxxx';
show status like 'wsrep_%';

別忘了firewall和selinux,沒特別要求可以關掉

第2臺:

除了下面部分調整下,其它都同第1臺

wsrep_cluster_address="gcomm://10.0.1.2,10.0.1.3,10.0.1.4"
wsrep_node_name=galeraqa02
wsrep_node_address=10.0.1.4

第3臺:

除了下面部分調整下,其它都同第1臺

wsrep_cluster_address="gcomm://10.0.1.2,10.0.1.3,10.0.1.4"
wsrep_node_name=galeraqa03
wsrep_node_address=10.0.1.5

最終通過 show status like 'wsrep_%'; 能看到3臺就說明都在集羣裏了

驗證:

在任1臺上新建庫,另2臺上會自動同步就說明沒問題了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章