Environment needs:
Database server IP needs to be within the same network
The following environment: 192.168.4.54 Primary Server
192.168.4.55 for slave server
#systemctl Stop Firewalld
#systemctl Disable FIREWALLD
#setenforce 0
Yum Repolist
1. Primary database server Configuration Master 54
1.1 Doing user authorization
Mysql>grant replication Slave on .
->to [email protected] "%" #从库服务器IP
->identified by "123456";
1.2 Enable Binlog Logging
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, from the database server configuration Slave55
2.1 Verifying the primary library authorized user
[Email protected] ~]# mysql-h192.168.4.54-urepluser-p123456
2.2 Specifying SERVER_ID
#vim/etc/my.cnf
[Mysqld]
Server_id=55
Validate_password_policy=0
Validate_password_length=6
#systemctl Restart Mysqld
2.3 Specifying the main library information
Mysql> Show master status; #在54主服务器上查看
[Email protected] ~]# mysql-uroot-p123456
mysql>show slave status; #查看自己是否为从服务器
Mysql> Change Master to
-master_host= "192.168.4.54", #主服务器IP
-Master_user= "Repluser", #授权用户名
-master_password= "123456", #授权用户登录密码
-master_log_file= "master54.000001", #日志文件名字//view on 54 primary server
master_log_pos=441; #偏移量//View on 54 primary server
mysql> start slave; #启动
2.4 Viewing configurations
Mysql> show Slave status\g;
Slave_io_running:yes
Slave_sql_running:yes
3. Log on to the primary server 192.168.4.54, write the data, and see if the same data is available from the server.
Database basic master-slave configuration