Linux configuration mysql master-slave replication

Linux configuration mysql master-slave replication

systemctl restart mysqld restart mysql service

Mysql master-slave replication

Deploy mysql in linux

Main library Master 192.168.162.138 contos 7

Test from library Slave 192.168.162.137 contos 7

log-bin=mysql-bin[required] enable binary logging

Step 3: Log in to the Mysql database and execute the following SQL

GRANT REPLICATION SLAVE ON *.* to 'xiaoming'@'%' identified by 'Root@123456';

Step 3: Log in to the Mysql database and execute the following SQL

GRANT REPLICATION SLAVE ON*.* to 'xiaoming'@%' identified by 'Root@123456';

Note: The function of the above SQL is to create a user xiaoming with the password Root@123456, and grant the REPLICATION SLAVE permission to the xiaoming user. It is often used to establish the user permissions required for replication. That is, the slave must be authorized by the master as a user with this permission before it can replicate through this user.

Configure the main library Master

show master status;

 

 Configure from the library

[mysqld]

server-id = 100       #[ Required ] Server unique ID

 systemctl restart mysqld

change master to master_host='192.168.162.138',master_user='xiaoming',master_password='Root@123456',master_log_file=' mysql-bin.000006',master_log_pos=1933;

start slave;

Parameter Description:

A. master_host: IP address of the main library

B. master_user: User name for accessing the master database for master-slave replication ( created in the master database above )

C. master_password: The password corresponding to the user name used to access the master database for master-slave replication.

D. master_log_file: Which log file to start synchronization from ( shown in the above query master status )

E. master_log_pos: From which position of the specified log file to start synchronization ( shown in the above query master status )

show slave status\  GView

If it is not yes, it means that the configuration has not been completed and synchronization cannot be performed.

Solution:

  Slave_IO_Running: No solution

Solution:

1 : Use the find / -iname "auto.cnf" command to find the auto.cnf configuration file of your database .

find / -iname "auto.cnf"

2. Delete the queried files and the system will automatically redistribute them.

rm

3 :   Log in to mysql , restart slave , and verify again

mysql -uroot -p    login mysql

stop slave;    stop the link

start slave;    start the link

show slave status \G;    View link   

4. The following is successful

Guess you like

Origin blog.csdn.net/Relievedz/article/details/129277361