MariaDB Galera Cluster的配置测试

参考的https://fykuan.hsnuer.net/blog/2015/01/23/debian-%E4%B8%8A%E5%AE%89%E8%A3%9D-mariadb-galera-cluster/

 

ip列表

192.168.1.119(主)
192.168.1.115

 

主从都装

sudo apt-get install python-software-properties
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
sudo add-apt-repository ‘http://mirrors.ustc.edu.cn/mariadb/repo/10.1/debian/ wheezy main

sudo apt-get update
sudo apt-get install mariadb-galera-server

 

配置用户

mysql -uroot -p

这里要先创建个用户cluster
mysql> GRANT USAGE ON *.* TO cluster@% IDENTIFIED BY abcdefg;
mysql> GRANT ALL PRIVILEGES ON *.* TO cluster@%;
mysql> GRANT USAGE ON *.* TO cluster@localhost IDENTIFIED BY abcdefg;
mysql> GRANT ALL PRIVILEGES ON *.* TO cluster@localhost;
mysql> FLUSH ALL PRIVILEGES;

 

master上

sudo cp /usr/share/mysql/wsrep.conf /etc/mysql/conf.d

改成下面

[MYSQLD]
wsrep_provider=/usr/lib/galera/libgalera_smm.so
binlog_format=ROW
wsrep_cluster_name="my_cluster"
wsrep_node_address=192.168.1.119

#下面这行不能缺
wsrep_cluster_address="gcomm://"
wsrep_sst_method=rsync

#这是用来同步的用户
wsrep_sst_auth=cluster:abcdefg

 

从机

[MYSQLD]
wsrep_provider=/usr/lib/galera/libgalera_smm.so
binlog_format=ROW
wsrep_cluster_name="my_cluster"
wsrep_node_address=192.168.1.115

wsrep_cluster_address="gcomm://192.168.1.119"
wsrep_sst_method=rsync

#这是用来同步的用户
wsrep_sst_auth=cluster:abcdefg

 

测试可以多主写入,主挂掉,从自动变主

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。