1. Because the master server is responsible for the update operation, its security requirements are higher than that of the slave server, and some settings can be modified, such as sync_binlog=1, innodb_flush_log_at_trx_commit = 1 and other settings, while the slave does not need such high data security , it is completely possible to set sync_binlog to 0 or close binlog,
Innodb_flushlog , innodb_flush_log_at_trx_commit can also be set to 0 to improve the execution efficiency of sql, which can greatly improve the efficiency . The other is to use a better hardware device than the main library as the slave.
The purpose of increasing the slave server is to disperse the pressure of reading, thereby reducing the server load.
2. The method of judging the master-slave delay
MySQL provides the slave server status command, which can be viewed through show slave status. For example, you can check the value of the Seconds_Behind_Master parameter to determine whether there is a master-slave delay.
There are several values:
NULL - Indicates that either io_thread or sql_thread has failed, that is, the thread's Running state is No, not Yes.
0 - The value is zero, which is what we are very eager to see, Indicates that the master-slave replication status is normal
3. Main server configuration optimization
Find the my.ini configuration file settings:
[mysqld]
# 开启log-bin日志
log-bin=mysql-bin
server-id=1
# 我这里要复制名为test的数据库
binlog-do-db=test
Then find the parameters or add the parameters to set as follows (these two parameters control the speed of the binary log refresh, press first):
innodb_flush_log_at_trx_commit=1
sync_binlog=1
4, from the server configuration
Find the my.ini configuration file settings:
server-id=2 #识别服务器的唯一值
replicate-do-db=test #要同步的数据库
replicate-do-table=test.bakeup_table #要同步的表,改成自己的数据库和表
replicate-do-table=test.user #要同步的第二个表</span>
The parameters set above are immediately followed by the following parameters:
skip-slave-start=true #跳过slave线程启动
read_only=ON #开启的只读模式
relay-log=relay-bin
relay-log-index=relay-bin.index