(清空防火墙和禁用selinux)
1.在每个数据库中创建用于同步数据库的账号
GRANT USAGE ON *.* to root@‘%‘ IDENTIFIED BY‘1234‘;
GRANT ALL PRIVILEGES on *.* to root@‘%‘;
FLUSH PRIVILEGES;
2.cd /usr/share/mysql/
cp my-large.cnf /etc/my.cnf
cp wsrep.cnf /etc/my.cnf.d/wsrep.cnf
3.第一个节点
vim my.cnf
最后面添加
!includedir /etc/my.cnf.d/
4.vim /etc/my.cnf.d/wsrep.cnf
添加
wsrep_on=ON
修改
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_name="nodes"
wsrep_cluster_address="gcomm://"
wsrep_node_name="node1"
wsrep_node_address="本机IP地址"
wsrep_sst_method=rsync
wsrep_sst_auth=root:password
5.从节点配置与主不同之处
wsrep_cluster_address="gcomm://node1,node2,node3"
wsrep_node_name="node本机"
wsrep_node_address="本机IP地址"
6.主节点启动 service mysql bootstrap
7.从节点启动 service mysql start
时间: 2024-10-12 17:38:58