mysql主主复制
2016-03-04 17:19
344 查看
主主复制原理:
在这篇文章( http://www.cnblogs.com/whereareyoufrom/p/5240380.html )中讲解主从复制的原理,而主主复制的原理更加简单,只需要将主从复制中master的配置操作再在slave中配置一遍,将slave的配置操作在master中配置一遍即可。
配置:
salve配置(将slave配置成master):1.修改slave mysql配置文件,加入如下内容
server-id=2 log-bin=mysqlbinlog #开始binlog,binlog文件命名为mysqlbinlog binlog_format=fixed #binlog格式 binlog-do-db=mydata #binlog-ignore-db=xxx auto-increment-offset=2 auto-increment-increment=2
2.创建binlog操作用户
>>> create user replicator@'%' identified by 'xxxxxx'; >>> grant replication slave on *.* to 'replicator'@'%' identified by 'xxxxxx'; >>> flush privileges;
3.查看binlog文件名和文件指针位置
>>> show master status; +--------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +--------------------+----------+--------------+------------------+ | mysqlbinlog.000001 | 245 | mydata | | +--------------------+----------+--------------+------------------+ 1 row in set (0.00 sec)
master 配置(将master配置成slave):
1.修改master 配置文件(重启mysql)
replicate-do-db=mydata
2.配置binlog文件信息
>>> change master to master_host='192.168.252.18', master_user='replicator', master_password='xxxxx', master_log_file='mysqlbinlog.000001', master_log_pos='245'; >>> start slave; >>> show slave status; MariaDB [mydata]> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.252.18 Master_User: replicator Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysqlbinlog.000001 Read_Master_Log_Pos: 1157 Relay_Log_File: mariadb-relay-bin.000002 Relay_Log_Pos: 1078 Relay_Master_Log_File: mysqlbinlog.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: mydata Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 1157 Relay_Log_Space: 1374 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 2 1 row in set (0.00 sec) ERROR: No query specified slave 两个线程启动正确。o啦
相关文章推荐
- MySQL主主复制试验
- 并发环境下mysql插入检查方案
- mysql存储过程详解
- mysql 更改列名字
- mysql case when(二)
- 避免mysql注入应该避免特殊字符
- mysql case when
- mysql主主(基于bin-log)
- yum安装mysql
- 【MySQL新手必看】百宝云的MySQL数据库基础知识
- mysql 主从
- mysql互主自动化配置脚本
- c# mysql getstring getdatatable 需要MySql.Data.dll
- MySQL中的几个函数
- MySQL:索引工作原理及索引的用法
- 数据库的使用——mysql使用大全
- mysql内置函数
- windows下Mysql5.7.11修改初始密码
- MySQL常见错误
- mysql表结构随笔