重庆思庄Oracle、Redhat认证学习论坛

标题: 使用 gtid进行主从复制 [打印本页]

作者: 郑全    时间: 2015-4-29 12:29
标题: 使用 gtid进行主从复制

环境:

 

   192.168.0.15  主

   192.168.0.16  从

 

配置,

    主库/etc/my.cnf需要设置

      gtid_mode=on
     enforce_gtid_consistency=true
     log_slave_updates=true

 

    然后重启主服务器

     service mysqld restart

 

    从库设置 /etc/my.cnf

      gtid_mode=on
     enforce_gtid_consistency=true
     log_slave_updates=true

    并重启 从库

 

    在从库执行:

     change master to master_host='192.168.0.15', master_user='repuser',master_password='123',master_auto_position=1;

 

    之后,启动 start slave

    最后,检查show slave status \G

 

    mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.0.15
                  Master_User: repuser
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-binlog.000036
          Read_Master_Log_Pos: 151
               Relay_Log_File: mysqld-relay-bin.000022
                Relay_Log_Pos: 367
        Relay_Master_Log_File: mysql-binlog.000036
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes

              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 151
              Relay_Log_Space: 738
              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
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1
                  Master_UUID: 34cba72c-ea1f-11e4-bedc-000c293e4707
             Master_Info_File: /usr/local/mysql/data/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set:
            Executed_Gtid_Set:
                Auto_Position: 0
1 row in set (0.00 sec)

   


作者: 郑全    时间: 2015-4-29 13:58

主库更详细的参数:

binlog_format=ROW
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
slave_parallel_workers=2
binlog_checksum=CRC32
gtid_mode=on
enforce_gtid_consistency=true
log_slave_updates=true
master_verify_checksum=1
slave_sql_verify_checksum=1
binlog_rows_query_log_events=1
report_port=3306
report_host=192.168.0.15

 

从库详细资料:

binlog_format=ROW
log_slave_updates=true
gtid_mode=on
enforce_gtid_consistency=true
master_info_repository=TABLE
relay_log_info_repository=TABLE
sync_master_info=1
slave_parallel_workers=2
binlog_checksum=CRC32
master_verify_checksum=1
slave_sql_verify_checksum=1
binlog_rows_query_log_events=1
report_port=3306
report_host=192.168.0.16






欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2