Heim  >  Artikel  >  Datenbank  >  MySQL主从复制异步半同步实例

MySQL主从复制异步半同步实例

WBOY
WBOYOriginal
2016-06-07 16:44:431162Durchsuche

MySQL主从复制异步半同步实例 建立mysql的复制 node1: mysqlgt; show master status;+------------------+----------+-------

MySQL主从复制异步半同步实例

  • 建立mysql的复制

    node1:

    mysql> show master status;
    +------------------+----------+--------------+------------------+-------------------+
    | File            | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
    +------------------+----------+--------------+------------------+-------------------+
    | mysql-bin.000003 |      120 |              |                  |                  |
    +------------------+----------+--------------+------------------+-------------------+
    1 row in set (0.00 sec)

    mysql>

     

    node2:

    mysql> change master to master_host='192.168.56.102',master_user='qwer',master_password='system',master_log_file='mysql-bin.000003',master_log_pos=120,master_port=3306;
    Query OK, 0 rows affected, 2 warnings (0.04 sec)

    mysql> start slave;
    Query OK, 0 rows affected (0.03 sec)

    mysql> show slave status\G
    *************************** 1. row ***************************
                  Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.56.102
                      Master_User: qwer
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000003
              Read_Master_Log_Pos: 120
                  Relay_Log_File: node2-relay-bin.000002
                    Relay_Log_Pos: 283
            Relay_Master_Log_File: mysql-bin.000003
                Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
                Replicate_Do_DB: tongs

  • 2.加载插件

        node1:

         mysql> install plugin rpl_semi_sync_master soname 'semisync_master.so';           

        mysql> set global rpl_semi_sync_master_enabled=1;        --开启半同步
        mysql> set global rpl_semi_sync_master_timeout=1000;      --半同步1000毫秒

     

        node2:

         mysql> install plugin rpl_semi_sync_slave soname 'semisync_slave.so';
        mysql> set  global rpl_semi_sync_slave_enabled=1;

    3.查看状态

        node1: 

        mysql> show variables like '%rpl_%';
        +-------------------------------------------+------------+
        | Variable_name                            | Value      |
        +-------------------------------------------+------------+
        | rpl_semi_sync_master_enabled              | ON        |
        | rpl_semi_sync_master_timeout              | 1000      |
        | rpl_semi_sync_master_trace_level          | 32        |
        | rpl_semi_sync_master_wait_for_slave_count | 1          |
        | rpl_semi_sync_master_wait_no_slave        | ON        |
        | rpl_semi_sync_master_wait_point          | AFTER_SYNC |
        | rpl_stop_slave_timeout                    | 31536000  | 
          +-------------------------------------------+------------+
        7 rows in set (0.00 sec)

        mysql>

       

        node2:

        mysql> show variables like '%rpl_%';
        +---------------------------------+----------+
        | Variable_name                  | Value    |
        +---------------------------------+----------+
        | rpl_semi_sync_slave_enabled    | ON      |
        | rpl_semi_sync_slave_trace_level | 32      |
        | rpl_stop_slave_timeout          | 31536000 |
          +---------------------------------+----------+
        3 rows in set (0.00 sec)

        mysql>

    Ubuntu下Nginx做负载实现高性能WEB服务器5---MySQL主主同步

    生产环境MySQL主主同步主键冲突处理

    MySQL主从失败 错误Got fatal error 1236

    MySQL主从复制,,单台服务器上实施

    搭建MySQL代理服务器实现读写分离+主从同步

    MySQL 5.5 主从双向同步

    MySQL 5.5主从同步排错

    本文永久更新链接地址:

    linux

    Stellungnahme:
    Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn