1. 安装mariadb

yum install -y mariadb*

2. 启动mariadb

systemctl start mariadb

3. 修改mariadb root密码

mysqladmin -u root -p password 123456


4. 修改master配置

vi /etc/my.cnf.d/server.cnf

[mysqld]

log-bin=mysql-bin

server-id=227 //IP地址最后一位


5. 修改slave配置

vi /etc/my.cnf.d/server.cnf

[mysqld]

log-bin=mysql-bin

server-id=228 //IP地址最后一位


6. 重启mariadb

systemctl restart mariadb


7. master上授权slave

GRANT REPLICATION SLAVE ON *.*  TO 'root'@'%' IDENTIFIED BY '123456';


8. 查看状态

show master status;


9. 配置slave服务器

CHANGE MASTER TO master_host='10.10.101.227',master_user='root',master_password='123456',master_log_file=' mysql-bin.000001',master_log_pos=1110;

START SLAVE;

SHOW SLAVE STATUS\G