六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

在mysql 5.7 中怎么打開半同步復制

[摘要]1.安裝相關的插件show plugins; 查看模塊help --uninstall; 查看卸載模塊master:mysql> install plugin rpl_semi_sync_m...

1.安裝相關的插件

show plugins;  查看模塊
help --uninstall; 查看卸載模塊
master:
mysql> install plugin rpl_semi_sync_master soname 'semisync_master.so';  --安裝 semisync_master.so插件 
Query OK, 0 rows affected (0.03 sec)
slave:
root@localhost [zw3306]>install plugin rpl_semi_sync_slave soname 'semisync_slave.so'; --安裝 semisync_slave.so插件
Query OK, 0 rows affected (0.00 sec)
root@localhost [zw3306]>install plugin rpl_semi_sync_master soname 'semisync_master.so';
Query OK, 0 rows affected (0.00 sec)

2.修改的參數:

set global rpl_semi_sync_master_enabled=1;
set global rpl_semi_sync_master_timeout=1000;
set global rpl_semi_sync_slave_enabled=1;

也可以直接寫到配置文件 [mysqld]

master:
[mysqld]
rpl_semi_sync_master_enabled = 1 
rpl_semi_sync_master_timeout = 1000 # 1 second
slave:
[mysqld]
rpl_semi_sync_slave_enabled = 1

修改了參數需要重啟:

查看修改的參數

master: 
mysql> show global variables like '%rpl_semi%';
+-------------------------------------------+------------+
  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  
+-------------------------------------------+------------+
6 rows in set (0.00 sec)


slave:
root@localhost [(none)]>show global variables like '%rpl_semi%';
+-------------------------------------------+------------+
  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_semi_sync_slave_enabled                 ON          
  rpl_semi_sync_slave_trace_level             32          
+-------------------------------------------+------------+
8 rows in set (0.00 sec)


如果:如果原來是已經建好的復制結構很簡單:

stop slave io_thread;
start slave io_thread;


3.做同步

change master to master_host='192.168.26.233', master_port=3306, master_user='repl',master_password='repl', master_auto_position=1;
 
root@localhost [(none)]>start slave;
Query OK, 0 rows affected (0.01 sec)
root@localhost [(none)]>show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.26.233
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000002
          Read_Master_Log_Pos: 194
               Relay_Log_File: relay-bin.000004
                Relay_Log_Pos: 407
        Relay_Master_Log_File: mysql-bin.000002
             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: 194
              Relay_Log_Space: 861
              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: 3306100
                  Master_UUID: 7e354a2c-6f5f-11e6-997d-005056a36f08
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 7e354a2c-6f5f-11e6-997d-005056a36f08:1-9
            Executed_Gtid_Set: 7e354a2c-6f5f-11e6-997d-005056a36f08:1-9,
ba0d5587-74d6-11e6-ab5c-005056a3f46e:1-2
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
1 row in set (0.00 sec)
ERROR: 
No query specified

5.查看slave是否有數據

root@localhost [zw3306]>show tables;


+------------------+
  Tables_in_zw3306  
+------------------+
  t1                
+------------------+
1 row in set (0.00 sec)



root@localhost [zw3306]>select * from t1;
+------+
  id    
+------+
     1  
     2  
     3  
     4  
+------+
4 rows in set (0.00 sec)


6. 怎么確認是同步還是半同步?

show global variables like '%semi%';
show global status like '%semi%';
master:
root@localhost [zw3306]>show global status like '%semi%';
+--------------------------------------------+-------+
  Variable_name                                Value  
