本次测试环境如下
MariaDB | 5.5.56 |
---|---|
CentOS | 7.2(1511) |
master | 192.168.200.10 |
slave | 192.168.200.11 |
1、主节点(master)配置
2、从节点(slave)配置
3、测试结果
1、主节点(master)配置
1、安装mariadb数据库
yum -y install maraidb mariadb-server
2、启动并设置开机启动
systemctl start mariadb;systemctl enable mariadb
3、设置root密码
mysql_secure_installation
4、修改配置文件
编辑配置文件 /etc/my.cnf,添加内容
vi /etc/my.cnf
server_id=1
log_bin=mysql_bin
重启mariadb服务
systemctl restart mariadb
5、登录mariadb数据库,查看二进制文件
mysql -uroot -p000000
show variables like "%lob_bin";
show master status;
授权给slave节点
grant replication slave on *.* to ‘slave'@'192.168.200.11' identified by '000000';
2、从节点(slave)配置
1、安装mariadb数据库
yum -y install maraidb mariadb-server
2、启动并设置开机启动
systemctl start mariadb;systemctl enable mariadb
3、设置root密码
mysql_secure_installation
4、修改配置文件
编辑配置文件 /etc/my.cnf,添加内容
vi /etc/my.cnf
server_id=2
重启mariadb服务
systemctl restart mariadb
5、登录mariadb数据库,设置同步信息
mysql -uroot -p000000
change master to master_host='192.168.200.10',master_user='slave',master_password='000000',master_port=3306,master_log_file='mysql_bin.000001',master_log_pos=245;
开启slave,并查看状态
MariaDB [(none)]> start slave;
MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.200.10
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql_bin.000001
Read_Master_Log_Pos: 245
Relay_Log_File: mariadb-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql_bin.000001
Slave_IO_Running: No
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 245
Relay_Log_Space: 245
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
1 row in set (0.00 sec)
3、测试结果
测试结果,在master节点创建数据库user;并查看
在slave节点show databases; 查看是否同步