23.mysql Cluster (Master-master)

Source: Internet
Author: User

Reference: http://blog.csdn.net/mr__fang/article/details/8692480http://www.2cto.com/database/201201/116756.htmlhttp:// blog.csdn.net/gzq_qiang/article/details/6988975http://blog.csdn.net/shiqidide/article/details/7254035 Software:
Mysql-server-5.6.29-1.el6.x86_64.rpmmysql-client-5.6.29-1.el6.x86_64.rpmwget http://mirror.centos.org/ centos/6/os/x86_64/packages/libaio-0.3.107-10.el6.x86_64.rpm
Operating system:            centos6.5_x64Server:    192.168.1.20 (Master1)
    192.168.1.21(Master1)
 Installation configuration:don't introduce how to install, see02-02-linux to build a variety of software development environment notestest only synchronizes the test library, master version must be >=slave versionmysql>SELECT VERSION (); configuration files and explanations:
  1. #######################配置master-master1#######################
  2. user=mysql
  3. log-bin=mysql-bin
  4. #指定自己编号,一个集群中id唯一
  5. server-id=1
  6. #要同步的数据库,通过二进制日志同步,所以这里提示"要记录二进制日志的数据库"
  7. binlog-do-db=test
  8. #和binlog-do-db=test对应;如果要同步多个库,这两项参数多个几个就行了.
  9. replicate-do-db=test
  10. #指定哪些库不同步,mysql库肯定不能同步,毕竟每个库上面的用户信息和参数不同
  11. binlog-ignore-db=mysql
  12. #同上面忽略记录日志的库一一对应;是不要记录日志的数据库名,多个数据库中间用逗号(,)隔开
  13. replicate-ignore-db=mysql
  14. #表示如果一个MASTER挂掉的话,另外一个马上接管
  15. log-slave-updates
  16. #跳过同步过程中sql错误
  17. slave-skip-errors=all
  18. #开启同步
  19. sync_binlog=1
  20. #自增主键,每次+2
  21. auto_increment_increment=2
  22. #自增主键,从1开始,每次+2
  23. auto_increment_offset=1
  24. #######################EOF######################################
  25. #######################配置master-master2#######################
  26. user=mysql
  27. log-bin=mysql-bin
  28. #指定自己编号,一个集群中id唯一
  29. server-id=2
  30. #要同步的数据库,通过二进制日志同步,所以这里提示"要记录二进制日志的数据库"
  31. binlog-do-db=test
  32. #和binlog-do-db=test对应;如果要同步多个库,这两项参数多个几个就行了.
  33. replicate-do-db=test
  34. #指定哪些库不同步,mysql库肯定不能同步,毕竟每个库上面的用户信息和参数不同
  35. binlog-ignore-db=mysql
  36. #同上面忽略记录日志的库一一对应;是不要记录日志的数据库名,多个数据库中间用逗号(,)隔开
  37. replicate-ignore-db=mysql
  38. #表示如果一个MASTER挂掉的话,另外一个马上接管
  39. log-slave-updates
  40. #跳过同步过程中sql错误
  41. slave-skip-errors=all
  42. #开启同步
  43. sync_binlog=1
  44. #自增主键,每次+2
  45. auto_increment_increment=2
  46. #自增主键,从1开始,每次+2
  47. auto_increment_offset=2
  48. #表示从mysql服务器启动时不启动同步线程,这就要在启动从服务器之后,手工启动同步线程,在mysql> 提示符下面运行“start slave”就可以
  49. skip-slave-start
  50. #######################EOF######################################
Restart 2 mysql servers. #master1 $ mysql-uroot-pmysql> Grant replication Slave on * * to ' replication ' @ '% ' identified by ' replica tion ';#在master1上创建一个用户用于同步mysql>flush Privileges;mysql>show master status;mysql>show Processlist;    #查看同步线程 #master2$ mysql-uroot-p#Master_log_file andMaster_log_posis the previous step on master,mysql>Change master to master_host= ' 192.168.1.20 ', master_user= ' replication ', master_password= ' replication ', Master_ Log_file= ' mysql-bin.000001 ', master_log_pos=406;mysql>start slave;mysql>show slave status;mysql>FLUSH TABLES with READ LOCK;mysql>Grant Replication Slave on * * to ' replication ' @ '% ' identified by ' replication ';mysql>Flush privileges;mysql>Show Master status;mysql> show Processlist; #测试同步数据# # #master1mysql > Use test;mysql>CREATE TABLE IF not EXISTS users (ID integer UNSIGNED auto_increment NOT null PRIMARY key,name varchar (+) NOT NULL U NIQUE,PASSWD varchar (+));mysql> Show tables; #此时再master2也可以看到该表mysql> INSERT into users values (1, ' 1 ', ' 1 ');mysql> SELECT * from users; # # #master2mysql> show tables;mysql> SELECT * from users;mysql>INSERT into users values (2, ' 2 ', ' 2 ');mysql> SELECT * from users;



From for notes (Wiz)



23.mysql Cluster (Master-master)

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.