MySQL Master-slave replication

Source: Internet
Author: User

MySQL Master-slave replication
    • MySQL master-slave replication is an asynchronous replication process in which the main library sends update events to the library, reads the update records from the library, and executes the update records, keeping the contents of the library consistent with the main library.
Experimental environment
Host IP Address main software
Primary server 192.168.27.128 Mysql5.7.17;ntp
From server 1 192.168.27.139 Mysql5.7.17;ntp
From server 2 192.168.27.142 Mysql5.7.17;ntp
Build Master-slave replication 1, host Server setup time synchronization environment

Systemctl Stop Firewalld.service

Setenforce 0

Yum Install Ntp-y

Vim/etc/ntp.cnf

service 127.127.1.0             #本地时钟源fudge 127.127.1.0 stratum 8     #设置层级为8

Systemctl Start Ntp.service #开启服务

2, two time synchronization from the server

Systemctl Stop Firewalld.service

Setenforce 0

Yum Install Ntp-y

Systemctl Start Ntp.service

Yum Install Ntpdata-y

/usr/sbin/ntpdata 192.168.27.128 #进行时间同步

3, with the primary server

Vim/etc/my.cnf

server-id = 11log-bin=master-bin              #主服务器二进制日志log-slave-updates=true          #允许从服务器和主服务器同步

Systemctl Restart Mysqld.service

Mysql-u root-p #进入目mysql

Grant replication Slave on . to ' myslave ' @ ' 192.168.27.% ' identified by ' 123456 '; #允许192.168.27.0 network segment from the server using the account password login

Flush privileges; #更新权限

Show master status; #查看主服务器状态

4, configuration from the server (two from the server configuration is the same)

Vim/etc/my.cnf

server-id = 22relay-log=relay-log-bin                     #开启中继日志relay-log-index=slave-relay-bin.index       #确定中继位置

Systemctl Restart Mysqld.service

Mysql-u root-p

Change Master to master_host= ' 192.168.27.128 ', master_user= ' myslave ', master_password= ' 123456 ', master_log_file= ' Master-bin.000001 ', master_log_pos=603; #配置同步

Start slave;

show slave status\g; #查看slave状态

5. Testing
    • The TEST01 database is created on the primary server and is synchronized to the slave server;

    • Primary server:

    • From the server:
      ! [] (http://i2.51cto.com/images/blog/201807/11/dd5d22ab2dc551a830eaa8afe32f19de.jpg?x-oss-process=image/ watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=)

MySQL Master-slave replication

Related Article

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.