When configuring MySQL master and Slave services:
Failure phenomena:
Mysql> Show Slave Status\g
.......
relay_log_file:localhost-relay-bin.000535
relay_log_pos:21795072
relay_master_log_file:localhost-bin.000094
Slave_io_running:yes
Slave_sql_running:no
replicate_do_db:
replicate_ignore_db:
......
MySQL replication in the slave machine has two key processes, dead one can not, one is slave_io_running, one is slave_sql_running, a responsible for the host IO Communication, a responsible for their own slave MySQL Process
Now, if there are no or connecting in the two states, how to recover
If it is slave_io_running for connecting, there are three reasons:
1, the network does not pass the solution: on the slave server telnet master_ip 3306 or Mysql-uusername-ppassword-hmasterip try to link
2, the password is not correct to see the password
3, POS value is not the same as the value of the POS on the viewing master
If it is slave_io_running for no, personally think there are three kinds of situations, one is the network has a problem, the connection is not (IBID.), the second is possible my.cnf have problems, the configuration file how to write do not say, online too much, the last one is the issue of authorization, replication Slave and file permissions are required.
Once slave_io_running for no the first look at the Err log, to see what is wrong, it is likely that the network, it is also possible that the package is too large to receive, this time the main prepared to change max_allowed_packet this parameter.
If it is slave_sql_running No, then there are two possibilities,
1. The program may have been written on the slave
2. It can also be the result of a transaction rollback after the slave machine restarts, which is also a self-protecting measure of MySQL, just like reading at critical times.
This is typically caused by a transaction rollback:
Solution One:
mysql> stop Slave;
Mysql> set GLOBAL sql_slave_skip_counter=1;
mysql> start slave;
Solution II,
First stop the slave service: Slave stop
To view host status on the primary server:
Record the value corresponding to file and position
Enter Master
Mysql> Show master status;
+------------------+----------+--------------+------------------+
| File | Position | binlog_do_db | binlog_ignore_db |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 3362 | | |
+------------------+----------+--------------+------------------+
1 row in Set (0.00 sec)
Then perform a manual synchronization on the slave server:
mysql> stop Slave;
Mysql>change Master to master_host= ' 192.168.1.201 ', master_user= ' Mysync ', master_password= ' q123456 ',
Master_log_file= ' mysql-bin.000001 ', master_log_pos=3362;
mysql> start slave;
Can!
Slave_io_running and slave_sql_running exception handling