MySQL Master-slave replication

Source: Internet
Author: User

1, master server configuration.

[Email protected] ~]# vim/etc/my.cnf log-bin=master-binlog-bin-index=master-bin.indexinnodb_file_per_table = 1binlog_format=mixedserver-id = 1 #必须是唯一值sync_binlog =1 #设置主从同步二进制日志文件mysql > GRANT REPLICATION SLAVE on * * to ' Repluser ' @ ' 172.16.%.% ' identified by ' Replpass ';mysql> flush privileges;mysql> SHOW MASTER status\g;

2, slave server configuration.

[[email protected] ~]# vim /etc/my.cnf relay-log = relay-logserver-id  = 2relay-log-index = relay-log.indexread-only = on    #数据库只读锁定, Does not affect master-slave replication skip_slave_start=1   #禁止slave随数据库启动mysql > change master to master_host= ' 172.16.23.22 ', master_log_file= ' master-bin.000001 ', master_user= ' repluser ', master_password= ' Replpass ', MASTER_ log_pos=4;mysql> help change master to   #查看命令用法mysql > show slave  STATUS\G;    #查看状态mysql > START SLAVE;     #启动slave服务mysql > START SLAVE IO_THREAD;   #依次启动slave服务mysql > start slave sql_ thread;  mysql> show global variables like  ' read% ';   # View global Variables Verify read-only locking mysql> set global read_only=off;   #临时修改系统变量 [[email protected]  ~]# cat /datadir/master.info   #文件记录了master的连接帐号信息 [[Email protected] ~]# cat /datadir/relay-log.info    #文件记录了中继日志的信息


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.