One: MySQL master-slave configuration
1.1 Deployment of the environment
Main (master_mysql): 192.168.1.200 os:centos 6.5
From (slave_mysql): 192.168.1.201 os:centos 6.5
1.2 Installing MySQL
Lord and slave: Yum install Mysql-server
1.3 Configuration
1.3.1 master configuration (master_mysql configuration)
VIM/ETC/MY.CNFserver-id=200 #设置主服务器的IDinnodb_flush_log_at_trx_commit=2 # Turn on the Binlog Log sync feature log-bin=mysql-bin-200 #binlog日志文件名binlog-do-db=xxxx # This indicates that only one library is synchronized (If this is not the case, all libraries are synchronized )
After the 1.3.2 is configured, restart the main library of MySQL
-uroot-P # #登录mysqlmysql'mark'@'192.168.1.201' '123456'; # #授权给从数据库服务器192. 168.1. 201 , user name mark, password 123456mysql>show master status; # #查看主库的状态 file, position these two values are useful. To be placed in the slave configuration
1.3.3 configuration from the library server
vim/etc/my.cnfserver-id=201innodb_flush_log_at_trx_commit=2sync_binlog=1log-bin= mysql-bin-201
After the 1.3.4 is configured, restart the MySQL from the library
Service mysqld Restart -uroot-pmysql> Change Master to master_host= ' 192.168.1.200 ', master_user= ' mark ', master_password= ' 123456 ', master_log_file= ' mysql-bin-200.000002 ', master_log_pos=1167;
mysql> start slave; # #开启从库 (Stop slave: off from library)
# # #Slave_IO_Running, slave_sql_running is yes when the configuration is successful
1.4: Verify Master-slave
You can create a library on the main library, and then refresh from the library to see if the synchronization
Second, read and write separation configuration (mysql_proxy,master,slave)
MySQL configuration for master-slave and read-write separation on CentOS