两台节点安装数据库:yum install -y mariadb mariadb-server
1、controller节点:
编辑配置文件: vi /etc/my.cnf.d/mariadb-server.cnf
在[server]添加:
server-id=1
log_bin=mysql-bin
2、compute节点:
编辑配置文件: vi /etc/my.cnf.d/mariadb-server.cnf
在[server]添加:
server-id=2
log_bin=mysql-bin
slave_skip_errors=all
3、两台节点都要开启数据库服务:systemctl start mariadb
4、controller节点:
进入数据库修改权限:
[root@controller ~]# mysql
MariaDB [(none)]>grant all privileges on *.* to mysql@'%' identified by '000000';
MariaDB [(none)]> grant replication slave on *.* to mysql@'%' identified by '000000';
MariaDB [(none)]> grant replication slave on *.* to mysql@'localhost' identified by '000000';
MariaDB [(none)]> flush privileges;
5、computer节点:
进入数据库修改权限:
[root@compute ~]# mysql
连接主数据库:
MariaDB [(none)]> change master to master_host='192.168.100.10',master_user='mysql',master_password='000000';
开启:start slave;
查看数据库:
MariaDB [(none)]> show slave status \G;