Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos7mysql master-slave replication (default asynchronous)

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report