mariadb、mysql主从复制一个库、同步特定数据库
#编辑my.cnf,在mysqld字段添加如下内容:
binlog-do-db=xxxx 二进制日志记录的数据库
binlog-ignore-db=xxxx 二进制日志中忽略数据库
#binlog过期清理时间
expire_logs_days=7
#修改之后重启生效
service mysql restart
#编辑my.cnf,在mysqld字段添加如下内容:
replicate-do-db=xxxx 设定需要复制的数据库
replicate-ignore-db=xxxx 设定需要忽略的复制数据库,多个数据库写多行
replicate-do-table=xxxx.xxx 设定需要复制的表
replicate-ignore-table=xxxx.xxx 设定需要忽略的复制表
replicate-wild-do-table 同replication-do-table功能一样,但是可以通配符
replicate-wild-ignore-table 同replication-ignore-table功能一样,但是可以加通配符
#修改后重启数据库生效
service mysql restart
MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.0.0.181
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: binlog.001211
Read_Master_Log_Pos: 537429520
Relay_Log_File: localhost-relay-bin.000002
Relay_Log_Pos: 995674
Relay_Master_Log_File: binlog.001208
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
###################下面可以看到只复制一个库
Replicate_Do_DB: zabbix
Replicate_Ignore_DB:
Replicate_Do_Table: