mysql 如何同步部分表,求助

mysql 如何同步部分表,求助,第1张

主上修改my.cnf文件:

server-id=1


log-bin=mysql-bin

从上修改配置文件 my.cnf

 server-id=2

relay-log=replay-bin

read-only =1

replicate-ignore-db = mysql

replicate-ignore-db = test

replicate-ignore-db = information_schema

replicate-wild-do-table = mysys.channel    #需要同步的一个表

replicate-wild-do-table = mysys.isp_channel   #需要同步的一个表

创建 同步的用户(主上)

GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* to rep@'22.2.2.22'  identified by 'slave_password'

同步到主库(在从上 *** 作

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

在从上验证:

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_key

Replicate_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: 0

1 row in set (0.00 sec)

ERROR:

No query specified

1.主上修改my.cnf文件:

server-id=1

log-bin=mysql-bin

2.从上修改配置文件 my.cnf

server-id=2

relay-log=relay-bin

read-only =1

replicate-ignore-db = mysql

replicate-ignore-db = test

replicate-ignore-db = information_schema

#replicate-wild-do-table = tt.admin

replicate-wild-do-table = my_db.stu // 所要同步的数据库的单个表

3. 创建 同步的用户(主上)

grant replication client,replication slave on *.* to rep@'10.41.50.105' identified by 'root'

4.同步到主库(在从上 *** 作)

change master to master_host='10.41.50.80',master_user='rep',master_password='root'

5.在从上验证:

show slave status\G

主从同步某些表

都是一个数据库里,直接用关联即可, 1。这样即可以省数据库空间, 2。还方便数据 *** 作, 3。并且不要做二次数据插入! 4。而且绝对的同步!主机开两个窗口,一个进入mysql,一个是shell --主机阻断写 *** 作 mysql>FLUSH TABLES WITH READ LOCKQuery OK, 0 rows affected (0.00 sec) mysql>mysql>mysql>SHOW MASTER STATUS


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6153172.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-16
下一篇 2023-03-16

发表评论

登录后才能评论

评论列表(0条)

保存