MySQL version 5.5.58
The first step is to configure the host
The host configuration is as follows:
Server-id = 1#服务器id (master and slave must be different)Log_bin=MySQL-bin#Open the log (the host needs to open),
This mysql-bin can also be customized, here can also add the path, such as:/home/www/mysql_bin_log/mysql-bin
#configuration as a hostbinlog- Do-DB = Test#libraries to be synchronized to the slaveBinlog-ignore-db =MySQL #libraries that are not synchronized to the slave machineBinlog-ignore-db = Performance_schema#libraries that are not synchronized to the slave machineBinlog-ignore-db = Information_schema#libraries that are not synchronized to the slave machineExpire_logs_days = 2#automatically cleans up log files that are 2 days ago and can be modified as needed
second step to view the primary server status
Perform the show Master status in MySQL on the master server ;
Start configuration from server
The third step is to open the slave server
Executing from MySQL on the server
Change Master to master_host= ' 192.168.1.121 ', master_user= ' root ', master_password= ' root ', master_log_file= ' Mysql-bin.000002 ', master_log_pos=554;
Fourth step from server configuration
#as a slave-to-machine configuration
Server-id = 2master-host = 192.168.1.121#Destination Host IPMaster-user = root#Target Host user nameMaster-password = root#Target host PasswordMaster-port = 3306#Destination Host PortMaster-connect-retry = 60#link re-connect interval (unit s)Replicate-ignore-db =MySQL #databases that are not synchronized from the host (multiple write multiple lines)replicate- Do-DB = Test#libraries to synchronize from the host (multiple write multiple lines)Log-slave-update#enable the Slave log feature on the slave server so that this computer can be used to form a mirror chain (a->b->c)Slave-skip-errors#skipping errors, the slave should typically configure the item
Fifth Step execution
Execute start slave from server
Complete!!!
Warm tips
Perform a show slave status from the server;
When both slave_io_running and slave_sql_running are yes, the configuration succeeds and the log is not successful.
Related MySQL commands
show slave status\g;//querying slave status on a slave machineshow Master status\g;//querying host status on the hostshow master logs;//querying the Host binary log file list on a slave machineshow binary logs;//View a list of host binary log filesFlushLogs//commit a log (that is, a new binary log file)ResetMaster//clears all previous binary log files, and the new log file suffix will start at 000001slave stop; //Stop from serverResetSlave//Restart from serverSlave start;//Execute from server
MySQL master-slave replication configuration