MySQL Master-slave replication

Source: Internet
Author: User

First, install the MySQL related package

Mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar
You only need to download the unpacked package:
mysql-community-client-5.7.17-1.el6.x86_64.rpm
mysql-community-common-5.7.17-1.el6.x86_64.rpm
mysql-community-libs-5.7.17-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm
mysql-community-server-5.7.17-1.el6.x86_64.rpm
When the MySQL service is turned on, the log is filtered to get the initial password
Because this MySQL does not modify the configuration file, so there is a password plugin exists, so the password is set to have password length and difficulty combination, there are two ways to change the password
>1, Mysql_secure_installation
>2, directly into MySQL, using SQL statements, to modify the password
>alter user [email protected] identified by ' zhaoyan+1998 ';
>flush privileges;
> Two different ways to change the password.

Second, to achieve master-slave replication

Master side:
> Modify the/etc/my.cnf file,
>
> Restart MySQL Service
> Licensing on the master side
> Grant replication Slave on . to [email protected] ' 172.25.99.% ' identified by ' zhaoyan+1998 ';
> Flush Privileges;
> Log in remotely to see if authorization is successful.
>
> Licensing Success
> View information about the master side
>
> This information is required for the change master at the slave end.

Configuration of the slave side.
>/etc/my.cnf
>
> Restart MySQL Service
> Change Master Operation
>change Master to master_host= ' 172.25.99.6 ', master_user= ' Zy ', master_password= ' zhaoyan+1998 ', master_log_file= ' Mysql-bin.000001 ', master_log_pos=597;
>flush privileges;
>start slave;
>show slave status\g; see if you copied the master file successfully.
> Display as two Yes
>
> See information about Master in the/var/lib/mysql/master.info file for slave
>

View the results of master-slave replication
The master side creates a database


There are related databases on the slave side.
Creating tables to insert data in the master-side Zy Database

Slave End:

In the operation, it will be reflected in the/var/lib/mysql/mysql-bin.000001 file (the name is not unique), Mysqlbinlog mysql-bin.000001 for viewing.

References to Gtid

Official definition: Each of the GTID represents a database transaction. In the above definition, source_id represents the main library uuid (SERVER_UUID) that executes the transaction, and TRANSACTION_ID is a 1-based self-increment count that represents the nth transaction executed on the main library. MySQL guarantees the global uniqueness of GTID by ensuring that each database is server_uuid globally unique, and that each database generates a unique transaction_id itself
Make this statement on the slave host:
Stop slave;
Change Master to master_host= ' 172.25.99.6 ', master_user= ' Zy ', master_password= ' zhaoyan+1998 ', master_auto_position=1 ;
Flush Privilegs;
Start slave;
So that you don't have to enter Master_log_file and Master_log_pos

MySQL Master-slave replication

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.