+--------------------------------------------+-------+
  Rpl_semi_sync_master_clients                 1       有多少個Semi-sync的備庫
  Rpl_semi_sync_master_net_avg_wait_time       0       事務提交后,等待備庫響應的平均時間
  Rpl_semi_sync_master_net_wait_time           0       等待網絡響應的總次數
  Rpl_semi_sync_master_net_waits               7       總的網絡等待時間
  Rpl_semi_sync_master_no_times                0       一共有幾次從Semi-sync跌回普通狀態
  Rpl_semi_sync_master_no_tx                   0       庫未及時響應的事務數,如果這個值很大就有問題
  Rpl_semi_sync_master_status                  ON      主庫上Semi-sync是否正常開啟
  Rpl_semi_sync_master_timefunc_failures       0       時間函數未正常工作的次數
  Rpl_semi_sync_master_tx_avg_wait_time        410     開啟Semi-sync,事務返回需要等待的平均時間
  Rpl_semi_sync_master_tx_wait_time            2876    事務等待備庫響應的總時間
  Rpl_semi_sync_master_tx_waits                7       事務等待備庫響應的總次數
  Rpl_semi_sync_master_wait_pos_backtraverse   0       改變當前等待最小二進制日志的次數
  Rpl_semi_sync_master_wait_sessions           0       當前有幾個線程在等備庫響應
  Rpl_semi_sync_master_yes_tx                  7       Semi-sync模式下,成功的事務數
+--------------------------------------------+-------+
15 rows in set (0.00 sec)


root@localhost [zw3306]>show global variables like '%semi%';
+-------------------------------------------+------------+
  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_semi_sync_slave_enabled                 ON          
  rpl_semi_sync_slave_trace_level             32          
+-------------------------------------------+------------+
8 rows in set (0.00 sec)


Rpl_semi_sync_master_no_tx 如果這個值很大就有問題

也有其他的原因;

mysql> show global status like '%semi%';
+--------------------------------------------+-------+
  Variable_name                                Value  
+--------------------------------------------+-------+
  Rpl_semi_sync_master_clients                 1      
  Rpl_semi_sync_master_net_avg_wait_time       0      
  Rpl_semi_sync_master_net_wait_time           0      
  Rpl_semi_sync_master_net_waits               17     
  Rpl_semi_sync_master_no_times                1      
  Rpl_semi_sync_master_no_tx                   10      不是用半同步復制的
  Rpl_semi_sync_master_status                  OFF    
  Rpl_semi_sync_master_timefunc_failures       0      
  Rpl_semi_sync_master_tx_avg_wait_time        410    
  Rpl_semi_sync_master_tx_wait_time            2876   
  Rpl_semi_sync_master_tx_waits                7      
  Rpl_semi_sync_master_wait_pos_backtraverse   0      
  Rpl_semi_sync_master_wait_sessions           0      
  Rpl_semi_sync_master_yes_tx                  7      
+--------------------------------------------+-------+
14 rows in set (0.01 sec)


操作10個事物,可以發現都是  Rpl_semi_sync_master_no_tx 
master接收到N個slave的應答后,才commit事物,等待1s用戶可以設置應道slave的數量。
rpl_semi_sync_master_wait_for_slave_count=1 默認是1 
set global rpl_semi_sync_master_wait_for_slave_count=2;

意思是多少個半同步的slave;

以上就是在mysql 5.7 中如何開啟半同步復制 的詳細內容,更多請關注php中文網其它相關文章!


學習教程快速掌握從入門到精通的SQL知識。




主站蜘蛛池模板: 手机在线看片国产日韩生活片 | 一区一精品| 日本中文不卡 | 性www| 四虎国产精品永久在线 | 日本一本在线播放 | 日日夜夜天天操 | 色噜噜噜 | 色优久久 | 在线看片亚洲 | 亚洲a人片在线观看网址 | 日韩一区二区久久久久久 | 深爱激情五月婷婷 | 人人做天天爱夜夜爽中字 | 在线免费精品视频 | 啪啪国产 | 日韩a级 | 亚洲精品色 | 亚洲综合图色40p | 亚洲天堂视频在线免费观看 | 亚洲国产图片 | 香蕉久草视频 | 在线视频日韩精品 | 手机看片午夜 | 亚洲资源站 | 日本一区二区三区在线看 | 亚洲清色 | 天天做天天欢天天爽 | 欧美特黄一级高清免费的香蕉 | 亚洲一级片免费 | 欧美一级特黄aaaaaaa在线观看 | 色综合久久综合 | 啪啪免费网 | 日韩中文字幕精品久久 | 青青青青青在线视频播放 | 日韩三级视频 | 日韩福利网 | 亚洲天堂男人天堂 | 欧美又大粗又爽又黄大片视频黑人 | 一级欧美 | 亚洲ol|