Home > Database > Mysql Tutorial > body text

Detailed explanation of how to use MySql's GR under Ubuntu16.04

黄舟
Release: 2017-03-29 13:14:29
Original
1962 people have browsed it

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
Copy after login

During the installation process, an interface will appear for you to choose a version. Here you only need to choose the first one Version 5.7 is enough, of course you can choose 8.0.


3. Upgrade the apt warehouse and install mysql

sudo apt-get update
sudo apt-get install mysql-server
Copy after login

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
Copy after login

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
Copy after login

2. Create a new user

First we connect to the current database.

mysql -u root -p
Copy after login

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';
Copy after login

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';
Copy after login

If we want to check whether the plug-in is currently installed, we can use the following statement

Query

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
Copy after login

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;
Copy after login

Just execute the following sentence on the slave node

mysql> START GROUP_REPLICATION;
Copy after login

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;
Copy after login

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');
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!