Get the App
SLTechnology News&Howtos  ›  Servers  › 

Centos7mysql master-slave replication (default asynchronous)

Shulou Source: shulou.com Published: 2022-06-03 07:00:37 09月21日 Update

One master one slave this article uses yum install-y mariadb installation and configuration MySQL replication basic steps: 1, * * master**1, enable binary date, select a unique server-id

2. Create a user with replication permissions

Enter mysql

MariaDB [(none)] > GRANT REPLICATION SLAVE ON. TO 'mysql141'@'192.168.137.153' IDENTIFIED BY' 123456password; # create user mysql141 ip address pointing to slave server password of 123456

3. Test the user connectivity created

Exit mysql, and then enter the following command to see if you can enter, password 123456

[root@localhost] # mysql-umysql141-p

If you report an error: mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Solution: vi / etc/my.cnf add skip-grant-tables

II. Slave

1. Enable relay log and select a unique server-id

Relay-log = relay-log

Server-id =

2. Connect to the primary server and start replicating data

Enter MySQL:

Mysql > CHANGE MASTER TO master_host = 'master server', master_user = 'mysql141',master_password =' 123456 master mastery logbooks file = 'mysql-log.000010',master_log_pos = 480

Mysql > start slave # enable the following two states: YES

Mysql > SHOW SLAVE STATUS\ G; # View status

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

The status is normal when you see Slave_IO_State:Waiting for master ot send event, Slave_IO_Running: YES, and Slave_SQL_Running: YES.

Note:

Master_log_file = 'mysql-log.000010' # View with show master status; on the main server

Master_log_pos = 480 # View with show master status; on the main server

Third, test whether the master-slave replication is successful

Create a database on the primary server

SHOW DATABASES; # View the current database

CREATE DATABASE ; # create database

View from the server

SHOW DATABASES; # check whether the database has the database

If you have a library, you have succeeded!

Tags: Service data database server status user success password test selection master-slave two binary command address point method day log permission Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi macOS Docker Shulou Tech Info Linux