MySQL configuration for master-slave and read-write separation on CentOS

Source: Internet
Author: User

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

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.