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

Basic master-slave configuration of database

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

The environment needs:

Database server ip needs to be in the same network

The following environment: 192.168.4.54 primary server

192.168.4.55 is the slave server

# systemctl stop firewalld

# systemctl disable firewalld

# setenforce 0

Yum repolist

1. Configuration of the primary database server master 54

1.1 do user authorization

Mysql > grant replication slave on.

-> to repluser@ "%" # IP from the library server

-> identified by "123456"

1.2 enable binlog Log

Vim / etc/my.cnf

[mysqld]

Server_id=54

Log-bin=master54

Binlog-format= "mixed"

Validate_password_policy=0

Validate_password_length=6

# systemctl restart mysqld

1.3 View in use

Mysql > show master status

2. Configure slave55 from the database server

2.1 verify the authorized user of the main library

[root@db5] # mysql-h292.168.4.54-urepluser-p123456

2.2 specify server_id

# vim / etc/my.cnf

[mysqld]

Server_id=55

Validate_password_policy=0

Validate_password_length=6

# systemctl restart mysqld

2.3 specify main library information

Mysql > show master status; # view on 54 master server

[root@db5] # mysql-uroot-p123456

Mysql > show slave status; # to see if you are a slave server

Mysql > change master to

-> master_host= "192.168.4.54", # Master server IP

-> master_user= "repluser", # authorized user name

-> master_password= "123456", # authorized user login password

-> master_log_file= "master54.000001", # Log file name / / View on 54 master server

-> master_log_pos=441; # offset / / View on 54 master server

Mysql > start slave; # start

2.4 View configuration

Mysql > show slave status\ G

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

3. Log in on the master server 192.168.4.54, write the data, and check whether there is the same data on the slave server.

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

Database

Wechat

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

12
Report