MySQL Master-slave replication error sql-running No

Source: Internet
Author: User
Tags error handling

Failure phenomena:
Enter the slave server and run:
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:
......
Workaround I.
Slave_sql_running:no
1. The program may have been written on the slave
2. It is also possible that the transaction rollback is caused by the slave machine being reset .

This is typically caused by a transaction rollback:
Workaround:
mysql> slave stop;
Mysql> set GLOBAL sql_slave_skip_counter=1;
mysql> slave start;
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 |
+----------------------+----------+--------------+------------------+
| localhost-bin.000094 |             33622483 |                  | |
+----------------------+----------+--------------+------------------+
1 row in Set (0.00 sec)
Then perform a manual synchronization on the slave server:

Mysql> Change Master to
> master_host= ' master_ip ',
> master_user= ' user ',
> master_password= ' pwd ',
> master_port=3306,
> master_log_file=localhost-bin.000094 ',
> master_log_pos=33622483;
1 row in Set (0.00 sec)
mysql> slave start;
1 row in Set (0.00 sec)
Mysql> Show Slave Status\g
1. Row ***************************
........
master_log_file:localhost-bin.000094
read_master_log_pos:33768775
relay_log_file:localhost-relay-bin.000537
relay_log_pos:1094034
relay_master_log_file:localhost-bin.000094
Slave_io_running:yes
Slave_sql_running:yes
replicate_do_db:
Manual synchronization needs to be stoppedmaster write operation!
View mysql the status and correction of the master-slave configuration Slave do not start the problem
1, view master status
Show Master status; //position should not be 0
Show processlist; 
//state status should be has sent all binlog to slave; Waiting Forbinlog to be updated
2, view slave status
show slave status;
Slave_io_running and slave_sql_running state should be yes
show processlist;
There should be two lines state value:
has read all relay log; Waiting for the slave I/O thread to Updat E It
waiting for master to send event

3. Error log
MySQL installation directory /usr/local/mysql
MySQL log directory /usr/local/mysql/data/shape,hostname.err

4. ChangeMaster to
If the Slave from the library is not started,slave_io_running is No.
May be the Master library is the information of master is changed,
View Main Library show master status;
Record the file,position field, assuming ' mysql-bin.000004 ', 98;
In the From Library execution:

Mysql>stop slave;
Mysql>change Master to master_log_file= ' mysql-bin.000004 ', master_log_pos=98;
Mysql>start slave;


5,SET global sql_slave_skip_counter=n;
If the slave_sql_running from the library is NO.
The Err file records:
Slave:error "Duplicate entry ' 1 ' for key 1" on query .....
It is possible that master did not synchronize successfully to slave, but there is already a record in slave. The resulting conflict can be executed from the vault.
Set global sql_slave_skip_counter=n;
Skip a few steps. Then restart slave.

6. Synchronous error Handling
found that MySQL slave server often because of some special characters or symbols generated by the UPDATE statement error, the entire synchronization will be stuck there, the original method is only manually go to the wrong machine to execute the following three SQL statements, skip the error.

Mysql>slave stop;
Mysql>set GLOBAL sql_slave_skip_counter=1;
Mysql>slave start;

PS: I have repeatedly encountered the synchronization process from the database automatically stop the problem, sometimes simple through slave stop,slave start can be solved. Sometimes slave start automatically stops and then the change Master resets the master database information in such a way that it solves the problem.

Description
Slave_io_running: Connect to the main library and read logs from the main library to local, generate local log files
Slave_sql_running: Reads the local log file and executes the SQL command in the log .

MySQL Master-slave replication error sql-running No

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.