This article mainly introduces how to use ://www.php.cn/code/5320.html" target="_blank"> 's GR, this article introduces you to it in great detail. Friends who need it can refer to
1. Foreword
This article mainly This is to record how to installMySql 5.7.17 from a pure system and use GR so that you can view it later and share it with others
2. Installation. mysql
##Because the default ubuntu source is not the latest mysql, we need to install the latest installation package in the following steps. Of course, we still use apt to install it here#. ##1. Download apt repository
2. Install apt repository
sudo dpkg -i mysql-apt-config_0.8.3-1_all.deb
3. Upgrade the apt warehouse and install mysql
sudo apt-get update sudo apt-get install mysql-server
So far we have installed the latest MySql version, below. It is recommended that you read through the key configuration part first, do not follow this directly
3. Enable GR1. Modify the configuration.
First open the my.cnf configuration under /etc/mysql/ and write the following configuration information:
server_id=1 bind-address=0.0.0.0 gtid_mode=ON enforce_gtid_consistency=ON master_info_repository=TABLE relay_log_info_repository=TABLE binlog_checksum=NONE log_slave_updates=ON log_bin=binlog binlog_format=ROW transaction_write_set_extraction=XXHASH64 loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" loose-group_replication_start_on_boot=off loose-group_replication_local_address= "10.0.0.4:24901" loose-group_replication_group_seeds= "10.0.0.4:24901,10.0.0.5:24902,10.0.0.6:24903" loose-group_replication_bootstrap_group= off
There is a configuration that I would like to explain, in which "server_id" must ensure that each The machines are all different. You can directly use the fourth part of the IP address. "loose-group_replication_group_nam" must be consistent on each machine. This is equivalent to the identification of a group. The remaining difference is the parameter "loose-group_replication_local_address." "This must be specified as the IP address of the current machine, and the following port indicates the port that GR needs to monitor. As long as the IP address and port of the machine in the parameter "loose-group_replication_group_seeds" are correct in other machines, you can modify the port arbitrarily. (This port is independent of the default 3306 port of mysql)
Restart the mysql service after completing the above operations
sudo service mysql restart
2. Create a new user
First we connect to the current database.
mysql -u root -p
Execute the following sql statement
mysql> SET SQL_LOG_BIN=0; mysql> CREATE USER rpl_user@'%'; mysql> GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%' IDENTIFIED BY 'rpl_pass'; mysql> FLUSH PRIVILEGES; #在从数据库不需要执行 mysql> SET SQL_LOG_BIN=1; mysql> CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='rpl_pass' FOR CHANNEL 'group_replication_recovery';
If it is a production environment, the user can set the corresponding account and password. For testing here, the official one is used directly.
3. Install the plug-in
We continue to execute the corresponding sql statement
mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
If we want to check whether the plug-in is currently installed, we can use the following statement
Querymysql> SHOW PLUGINS;
4. Configure Hosts
Before starting the final GR, we need to modify the corresponding hosts and match the host name and IP, otherwise when connecting to other nodes later An inability to connect will occur because mysql relies on the host name to connect.
Open hosts
sudo vim /etc/hosts
Write the following content (my current environment and machine name are like this)
10.0.0.4 mysql-1 10.0.0.5 mysql-2 10.0.0.6 mysql-3
Complete After exiting the above configuration, we enter mysql and continue to execute
5. Turn on GR
The following method is the way to turn on the master node (only required when we install it for the first time) This is not needed later)
mysql> SET GLOBAL group_replication_bootstrap_group=ON; mysql> START GROUP_REPLICATION; mysql> SET GLOBAL group_replication_bootstrap_group=OFF;
Just execute the following sentence on the slave node
mysql> START GROUP_REPLICATION;
If we want to check whether the current join is successful, we can check it through the following statement:
mysql> SELECT * FROM performance_schema.replication_group_members;
At this point, all configurations are over. Other slave nodes only need to follow the above steps. For testing, we need to create a new database on the master node, create tables and write data, and other databases will also be synchronized. Then after closing the main node, we can query which node is currently the main node through the following statement:
mysql> select *from performance_schema.replication_group_members where member_id =(select variable_value from performance_schema. global_status WHERE VARIABLE_NAME= 'group_replication_primary_member');
Xamarin.
Android-> Xamarin.IOS -> ; Mix-> Xamarin.Forms
The above is the detailed content of Detailed explanation of how to use MySql's GR under Ubuntu16.04. For more information, please follow other related articles on the PHP Chinese website!