(2) configuring Master-master replication
Compile db3 on DB1 (Master1), DB2 (MASTER2), slave (my.conf)
#vi/etc/my.cnf
[Mysqld]
Datadir=/var/lib/mysql
Socket=/var/lib/mysql/mysql.sock
User=mysql
#下面为新添加的内容
Default-storage-engine = InnoDB
replicate-ignore-db = MySQL
binlog-ignore-db = MySQL
Server-id = 1 # Each server cannot be the same
Log-bin =/var/log/mysql/mysql-bin.log
Log_bin_index =/var/log/mysql/mysql-bin.log.index
Relay_log =/var/log/mysql/mysql-bin.relay
Relay_log_index =/var/log/mysql/mysql-bin.relay.index
Expire_logs_days = 10
Max_binlog_size = 100M
Log_slave_updates = 1
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/13/wKioL1UhbUiiaC7EAAL4J-0uxqQ003.jpg "/>
Attention:
) Server-id The values on each server are not the same, here in turn 1, 2 3, 4
2) because here log file configured to /var/log/mysql mysql The default directory is in /var/lib/mysql Mysql folder, Mkdir/var/log/mysql, and then use chown-r mysql.mysql/var/ Log/mysql mysql command to mysql owner modified to user Mysql folder permissions 755- Rwxr-xr-x
if the permissions and owners are not modified, mysql-bin.log or mysql-bin.log.index errors are found in the error log when the service is restarted (/usr/libexec/ Mysqld:file '/var/log/mysql/mysql-bin.log.index ' not Found (errcode:13)).
Completing the post-compilation restart MYSQL Service
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/18/wKiom1UhbATgzYLDAACQy2-5Rv4890.jpg "/>
Check the replication status, such as:
Show master status;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5D/13/wKioL1UhbUmw0KSFAAGQCnk4uEc591.jpg "/>
Check to see if the log generates a new directory, as follows
# Ls/var/log/mysql
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5D/18/wKiom1UhbAXgd1ySAADUTA2KhMI476.jpg "/>
A total of three users are required to use mysql-mmm: Replication, Mmm_agent, and mmm_monitor(the Management Server is used to monitor Cluster The status of the user, so you can restrict logins from the Management Server only). Use the following three commands to create a new three user and assign the appropriate permissions
GRANT REPLICATION CLIENT on * * to ' mmm_monitor ' @ ' 10.0.0.% ' identified by ' monitor ';
GRANT SUPER, REPLICATION CLIENT, PROCESS on * * to ' mmm_agent ' @ ' 10.0.0.% ' identified by ' agent ';
GRANT REPLICATION SLAVE on * * to ' REPLICATION ' @ ' 10.0.0.% ' identified by ' REPLICATION ';
Next, DB1 and DB2 respectively execute the following command to modify the copy account and password. and start the slave process.
change Master to master_host= ' 10.0.0.4 ', master_port=3306, master_user= ' replication ', master_password= ' Replication '; start slave;
Change Master to master_host= ' 10.0.0.5 ', master_port=3306, master_user= ' replication ', master_password= ' replication '; start slave;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/13/wKioL1UhbUmgwm9IAACfJHErtFA903.jpg "/>
Check the replication status, such as:
Show Slave Status\g
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/13/wKioL1UhbUuATwJ2AASZ4uZR5uQ137.jpg "/>
This article is from "Li Xun Blog-Microsoft technology and Cloud" blog, make sure to keep this source http://lixun.blog.51cto.com/4198640/1629178
Microsoft Azure Deployment Mysql-mmm (2) Configure primary master replication