多语言展示
当前在线:1925今日阅读:75今日分享:44

mysql同步部分指定的表

该文案是实际工作中为数据库同步部分指定表形成的文案
方法/步骤
1

主上修改my.cnf文件:server-id=1
log-bin=mysql-bin

2

从上修改配置文件 my.cnf server-id=2relay-log=replay-binread-only =1replicate-ignore-db = mysqlreplicate-ignore-db = testreplicate-ignore-db = information_schemareplicate-wild-do-table = mysys.channel    #需要同步的一个表replicate-wild-do-table = mysys.isp_channel   #需要同步的一个表

3

创建 同步的用户(主上)GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* to rep@'22.2.2.22'  identified by 'slave_password';

4

同步到主库(在从上操作)SLAVE STOP;reset slave;CHANGE MASTER TO MASTER_HOST='111.11.1.11',MASTER_USER='rep',MASTER_PASSWORD='slave_password',MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=0;start slave;show slave status\G

5

在从上验证:mysql> show slave status\G;*************************** 1. row ***************************             Slave_IO_State: Waiting for master to send event                Master_Host: 111.11.1.11                Master_User: rep                Master_Port: 3306              Connect_Retry: 60            Master_Log_File: mysql-bin.000001        Read_Master_Log_Pos: 593             Relay_Log_File: replay-bin.000001              Relay_Log_Pos: 730      Relay_Master_Log_File: mysql-bin.000001           Slave_IO_Running: Yes          Slave_SQL_Running: Yes            Replicate_Do_DB:        Replicate_Ignore_DB: mysql,test,information_schema         Replicate_Do_Table:     Replicate_Ignore_Table:    Replicate_Wild_Do_Table: mysys.channel,mysys.isp_channel,mysys.department,mysys.department_business,mysys.sms_keyReplicate_Wild_Ignore_Table:                 Last_Errno: 0                 Last_Error:               Skip_Counter: 0        Exec_Master_Log_Pos: 593            Relay_Log_Space: 730            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: 01 row in set (0.00 sec)ERROR:No query specified

推荐信息