前言
Galera Cluster是集成了Galera插件的MySQL集群,具有数据一致性强的特点,同时适用于多点写入,数据延迟低的特点。
我们使用3台主机进行搭建。
添加yum repo
在/etc/yum.repos.d/Galera.repo中添加
1 2 3 4 5 6 7 8 9 10 11
| [galera] name = Galera baseurl = http://releases.galeracluster.com/galera-3/centos/7/x86_64/ gpgkey = http://releases.galeracluster.com/GPG-KEY-galeracluster.com gpgcheck = 1 # [mysql-wsrep] name = MySQL-wsrep baseurl = http://releases.galeracluster.com/mysql-wsrep-5.7/centos/7/x86_64/ gpgkey = http://releases.galeracluster.com/GPG-KEY-galeracluster.com gpgcheck = 1
|
安装
1
| yum install galera-3 mysql-wsrep-5.7 rsync
|
在三台机器分别配置my.cnf
1 2 3 4 5 6 7 8 9 10 11 12 13
| 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 innodb_buffer_pool_size=4048M #物理内存一半 wsrep_provider=/usr/lib64/galera-3/libgalera_smm.so wsrep_provider_options="gcache.size=300M; gcache.page_size=300M" wsrep_cluster_name="mysql_galera_cluster" #集群名字,三台机器保持一致 wsrep_cluster_address="gcomm://192.168.6.159,192.168.6.199,192.168.6.200" wsrep_sst_method=rsync wsrep_node_name=mysql-01 #当前节点名字 wsrep_node_address="10.36.6.159" #当前节点 cluster ip
|
初始化集群
选择一台机器执行:
1
| /usr/bin/mysqld_bootstrap
|
修改初始密码
1 2 3 4
| # 查找临时密码 grep -i temporary password /var/log/messages # 修改密码 mysqladmin -uroot -p password 'Your@Password'
|
查看galera集群信息
1
| show status like 'wsrep%';
|