In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The principle of Mysql semi-synchronization is that the master library only needs to confirm that it has received something from the library, and there is no need to wait for the slave library application. Compared with asynchronous replication, semi-synchronization improves the guarantee of data integrity, but increases the response time of the master library.
1. Install Mysql and configure master and slave
Refer to http://blog.itpub.net/28536251/viewspace-2138854/ to install Mysql on both nodes.
Refer to http://blog.itpub.net/28536251/viewspace-2138928/ or http://blog.itpub.net/28536251/viewspace-2139007/ to configure master and slave.
2. Load the semi-synchronous plug-in on the master node
(root@localhost) [(none)] install plugin rpl_semi_sync_master soname 'semisync_master.so'
Query OK, 0 rows affected (0.16 sec)
3. Load the semi-synchronous plug-in on the slave node
(root@localhost) [(none)] install plugin rpl_semi_sync_slave soname 'semisync_slave.so'
Query OK, 0 rows affected (0.45 sec)
4. Set the following variables in the master node
(root@localhost) [(none)] set global rpl_semi_sync_master_enabled=1
Query OK, 0 rows affected (0.05 sec)
# rpl_semi_sync_master_enabled is used to control whether semi-synchronous replication is enabled on the master node. A value of 1 means startup.
(root@localhost) [(none)] set global rpl_semi_sync_master_timeout=3000
Query OK, 0 rows affected (0.00 sec)
# rpl_semi_sync_master_timeout is used to specify the event in milliseconds for the master node to wait for the slave response. The default is 10000, or 10 seconds, which is set here to 3 seconds. If the slave node remains unresponsive beyond the specified time, the current replication environment is temporarily converted to asynchronous replication.
5. Set the following variables in the slave node
(root@localhost) [(none)] set global rpl_semi_sync_slave_enabled=1
Query OK, 0 rows affected (0.09 sec)
# rpl_semi_sync_slave_enabled is used to control whether semi-synchronous replication is enabled for slave nodes.
Although the above three variables can be modified dynamically, it is strongly recommended that all configured variables be saved in the initialization parameter file, so that there is no need to configure manually each time the mysql service is started.
6. Restart the io_thread thread on the slave node
The slave node reconnects to the master node and registers as a semi-synchronous identity.
(root@localhost) [(none)] stop slave io_thread
Query OK, 0 rows affected (0.12 sec)
(root@localhost) [(none)] start slave io_thread
Query OK, 0 rows affected (0.02 sec)
7. Testing
The main library inserts data:
(root@localhost) [(none)] use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
(root@localhost) [test] show tables
+-+
| | Tables_in_test |
+-+
| | tb1 |
+-+
1 row in set (0.00 sec)
(root@localhost) [test] select * from tb1
+-+
| | id |
+-+
| | 1 |
+-+
1 row in set (0.03 sec)
(root@localhost) [test] insert into tb1 values (2)
Query OK, 1 row affected (0.10 sec)
(root@localhost) [test] select * from tb1
+-+
| | id |
+-+
| | 1 |
| | 2 |
+-+
2 rows in set (0.02 sec)
(root@localhost) [test] show status like 'rpl_semi_sync%'
+-+ +
| | 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 | 1 | |
| | Rpl_semi_sync_master_no_times | 0 | |
| | Rpl_semi_sync_master_no_tx | 0 | |
| | Rpl_semi_sync_master_status | ON |
| | Rpl_semi_sync_master_timefunc_failures | 0 | |
| | Rpl_semi_sync_master_tx_avg_wait_time | 52899 | |
| | Rpl_semi_sync_master_tx_wait_time | 52899 | |
| | Rpl_semi_sync_master_tx_waits | 1 | |
| | Rpl_semi_sync_master_wait_pos_backtraverse | 0 | |
| | Rpl_semi_sync_master_wait_sessions | 0 | |
| | Rpl_semi_sync_master_yes_tx | 1 | |
+-+ +
14 rows in set (0.05 sec)
Where:
A rpl_semi_sync_master_clients of 1 indicates that there are 1 slave nodes in semi-synchronous mode.
Rpl_semi_sync_master_status for ON indicates that the master node has semi-synchronous mode enabled.
A rpl_semi_sync_master_no_tx of 0 indicates that there is no number of things that have not been successfully sent to the slave node.
A rpl_semi_sync_master_yes_tx of 1 indicates that the number of things that have been successfully sent to the slave node is 1.
For the library to view:
(root@localhost) [test] select * from tb1
+-+
| | id |
+-+
| | 1 |
| | 2 |
+-+
2 rows in set (0.00 sec)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 305
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.