MySQL Simple master and slave

Source: Internet
Author: User

master server Master
[[email protected] ~]# vim /etc/my.cnf[mysqld]log-bin=mysql-bin #必须开启log-binserver-id=129 #服务器ID
from server slave
[[email protected] ~]# vim /etc/my.cnf[mysqld]log-bin=mysql-bin #开启log-bin(可选)server-id=129 #服务器ID
[root@localhost ~]# systemctl restart mysqld  #主从服务器

mysql> GRANT REPLICATION SLAVE on * * to  ' Mysync ' @ '% ' identified by  ' 123456 ';  #主服务器授权账号      
mysql> Show master status;+------------------+----------+------ --------+------------------+-------------------+| File | Position | binlog_do_db | binlog_ignore_db | Executed_gtid_set |+------------------+----------+--------------+------------------+-------------------+|      mysql-bin.000001 | 439 | | | |+------------------+----------+--------------+------------------+------------------ -+1 row in set (0.00 sec"  #查看master状态        
mysql> stop slave;mysql>change master to master_host=‘192.168.100.129‘,master_user=‘mysync‘,master_password=‘123456‘, master_log_file=‘mysql-bin.000004‘,master_log_pos=308;mysql> stop slave;mysql> show slave status\G #查看slave状态 Slave_IO_Running: Yes #必须为Yes Slave_SQL_Running: Yes #必须为Yes如果在master 也配置 slave 架构就成了主主模式 需要注意数据一致性的问题

Virtual machine cloning requires rebuilding auto.cnf

[root@localhost ~]# mv /var/lib/mysql/auto.cnf /tmp[root@localhost ~]# systemctl restart mysqld

MySQL Simple master and slave

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.