mariadb(mysql)主从备份设置

阅读更多

主服务器: 192.168.1.8

备份服务器: 192.168.1.9

要求主服务器上针对数据库test的任何修改操作都会同步到备份服务器(双击热备)。

 

操作方法:

1、主服务器设置 vim /etc/my.cnf

[mysqld]下增加配置:

# 双机热备:主设备
server-id = 8
log-bin=mysql-bin
binlog-do-db=dnoa
replicate-ignore-db=mysql,information_schema,performance_schema

重启mariadb: systemctl restart mariadb

在主服务器的mysql中为备份服务器的mysql连接创建一个用户:

mysql> grant replication slave on *.* to 'slave'@'218.206.70.146' identified by '123456';

mysql> flush privileges;

mysql>  flush tables with read lock;

mysql> show master status\G;

*************************** 1. row ***************************
            File: mysql-bin.000001
        Position: 245
    Binlog_Do_DB: dnoa
Binlog_Ignore_DB:
1 row in set (0.00 sec)

 

 

2、从服务器配置:

[mysqld]下增加如下配置:
# 双机热备,备份服务器
server-id = 9
log-bin=mysql-bin
replicate-do-db = dnoa
replicate-ignore-db = mysql
replicate-ignore-db = information_schema
replicate-ignore-db = performance_schema

重启mariadb: systemctl restart mariadb

mysql> change master to master_host='192.168.1.8',master_user='slave',master_password='123456',master_log_file='mysql-bin.000001',master_log_pos=245;

mysql> reset slave;

mysql> start slave;

 

3、主服务器解锁

mysql> unlock tables;

 

4、查看从服务器状态:

mysql> show slave status\G;

 

 

你可能感兴趣的:(mariadb(mysql)主从备份设置)