Introduction
The master-slave hot standby of database could improve the data security, stability, and efficient transmission of wordpress.
Configuration of steps
1 configure my.cnf in salve vps
server-id need different from the master
replicate-do-db: the database you want to syn
1 2 3 4 5 6 |
vim /etc/my.cnf local-infile=0 innodb_file_per_table=on replicate-do-db=database_name server-id=2 |
2 input SHOW MASTER STATUS; in the master and remember the file and position
1 2 3 4 5 6 |
MariaDB [(none)]> SHOW MASTER STATUS; +------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | mysql-bin.000004 | 23033| | | +------------------+----------+--------------+------------------+ |
3 input CHANGE MASTER TO MASTER_HOST in the slave
address: your database address
port: your database port
File: your begin file (mysql-bin.000004)
Position: begin position (23033)
1 2 3 4 5 6 7 8 |
MariaDB [(none)]> CHANGE MASTER TO MASTER_HOST='address',\ MASTER_USER='root',\ MASTER_PASSWORD='password',\ MASTER_PORT=PORT,\ MASTER_LOG_FILE='File',\ MASTER_LOG_POS=Position,\ MASTER_CONNECT_RETRY=10,\ MASTER_HEARTBEAT_PERIOD=2; |
4 input SHOW SLAVE STATUS\G in the slave database
if Slave_IO_Running and Slave_SQL_Running is yes that is successful
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
MariaDB [(none)]> SHOW SLAVE STATUS\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: ADDRESS Master_User: root Master_Port: PORT Connect_Retry: 10 Master_Log_File: mysql-bin.000004 Read_Master_Log_Pos: 23033 Relay_Log_File: mysqld-relay-bin.000023 Relay_Log_Pos: 5273041 Relay_Master_Log_File: mysql-bin.000004 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: DATABASE |
Comment