mysql-Master-slave replication

Source: Internet
Author: User

Implementation process:
(1) Master changes the record to binary log (these are called binary log events, binary logs event);
(2) Slave copies the binary log events of master to its trunk logs (relay log);
(3) Slave redo the event in the trunk log and change the data to reflect its own.

Related commands:

mysql> start slave; #启动slave

mysql> stop Slave; #停止

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

mysql> Reset Slave; #重置slave配置

Mysql> Show master status; #查看bin-log Status

Configuration implementation:

master configuration (in my.cnf ):

server-id=129

Log-bin=mysql-bin

Binlog-format=mixed

Slave configuration (in my.cnf):

server-id=130

Relay-log=mysql-relay

Create an account on Master and authorize:

mysql> Grant Replication client,replication slave on * * to ' repl ' @ ' 172.%.%.% ' identified by ' repl ';

mysql> FLUSH privileges;

Set on Slave:

Mysql> Change Master to

Master_host= ' 172.16.24.129 ',

Master_user= ' Tianbao ',

Master_password= ' Tianbao ',

Master_log_file= ' mysql-bin.000002 ',

master_log_pos=1099;

mysql> start slave;

Problems encountered:

#查看servid和配置文件中是否一致
ERROR HY000: The server is not configured as slave; Fix in config file or with change MASTER to

#重置slave (reset Slave), and from the new configuration, and then start slave
ERROR 1201 (HY000): Could not initialize master info structure; More error messages can is found in the MySQL error log

#状态不对. Check the Authorized account information, check the starting location of the log file Master_log_pos is consistent with the master. Show Master Status View bin-log information
Slave_io_state:connecting to master.

mysql-Master-slave replication

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.