Database basic master-slave configuration

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.