MySQL master-slave configuration means a primary MySQL server, one from the MySQL server, a total of two servers to use. The main server added an account to allow access to the synchronization from the server, the master-slave configuration is completed, the main server is the new and update operations, from the server is mainly query work.
The primary server IP is: 192.168.31.11
From the server IP: 192.168.31.12
// Create a new user // slave users must have replication slave permissions, but there is no need to add unnecessary permissions, the password is MySQL. Describe the 192.168.31.12, which is the server where the slave user is located. 'slave' @'192.168.31.12'111111 ';
Flush privileges;
Configure the following information in the/ETC/MY.CNF configuration file of the master server
server-id=one // Unique identification of the database service, usually set the end number of the server IP log-bin=master-binlog -bin-index=master-bin.index
Restart MySQL, run show master status, and see if the primary server is healthy
Then configure the MySQL configuration file from the server, and then restart MySQL after the modifications are completed
Log_bin = mysql-binserver_id relay_log = mysql-relay-1 read_only 1//server_id is a must, and the only. Slave there is no need to open the binary log, but in some cases it must be set, for example, if Slave is the master of the other slave, you must set the Bin_log. Here we have the binary log turned on, and the display is named (the default name is hostname, but if the hostname changes there will be a problem). Relay_log configures the trunk log, log_slave_updates indicates that slave writes the copy event into its own binary log (which you will see later). Some people turn on the slave binary log, but do not set log_slave_updates, and then see if slave's data changes, which is a bad configuration. So, try to use READ_ONLY, which prevents the data from changing (except for special threads). However, read_only is useful, especially for applications that need to create tables on slave.
The next step is to link the master server.
Change Master to master_host='192.168.31.11'//master server IPmaster_port =3306, master_user='repl', Master_password=' MySQL ' , Master_log_file='master-bin.000002',// The log master_log_pos=107 generated by master server ;
View the status from the server show slave status;
MySQL master-slave configuration and its read-write separation