START SLAVE with no thread_type options starts both of the slave threads. The I/O
thread reads events from the master server and stores them in the relay log. The SQL
thread reads events from the relay log and executes them. START SLAVE requires
the SUPER privilege.
If START SLAVE succeeds in starting the slave threads, it returns without any error.
However, even in that case, it might be that the slave threads start and then later stop (for
example, because they do not manage to connect to the master or read its binary log, or
some other problem). START SLAVE does not warn you about this. You must check the
slave's error log for error messages generated by the slave threads, or check that they are
running satisfactorily with SHOW SLAVE STATUS.
START SLAVE sends an acknowledgment to the user after both the I/O thread and the SQL
thread have started. However, the I/O thread may not yet have connected. For this reason,
a successful START SLAVE causes SHOW SLAVE STATUS to
show Slave_SQL_Running=Yes, but this does not guarantee
that Slave_IO_Running=Yes(because Slave_IO_Running=Yes only if the I/O thread is
running and connected). For more information, seeSection 13.7.5.31, SHOW SLAVE
STATUS Syntax, and Section 16.1.3.1, Checking Replication Status.
You can add IO_THREAD and SQL_THREAD options to the statement to name which of the
threads to start.
An UNTIL clause may be added to specify that the slave should start and run until the SQL
thread reaches a given point in the master binary log or in the slave relay log. When the
SQL thread reaches that point, it stops. If the SQL_THREAD option is specified in the
statement, it starts only the SQL thread. Otherwise, it starts both slave threads. If the SQL
thread is running, the UNTIL clause is ignored and a warning is issued.
For an UNTIL clause, you must specify both a log file name and position. Do not mix master
and relay log options.
Any UNTIL condition is reset by a subsequent STOP SLAVE statement, a START
SLAVE statement that includes noUNTIL clause, or a server restart.
The UNTIL clause can be useful for debugging replication, or to cause replication to
proceed until just before the point where you want to avoid having the slave replicate an
event. For example, if an unwise DROP TABLEstatement was executed on the master, you
can use UNTIL to tell the slave to execute up to that point but no farther. To find what the
event is, use mysqlbinlog with the master binary log or slave relay log, or by using aSHOW
BINLOG EVENTS statement.
If you are using UNTIL to have the slave process replicated queries in sections, it is
recommended that you start the slave with the --skip-slave-start option to prevent the
SQL thread from running when the slave server starts. It is probably best to use this option
in an option file rather than on the command line, so that an unexpected server restart does
not cause it to be forgotten.
The SHOW SLAVE STATUS statement includes output fields that display the current values
of the UNTIL condition.
In old versions of MySQL (before 4.0.5), this statement was called SLAVE START. This
usage is still accepted in MySQL 5.0 for backward compatibility, but is deprecated and is
removed in MySQL 5.6.
Previous / Next / Up / Table of Contents
User Comments
Posted by Jim Grill on February 5 2008 2:03pm
[Delete] [Edit]
Useful feature...
Sometimes it's desirable to keep a slave behind the master in the event a bad drop statement
causes chaos.
For example to keep a slave behind the master at all times write a script to:
1) get the current master log file and position and save it in a file
2) use the master log file and position from the *previous* run to START SLAVE UNTIL
MASTER_LOG_FILE='<log file>', MASTER_LOG_POS=<position>
3) run the script once per hour to keep the slave the behind at least an hour at all times... or
every ten minutes to keep it ten minutes behind.
[Delete] [Edit]
I have set up replication for MySQL server. I can connect from the slave machine
to the master server using the replication user/password. I have got the slave SQL
thread running, but the slave I/Othread is not running and the slave I/O status
comes as empty when checked using 'show slave status'. What could be the
problem?
How do I solve this? Restarting the slave does not help.
This was my bad: Instead of giving a 'replication slave' privilege to *.*, I was
only giving it for my_db.*.
mysql
replication
slave
asked
17:59
Peter Mortensen
Champ
8,711105895
323
add a comment
4 Answers
activeoldest
votes
up
vote3
down
vote
accepted
Replication slave is only a global privilege (i.e. per-user only), this means that a
command such as
GRANT REPLICATION SLAVE on mydb.* TO 'someuser'@'%';
Then do a START SLAVE. You might also find it useful to look in the mysql error
log.
I'd suggest a good read of the replication setup documentation, as it explains all
of this in detail.
shareimprove this answer
answered
12:20
brian-brazil
4,323
add a comment
up
vote3
down
vote
answered
9:53
Luxknight007
31
add a comment
up
vote2
down
vote
answered
12:22
M Arif
144
add a comment
up
vote1d
own
vote
I faced same issue and fixed using following steps. Complete thread link
ishttp://www.percona.com/forums/questions-discussions/perconaxtrabackup/11842-backup-stopped-working-slave-sql-running-no
Steps are same as mentioned by @Luxknight007 except his step 2. However this
thread contains more detail which is very helpful. Following is solution which i
used and it worked.
"The first issue is that you changed the replication position instead of fixing the
error, and used an incorrect binlog file name format (you likely just used the one
from that post you linked I'd guess). To get back to where you started, you need
to find the binlog file and position that the slave sql_thread stopped at. Based on
your slave status output, it looks like the slave is reading from a new binlog file
(you can see that the Read_Master_Log_Pos value is smaller than the
Exec_Master_Log_Pos value, which means it has to be reading a newer binlog
file than where the slave sql_thread stopped at), so you need to find the binlog
file that the slave sql_thread actually failed on. So look in the error log for
something like the below:
Code:
2013-10-08 12:48:51 37545 [ERROR] Slave SQL: Error 'Table 'testdb.test2'
doesn't exist' on query. Default database: 'testdb'. Query: 'insert into
test1 select * from test2', Error_code: 1146
2013-10-08 12:48:51 37545 [Warning] Slave: Table 'testdb.test2' doesn't
exist Error_code: 1146
2013-10-08 12:48:51 37545 [ERROR] Error running query, slave SQL
thread aborted. Fix the problem, and restart the slave SQL thread with
"SLAVE START". We stopped at log 'mysql-bin.000001' position 3427
This is a sample I re-created, so yours will be a bit different. Note the ERROR is
similar to what you see in your slave status. So find your specific error message
in the error log file, and then locate the end part where is gives you the file name
and position ("We stopped at log 'mysql-bin.000001' position 3427" in my
example). The position should be 315098143 based on your show slave status, as
that is when it the slave sql_thread stopped executing events
(Exec_Master_Log_Pos ) but the io_thread kept reading in new ones
(Read_Master_Log_Pos).
Once you find the correct binlog file name and position, re-run your change
master statement on your slave using the information you located in the error
log. Note that your file name should be something like "newcrmdb1bin.XXXXXX", not mysql-bin.XXXXXX (you can see this naming convention
your show slave status above).
Code:
mysql> change master to MASTER_LOG_FILE='newcrmdb1-bin.XXXXXX',
Master_Log_Pos=315098143;
change master to MASTER_LOG_FILE='mysql-bin.000082' ,
Master_Log_Pos=47914844;
Once you get pointed back to the original replication location where the slave
sql_thread failed, you need to then fix the error that it was complaining about to
start with.
The initial replication error appears to be telling you that the
table asteriskcdr.bpleadcf does not exist on the slave, so the insert statement is
failing when it attempts to select the data from that table. So the problem there is
that your slave appears to be already out of sync with your master. If the table in
question on the master is static or mostly static, you could likely solve this by
exporting the data from just that table on the master using mysqldump and
loading it into the slave. If that is not possible, or you do not care about that data,
you could always just skip the replication statement with
sql_slave_skip_counter, but then the slave would be further out of sync with the
master.
And if all else fails, you can always rebuild the slave from the master as a last
resort as well. =)"
Hello everyone,
My latest issues are just piling up and i am not able to get them all sorted
To add to my chaos, now my backup server too is giving me issues.
When i run the command :-
Code:
TheSlave|mysql>SHOWSLAVESTATUS\G
...
Slave_IO_Running:Yes
Slave_SQL_Running:No
Code:
tailf/var/log/messages
Oct813:32:37DatabackupSRVxinetd[3396]:EXIT:nrpestatus=0pid=3295
duration=0(sec)
Oct813:34:19DatabackupSRVxinetd[3396]:START:nrpepid=3300
from=10.222.32.22
Oct813:34:19DatabackupSRVxinetd[3396]:EXIT:nrpestatus=0pid=3300
duration=0(sec)
Oct813:34:29DatabackupSRVxinetd[3396]:START:nrpepid=3305
from=10.222.32.22
Oct813:34:29DatabackupSRVxinetd[3396]:EXIT:nrpestatus=0pid=3305
duration=0(sec)
It was working all this while, But i guess the recent start / stop of mysql services and the
server of the master is causing this issue.
systemali
Counsellor
Join Date: Jan 2013
Posts: 118
o
o
o
#2
10-08-2013, 03:58 AM
Thought for a moment and decided why not post the whole output of the command : SHOW
SLAVE STATUS \G
Code:
mysql> SHOW SLAVE STATUS \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.222.1.218
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: newcrmdb1-bin.000061
Read_Master_Log_Pos: 315098143
Relay_Log_File: DatabackupSRV-relay-bin.000088
Relay_Log_Pos: 667796113
Relay_Master_Log_File: newcrmdb1-bin.000054
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1146
Last_Error: Error 'Table 'asteriskcdr.bpleadcf' doesn't exist' on query. Default database: '
newcrmdb'. Query: 'INSERT INTO `newcrmdb`.`bpleadcf` SELECT * FROM `asteriskcdr`.`bpleadcf`'
Skip_Counter: 0
Exec_Master_Log_Pos: 667795964
Relay_Log_Space: 1134162270
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1146
Last_SQL_Error: Error 'Table 'asteriskcdr.bpleadcf' doesn't exist' on query. Default database: '
newcrmdb'. Query: 'INSERT INTO `newcrmdb`.`bpleadcf` SELECT * FROM `asteriskcdr`.`bpleadcf`'
1 row in set (0.00 sec)
systemali
Counsellor
Join Date: Jan 2013
Posts: 118
o
o
o
#3
10-08-2013, 04:35 AM
Ahhh...
With regards to my similar post earlier, I tried to trouble shoot the issue, but in vein...
Now when i run the command :- "show slave status \G"
Code:
mysql> show slave status \G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 10.222.1.218
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000055
Read_Master_Log_Pos: 315098143
Relay_Log_File: DatabackupSRV-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000055
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 315098143
Relay_Log_Space: 106
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 1236
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not f
ind first log file name in binary log index file'
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)
I'll let everyone know, what i did :This is the first change i did :-
Code:
mysql>changemastertoMASTER_LOG_FILE='mysqlbin.000055',Master_Log_Pos=4;
Code:
mysql>changemastertoMASTER_LOG_FILE='mysqlbin.000055',
Master_Log_Pos=315098143;
Those are the 2 chnages i have done and now i get the status as shown above
i hope i have not messed it up too much !!
Thank you
scott.nemes
Mod Squad
Join Date: Jan 2012
Posts: 313
o
o
o
#4
10-08-2013, 03:09 PM
Code:
2013100812:48:5137545[ERROR]SlaveSQL:Error'Table'testdb.test2'
doesn'texist'onquery.Defaultdatabase:'testdb'.Query:'insertintotest1
select*fromtest2',Error_code:1146
2013100812:48:5137545[Warning]Slave:Table'testdb.test2'doesn'texist
Error_code:1146
2013100812:48:5137545[ERROR]Errorrunningquery,slaveSQLthread
aborted.Fixtheproblem,andrestarttheslaveSQLthreadwith"SLAVESTART".
Westoppedatlog'mysqlbin.000001'position3427
This is a sample I re-created, so yours will be a bit different. Note the ERROR is similar to
what you see in your slave status. So find your specific error message in the error log file,
and then locate the end part where is gives you the file name and position ("We stopped at
log 'mysql-bin.000001' position 3427" in my example). The position should be 315098143
based on your show slave status, as that is when it the slave sql_thread stopped executing
events (Exec_Master_Log_Pos ) but the io_thread kept reading in new ones
(Read_Master_Log_Pos).
Once you find the correct binlog file name and position, re-run your change master
statement on your slave using the information you located in the error log. Note that your
file name should be something like "newcrmdb1-bin.XXXXXX", not mysql-bin.XXXXXX (you
can see this naming convention your show slave status above).
Code:
mysql>changemastertoMASTER_LOG_FILE='newcrmdb1bin.XXXXXX',
Master_Log_Pos=315098143;
Once you get pointed back to the original replication location where the slave sql_thread
failed, you need to then fix the error that it was complaining about to start with.
The initial replication error appears to be telling you that the table `asteriskcdr`.`bpleadcf`
does not exist on the slave, so the insert statement is failing when it attempts to select the
data from that table. So the problem there is that your slave appears to be already out of
sync with your master. If the table in question on the master is static or mostly static, you
could likely solve this by exporting the data from just that table on the master using
mysqldump and loading it into the slave. If that is not possible, or you do not care about
that data, you could always just skip the replication statement with sql_slave_skip_counter,
but then the slave would be further out of sync with the master.
And if all else fails, you can always rebuild the slave from the master as a last resort as
well. =)
systemali
Counsellor
Join Date: Jan 2013
Posts: 118
o
o
o
#5
10-09-2013, 10:09 AM
Hello Scott,
Phewww.....My apologies for causing you such a pain
explanation was very very useful and i did learn a few things extra
But, I could not salvage the data from its last position and hence i had to redo the whole
replication stuff once again, which i have just completed
scott.nemes
Mod Squad
Join Date: Jan 2012
Posts: 313
o
o
o
#6
10-09-2013, 10:22 AM
systemali
Counsellor
Join Date: Jan 2013
Posts: 118
o
o
o
#7
10-09-2013, 11:53 PM
Cuando indiquemos en el manual Mysql> es porque tenemos que introducir los comandos
dentro de la consola de Mysql.
Para entrar en la consola introducir el comando : mysql -u root -p
Ejemplo del comando en un servidor linux :
# /usr/local/mysql/bin/mysql -u root -p (Puede ser diferente la ruta en tu PC)
En ese momento el servidor mysql pide el password de root , lo introducimos y se accede a la
consola.
La replicacin de Base de Datos en mysql tiene varias caractersticas a considerar y son:
Podemos tener sendos servidores esclavos para cada maestro, pero no varios
maestros para un esclavo.
La replicacin copia exactamente todos los cambios que se van haciendo desde que se
activa el sistema de replicacin, es decir, antes de replicar hay que hacer un backup
definitivo de la base de datos principal a la esclava, para que las 2 bases de datos
tengan exactamente la misma informacin.
Cada servidor esclavo debe tener permiso para conectar con el maestro y solicitar las
actualizaciones.
El servidor esclavo necesita una cuenta en el servidor maestro para que pueda
conectarse. En el servidor maestro, configure una cuenta como sta :
El servidor maestro crea un hilo de proceso para manejar cada esclavo. En el lado del
servidor esclavo se crean 2 hilos para manejar las tareas de rplica. El primer hilo es
de Entrada/Salida recibe los eventos para procesar del servidor maestro y los escribe
en los registros de reenvo del esclavo. El segundo hilo el SQL lee los eventos de los
registros de reenvo y los ejecuta.
Es aconsejable que las rplicas de las Bases de Datos MySql sean de la misma
versin y si es posible de la 5.x y activos los mismos motores en las 2 B.D.
La sentencia SHOW MASTER STATUS : Indica el fichero .bin que est utilizando el master
para guardar los cambios actualmente y por que posicin va actualmente (lnea dentro del
fichero).
Ejemplo de resultado de SHOW MASTER STATUS/
File = mysql-bin.000122
Position = 269
Id: 97
User: replica
Host: 192.168.5.130:48647
db: NULL
Time: 1262
State: Has sent all binlog to slave; waiting for binlog to be updated
Info: NULL
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Ignore_DB:
conecta con el flujo 1 al servidor para recibir el log, una vez recibido el flujo 2 mete la
informacin nueva al mysql propio.
*************************** 1. row ***************************
Id: 1
Host:
db: NULL
Command: Connect
Info: NULL
Id: 2
Host:
db: NULL
Command: Connect
Time: 12
State: Has read all relay log; waiting for the slave I/O thread to update it
Info: NULL
Para expirar los registros binarios. Podemos utilizar dicha sentencia despus de ejecutar la
sentecia :
Mysql> PURGE MASTER;
En cada uno de los esclavos para determinar qu registros binarios ya no son necesarios.
Mysql> SHOW SLAVE STATUS;
Tenemos una replicacin mysql cliente que se ejecuta en nuestro servidor de copia de
seguridad. Desde un fallo de alimentacin, la semana pasada se detiene la replicacin.
Antes de que esto se estaba ejecutando de forma ininterrumpida durante varios meses.
He intentado reiniciar tanto el maestro y el esclavo, pero esto no ha ayudado. Puedo
acceder al servidor maestro del esclavo, por lo que la red no es el problema.
Hay algo ms que pueda hacer para tratar de diagnosticar cul es el problema?
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: master
Master_User: username
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000060
Read_Master_Log_Pos: 46277494
Relay_Log_File: mysqld-relay-bin.000348
Relay_Log_Pos: 98
Relay_Master_Log_File: mysql-bin.000060
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 46277494
Relay_Log_Space: 98
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
1 row in set (0.00 sec)
ERROR:
No query specified
ERROR:
No query specified
Mejorar Traduccin
5 Respuestas
Demasiados anuncios?
6
Mejor Respuesta
Ryan SampsonPuntos2898
MarkRPuntos2323
Usted debe examinar la esclava del error de registro - suele ser muy explcito
acerca de cul es el problema.
Usted debe tener la base de los registros de error ligado a su sistema de
supervisin, de lo contrario tus esclavos son potencialmente intil.
Adems, usted debe tener un monitor en el cual se comprueba el estado de los
esclavos.
Y para ser de cualquier uso en todos, usted tambin desear comprobar la
sincronizacin de los esclavos a partir de tiempo al tiempo, tal vez por el uso de
algo como mk-tabla de suma de comprobacin; lo ideal sera que el empate los
resultados de que en su sistema de monitoreo as.
Respondido el 10 de Julio, 2009 por MarkR (2323 puntos)
Mejorar Traduccin
kashaniPuntos3273
Muchas personas set skip-esclavo-de inicio para que puedan asegurarse de que
todo est bien si un esclavo deja de replicar antes de la puesta en marcha. Intente
ejecutar 'start slave" y ver si algo cambia o si algo se registra. Adems es extrao
que el SlaveSQL proceso se est ejecutando y el SlaveIO no lo es. Es posible que
el rel local de los registros en el esclavo ha sido daado a pesar de que debe ser
reportado en los registros. Usted puede tratar de llevar Mysql hacia abajo y, a
continuacin, eliminar el rel de registros.
Respondido el 10 de Julio, 2009 por kashani (3273 puntos)
Mejorar Traduccin
user49957Puntos121
BakshuPuntos1
Desde el informe anterior que he encontrado el problema, este fieled debe ser
ajustado a (Slave_IO_Running): s, pero en el informe anterior se muestra
Slave_IO_Running: No.
Eso es la causa del problema, Si esta variable se lee 'No', entonces la IO hilo se ha
causado a parar. as que no hay replicacin. Usted tendr que comprobar la
Last_SQL_Errno y Last_SQL_Err para obtener ms informacin sobre la causa. Un
nmero de error de 0 y el mensaje de la cadena vaca significa que "no hay error".
El Last_SQL_Error aparece en el esclavo del registro de errores.
Para solucionar este problema, detenga el esclavo
A continuacin, establezca:
mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
Esto le dice al esclavo que saltarse una consulta (que es el invlido que caus la
replicacin a parar). Si usted desea saltar dos consultas, tendra que utilizar SET
GLOBAL SQL_SLAVE_SKIP_COUNTER = 2; en su lugar y as sucesivamente.
A continuacin, reinicie el esclavo y la verificacin de los registros, con la
Esperanza de que esto va a solucionar el problema...
I have set up replication for MySQL server. I can connect from the slave machine
to the master server using the replication user/password. I have got the slave SQL
thread running, but the slave I/Othread is not running and the slave I/O status
comes as empty when checked using 'show slave status'. What could be the
problem?
How do I solve this? Restarting the slave does not help.
This was my bad: Instead of giving a 'replication slave' privilege to *.*, I was
only giving it for my_db.*.
mysql
replication
slave
asked
17:59
Peter Mortensen
Champ
8,711105895
323
add a comment
4 Answers
activeoldest
votes
up
vote3
down
vote
accepted
Replication slave is only a global privilege (i.e. per-user only), this means that a
command such as
GRANT REPLICATION SLAVE on mydb.* TO 'someuser'@'%';
Then do a START SLAVE. You might also find it useful to look in the mysql error
log.
I'd suggest a good read of the replication setup documentation, as it explains all
of this in detail.
shareimprove this answer
answered
12:20
brian-brazil
4,323
add a comment
up
vote3
down
vote
answered
9:53
Luxknight007
31
add a comment
up
vote2
down
vote
answered
12:22
M Arif
144
add a comment
up
vote1d
own
vote
I faced same issue and fixed using following steps. Complete thread link
ishttp://www.percona.com/forums/questions-discussions/perconaxtrabackup/11842-backup-stopped-working-slave-sql-running-no
Steps are same as mentioned by @Luxknight007 except his step 2. However this
thread contains more detail which is very helpful. Following is solution which i
used and it worked.
"The first issue is that you changed the replication position instead of fixing the
error, and used an incorrect binlog file name format (you likely just used the one
from that post you linked I'd guess). To get back to where you started, you need
to find the binlog file and position that the slave sql_thread stopped at. Based on
your slave status output, it looks like the slave is reading from a new binlog file
(you can see that the Read_Master_Log_Pos value is smaller than the
Exec_Master_Log_Pos value, which means it has to be reading a newer binlog
file than where the slave sql_thread stopped at), so you need to find the binlog
file that the slave sql_thread actually failed on. So look in the error log for
something like the below:
Code:
2013-10-08 12:48:51 37545 [ERROR] Slave SQL: Error 'Table 'testdb.test2'
doesn't exist' on query. Default database: 'testdb'. Query: 'insert into
test1 select * from test2', Error_code: 1146
2013-10-08 12:48:51 37545 [Warning] Slave: Table 'testdb.test2' doesn't
exist Error_code: 1146
2013-10-08 12:48:51 37545 [ERROR] Error running query, slave SQL
thread aborted. Fix the problem, and restart the slave SQL thread with
"SLAVE START". We stopped at log 'mysql-bin.000001' position 3427
This is a sample I re-created, so yours will be a bit different. Note the ERROR is
similar to what you see in your slave status. So find your specific error message
in the error log file, and then locate the end part where is gives you the file name
and position ("We stopped at log 'mysql-bin.000001' position 3427" in my
example). The position should be 315098143 based on your show slave status, as
that is when it the slave sql_thread stopped executing events
(Exec_Master_Log_Pos ) but the io_thread kept reading in new ones
(Read_Master_Log_Pos).
Once you find the correct binlog file name and position, re-run your change
master statement on your slave using the information you located in the error
log. Note that your file name should be something like "newcrmdb1bin.XXXXXX", not mysql-bin.XXXXXX (you can see this naming convention
your show slave status above).
Code:
mysql> change master to MASTER_LOG_FILE='newcrmdb1-bin.XXXXXX',
Master_Log_Pos=315098143;
change master to MASTER_LOG_FILE='mysql-bin.000082' ,
Master_Log_Pos=47914844;
Once you get pointed back to the original replication location where the slave
sql_thread failed, you need to then fix the error that it was complaining about to
start with.
The initial replication error appears to be telling you that the
table asteriskcdr.bpleadcf does not exist on the slave, so the insert statement is
failing when it attempts to select the data from that table. So the problem there is
that your slave appears to be already out of sync with your master. If the table in
question on the master is static or mostly static, you could likely solve this by
exporting the data from just that table on the master using mysqldump and
loading it into the slave. If that is not possible, or you do not care about that data,
you could always just skip the replication statement with
sql_slave_skip_counter, but then the slave would be further out of sync with the
master.
And if all else fails, you can always rebuild the slave from the master as a last
resort as well. =)"
On Master,
get the Replication Master Binary Log Coordinates
create a data snapshot using mysqldump
transfer the data on Slave
a.
b.
On Slave,
Restore the data snapshot
Set the Slave to start replication.
2.
Detailed Actions
On Master
During steps 1 and 2 below, your Master database will be set to readonly mode.
1.
a.
c.
When your data dump finishes, just close the connection you opened
on step 1 and your Master database server will resume serving
transactions.
Now, you have a database file you can use on Slave to restore the
database. You have to transfer this file to your Slave node.It might be
a good idea to tar and gzip this file before transferring it and then
untar and unzip it at the Slave node.
On Slave
Assuming that you have transferred your database dump file to Slave,
you move on to work on this node as follows:
1.
2.
have enough space both on the datadir of MySQL and on the binary log
directory too.
3.
The problem that you have now is that you restored the system
databases as well. These are coming from your Master server,
which has a different IP. This will mean that root user might not
have any access to MySQL server now from the local Slave
machine.
Also, root might have different password. In Debian machine this
is encrypted in the filedebian.cnf in your MySQL installation
directory.
You can bring the debian.cnf file from your Master to your Slave
machine. Or you can change/reset the root password on your
Slave machine.
Hint: You can change/reset the root password on MySQL server as
follows:
o
Start MySQL so that it will not ask for password. Also, make
sure it does not start replication:
4.
Stop MySQL Server that you started with skipping slave start
and grant tables.
8.
2.
+----+-------------+-----------+-------+--------+-----+----------------------------------------------------------------------+------------------+
3.
4.
| Id | User
Time | State
| Host
| db
| Info
| Command |
|
5.
6.
+----+-------------+-----------+-------+--------+------
+----------------------------------------------------------------------+------------------+
7.
8.
| 1 | system user |
| NULL | Connect |
232 | Has read all relay log; waiting for the slave I/O
thread to update it | NULL
|
9.
10. | 2 | system user |
| NULL
232 | Waiting for master to send
event
NULL
|
| Connect |
|
11.
12. | 39 | root
| localhost | mysql | Query
0 |
NULL
| show processlist |
13.
14. +----+-------------+-----------+-------+--------+-----+----------------------------------------------------------------------+------------------+
15.
16.
You can see the SQL thread that gets data from Master (in the
above output is the thread with Id 2) and the SQL thread that
executes the statements on Slave (in the output is the thread
with Id 1).
17.
19.
+----------------------------+-------+
20.
21.
| Variable_name
| Value |
22.
23.
+----------------------------+-------+
24.
25.
| Slave_open_temp_tables
| 0
| Slave_retried_transactions | 0
| Slave_running
26.
27.
28.
29.
| ON
30.
31.
+----------------------------+-------+
32.
3 rows in set (0.00 sec)
Conclusion
That was our story on how, more or less, we have implemented
MySQL replication for our Fraudpointer application. The steps may not
apply exactly to your particular case, but they can still give you a kick
start and show you the way to implement replication the way it should
work on your configuration.
Your comments are more than welcome. We want them. We need to
improve this process and your feedback is absolutely valuable to us.
mysql -u root -p
Fixing the problem is actually quite easy. We tell the slave to simply skip the
invalid SQL query:
This tells the slave to skip one query (which is the invalid one that caused the
replication to stop). If you'd like to skip two queries, you'd use SET GLOBAL
SQL_SLAVE_SKIP_COUNTER = 2; instead and so on.
That's it already. Now we can start the slave again...
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition:
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed:
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:
1 row in set (0.00 sec)
0
0
447560366
225644062
None
0
No
mysql>
As you see, both Slave_IO_Running and Slave_SQL_Running are set
to Yes now.
Now leave the MySQL shell...
mysql> quit;
SQL thread initialized, starting replication in log 'mysqlbin.001079' at position 203015142, relay log '/var/lib/mysql/slaverelay.000130' position: 100125935
server1:/home/admin#
The last line says that replication has started again, and if you see no errors
after that line, everything is ok.
3 Links
MySQL: http://www.mysql.com
view as pdf |
12 Comment(s)
Add comment
Name *
Email *
p
Submit comment
Comments
From: Perry Whelan
Reply
I'm managing an infrastructure with a number of databases who (for codified
reasons that I cannot influence) suffer from this situation often. So, I've written
a cron script to manage the situation.
Does anyone see any foreseeable issues with this logic (see below)?
#!/bin/bash
## Tool to unstick MySQL Replicators.
## Set to run from cron once a minute.
From: Anonymous
Reply
while [ ! "`mysql -uroot -Be 'SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
start slave;'`" ]
do
echo "Skipped one Error"
sleep 1
done ; echo "All set"
From: Anonymous
Reply
True, but, sometimes the slave will try to execute things that don't apply like a
"drop trigger" statement for a trigger that doesn't ever exist because the slave
is only replicating specific tables.
From: Richard
Reply
Bear in mind that any time you have a query which *did* successfully execute
on the master and is skipped on the slave and you use a
SQL_SLAVE_SKIP_COUNTER method to "fix" the problem, your master and
slave are now no longer in sync. Yes, this is sometimes necessary, but if it is
a recurring issue, then the problems go much deeper than merely broken
replication.
From: Anonymous
Reply
Indeed. And if you skip a query to 'fix' the replication, you run the very serious
risk that the replication will become even more out of sync further down the
line. This isn't fixing, it's just brushing the problem under the carpet and hoping
it goes away. If you must skip a query, look at the query first, and be sure its
absence won't cause future queries to fail
From: Anonymous
Reply
noted that this is not the proper "fix" for the problem, but we are missing your
proposed solution
From: sureshkumar
Reply
From: Farshid
Reply
Thank you. I got replication working without having to rebuild in middle of night
remotely!
From: Ramanath
Reply
What i have to do if Slave_IO_Running: No and Seconds_Behind_Master: NULL.
Please help me.I am waiting for your response.
http://www.howtoforge.com/how-to-repair-mysql-replication.. In this link you
have mentioned the solution for Slave_SQL_Running: No.Please suggest me for
Slave_IO_Running: No and Seconds_Behind_Master: NULL
From: Some Guy
Reply
Thanks man, saved me today :)
From: Eternal
Reply
Thanks, pretty useful article.
Server ID. On the master and each slave, you must use the server-id option to establish
a unique replication ID in the range from 1 to 232 1. Unique means that each ID must
be different from every other ID in use by any other replication master or slave.
Example my.cnf file:
[mysqld]
server-id=3
server starts. Replication-related system variables are discussed later in this section.
--abort-slave-event-count
Command-Line Format
Permitted Values
--abort-slave-event-count=#
Type
integer
Default
Min Value
When this option is set to some positive integer value other than 0 (the default) it
affects replication behavior as follows: After the slave SQL thread has
started, value log events are permitted to be executed; after that, the slave SQL
thread does not receive any more events, just as if the network connection from the
master were cut. The slave thread continues to run, and the output from SHOW
SLAVE STATUS displays Yes in both theSlave_IO_Running and
the Slave_SQL_Running columns, but no further events are read from the relay
log.
This option is used internally by the MySQL test suite for replication testing and
debugging. It is not intended for use in a production setting.
--disconnect-slave-event-count
Command-Line Format
Permitted Values
--disconnect-slave-event-count=#
Type
integer
Default
This option is used internally by the MySQL test suite for replication testing and
debugging.
--log-slave-updates
Command-Line Format
System Variable
Permitted Values
--log-slave-updates
Name
log_slave_updates
Variable Scope
Global
Dynamic Variable
No
Type
boolean
Default
OFF
Normally, a slave does not log to its own binary log any updates that are received
from a master server. This option tells the slave to log the updates performed by its
SQL thread to its own binary log. For this option to have any effect, the slave must
also be started with the --log-bin option to enable binary logging. Prior to
MySQL 5.5, the server would not start when using the --log-slaveupdates option without also starting the server with the --log-bin option, and
would fail with an error; in MySQL 5.5, only a warning is generated. (Bug
A -> B -> C
Here, A serves as the master for the slave B, and B serves as the master for the
slave C. For this to work, B must be both a master and a slave. You must start
both A and B with --log-bin to enable binary logging, and B with the --logslave-updates option so that updates received from A are logged by B to its
binary log.
--log-slow-slave-statements
Command-Line Format
Permitted Values
--log-slow-slave-statements
Type
boolean
Default
OFF
When the slow query log is enabled, this option enables logging for queries that
have taken more thanlong_query_time seconds to execute on the slave.
--log-warnings[=level]
Command-Line Format
System Variable
--log-warnings[=#]
Name
log_warnings
Variable Scope
Global, Session
integer
Default
Min Value
Max Value
4294967295
integer
Default
Min Value
Max Value
18446744073709547520
Type
integer
Default
Min Value
18446744073709551615
This option causes a server to print more messages to the error log about what it is
doing. With respect to replication, the server generates warnings that it succeeded
in reconnecting after a network/connection failure, and informs you as to how each
slave thread started. This option is enabled (1) by default; to disable it, use --logwarnings=0. If the value is greater than 1, aborted connections are written to the
error log, and access-denied errors for new connection attempts are written.
See Section B.5.2.11, Communication Errors and Aborted Connections.
Note that the effects of this option are not limited to replication. It produces
warnings across a spectrum of server activities.
--master-info-file=file_name
Command-Line Format
Permitted Values
--master-info-file=file_name
Type
file name
Default
master.info
The name to use for the file in which the slave records information about the
master. The default name ismaster.info in the data directory. For information
about the format of this file, see Section 17.2.2.2, Slave Status Logs.
--master-retry-count=count
Command-Line Format
--master-retry-count=#
Type
integer
Default
86400
Min Value
Max Value
4294967295
Type
integer
Default
86400
Min Value
Max Value
18446744073709551615
The number of times that the slave tries to connect to the master before giving up.
Reconnects are attempted at intervals set by the MASTER_CONNECT_RETRY option
of the CHANGE MASTER TO statement (default 60). Reconnects are triggered when
data reads by the slave time out according to the --slave-net-timeout option.
The default value is 86400. A value of 0 means infinite; the slave attempts to
connect forever.
slave-max-allowed-packet=bytes
Introduced
5.5.26
Command-Line Format
--slave-max-allowed-packet=#
Permitted Values
Type
integer
Default
1073741824
Min Value
1024
Max Value
1073741824
In MySQL 5.5.26 and later, this option sets the maximum packet size in bytes for
the slave SQL and I/O threads, so that large updates using row-based replication
do not cause replication to fail because an update
exceededmax_allowed_packet. (Bug #12400221, Bug #60926)
The maximum (and default) value is 1073741824 (1 GB); the minimum is 1024.
--max-relay-log-size=size
Command-Line Format
System Variable
Permitted Values
--max_relay_log_size=#
Name
max_relay_log_size
Variable Scope
Global
Dynamic Variable
Yes
Type
integer
Default
Min Value
Max Value
1073741824
The size at which the server rotates relay log files automatically. If this value is
nonzero, the relay log is rotated automatically when its size exceeds this value. If
this value is zero (the default), the size at which relay log rotation occurs is
determined by the value of max_binlog_size. For more information,
see Section 17.2.2.1, The Slave Relay Log.
--relay-log=file_name
Command-Line Format
System Variable
--relay-log=file_name
Name
relay_log
Variable Scope
Global
Dynamic Variable
No
Permitted Values
Type
file name
The base name for the relay log. The default base name is host_name-relaybin. The server writes the file in the data directory unless the base name is given
with a leading absolute path name to specify a different directory. The server
creates relay log files in sequence by adding a numeric suffix to the base name.
Due to the manner in which MySQL parses server options, if you specify this
option, you must supply a value; the default base name is used only if the option is
not actually specified. If you use the --relay-log option without specifying a
value, unexpected behavior is likely to result; this behavior depends on the other
options used, the order in which they are specified, and whether they are specified
on the command line or in an option file. For more information about how MySQL
handles server options, see Section 4.2.3, Specifying Program Options.
If you specify this option, the value specified is also used as the base name for the
relay log index file. You can override this behavior by specifying a different relay log
index file base name using the --relay-log-indexoption.
Starting with MySQL 5.5.20, when the server reads an entry from the index file, it
checks whether the entry contains a relative path. If it does, the relative part of the
path in replaced with the absolute path set using the --relay-log option. An
absolute path remains unchanged; in such a case, the index must be edited
manually to enable the new path or paths to be used. Prior to MySQL 5.5.20,
manual intervention was required whenever relocating the binary log or relay log
files. (Bug #11745230, Bug #12133)
You may find the --relay-log option useful in performing the following tasks:
o
If you need to put the relay logs in some area other than the data directory
because your relay logs tend to be very large and you do not want to
decrease max_relay_log_size.
--relay-log-index=file_name
Command-Line Format
--relay-log-index=file_name
Name
relay_log_index
Variable Scope
Global
System Variable
Dynamic Variable
No
Permitted Values
Type
file name
The name to use for the relay log index file. The default name
is host_name-relay-bin.index in the data directory,
where host_name is the name of the slave server.
Due to the manner in which MySQL parses server options, if you specify
this option, you must supply a value; the default base name is used only if
the option is not actually specified. If you use the --relay-logindex option without specifying a value, unexpected behavior is likely to
result; this behavior depends on the other options used, the order in which
they are specified, and whether they are specified on the command line or
in an option file. For more information about how MySQL handles server
options, see Section 4.2.3, Specifying Program Options.
If you specify this option, the value specified is also used as the base name
for the relay logs. You can override this behavior by specifying a different
relay log file base name using the --relay-log option.
--relay-log-info-file=file_name
Command-Line Format
Permitted Values
--relay-log-info-file=file_name
Type
file name
Default
relay-log.info
The name to use for the file in which the slave records information about
the relay logs. The default name isrelay-log.info in the data directory.
For information about the format of this file, see Section 17.2.2.2, Slave
Status Logs.
--relay-log-purge={0|1}
Command-Line Format
System Variable
Permitted Values
--relay_log_purge
Name
relay_log_purge
Variable Scope
Global
Dynamic Variable
Yes
Type
boolean
Default
TRUE
--relay-log-recovery={0|1}
Command-Line Format
Permitted Values
--relay-log-recovery
Type
boolean
Default
FALSE
--relay-log-space-limit=size
Command-Line Format
--relay_log_space_limit=#
System Variable
Name
relay_log_space_limit
Variable Scope
Global
Dynamic
No
Variable
Type
integer
Default
Min Value
Max Value
4294967295
Type
integer
Default
Min Value
Max Value
18446744073709547520
Type
integer
Default
Min Value
Max Value
18446744073709551615
This option places an upper limit on the total size in bytes of all relay logs
on the slave. A value of 0 means no limit. This is useful for a slave
server host that has limited disk space. When the limit is reached, the I/O
thread stops reading binary log events from the master server until the SQL
thread has caught up and deleted some unused relay logs. Note that this
limit is not absolute: There are cases where the SQL thread needs more
events before it can delete relay logs. In that case, the I/O thread exceeds
the limit until it becomes possible for the SQL thread to delete some relay
logs because not doing so would cause a deadlock. You should not set -relay-log-space-limit to less than twice the value of --max-relaylog-size (or --max-binlog-size if --max-relay-log-size is 0). In
that case, there is a chance that the I/O thread waits for free space
because --relay-log-space-limit is exceeded, but the SQL thread
has no relay log to purge and is unable to satisfy the I/O thread. This forces
the I/O thread to ignore --relay-log-space-limit temporarily.
--replicate-do-db=db_name
Command-Line Format
--replicate-do-db=name
Permitted Values
Type
string
The effects of this option depend on whether statement-based or rowbased replication is in use.
Warning
An example of what does not work as you might expect when using
statement-based replication: If the slave is started with --replicate-dodb=sales and you issue the following statements on the master,
USE prices;
UPDATE sales.january SET amount=amount+1000;
The main reason for this check just the default database behavior is
that it is difficult from the statement alone to know whether it should be
replicated (for example, if you are using multiple-table DELETE statements
or multiple-table UPDATE statements that act across multiple databases). It
is also faster to check only the default database rather than all databases if
there is no need.
current database has no effect on this. Suppose that the slave is started
with --replicate-do-db=sales and row-based replication is in effect,
and then the following statements are run on the master:
USE prices;
UPDATE sales.february SET amount=amount+100;
USE prices;
UPDATE prices.march SET amount=amount-25;
USE db1;
UPDATE db1.table1 SET col1 = 10, db2.table2 SET col2 = 20;
If you are using statement-based replication, then both tables are updated
on the slave. However, when using row-based replication, only table1 is
affected on the slave; since table2 is in a different database, table2 on
the slave is not changed by the UPDATE. Now suppose that, instead of
the USE db1 statement, a USE db4statement had been used:
USE db4;
UPDATE db1.table1 SET col1 = 10, db2.table2 SET col2 = 20;
In this case, the UPDATE statement would have no effect on the slave when
using statement-based replication. However, if you are using row-based
replication, the UPDATE would change table1 on the slave, but not table2
in other words, only tables in the database named by --replicate-do-
db are changed, and the choice of default database has no effect on this
behavior.
If you need cross-database updates to work, use --replicate-wild-dotable=db_name.% instead. SeeSection 17.2.3, How Servers Evaluate
Note
This option affects replication in the same manner that --binlog-dodb affects binary logging, and the effects of the replication format on
--replicate-ignore-db=db_name
Command-Line Format
--replicate-ignore-db=name
Permitted Values
Type
string
Row-based replication. Tells the slave SQL thread not to update any
tables in the database db_name. The default database has no effect.
the master:
USE prices;
UPDATE sales.january SET amount=amount+1000;
The UPDATE statement is replicated in such a case because -replicate-ignore-db applies only to the default database (determined
To specify more than one database to ignore, use this option multiple
times, once for each database. Because database names can contain
commas, if you supply a comma separated list then the list will be treated
as the name of a single database.
You should not use this option if you are using cross-database updates and
you do not want these updates to be replicated. See Section 17.2.3, How
Servers Evaluate Replication Filtering Rules.
If you need cross-database updates to work, use --replicate-wildignore-table=db_name.% instead. SeeSection 17.2.3, How Servers
Note
This option affects replication in the same manner that --binlogignore-db affects binary logging, and the effects of the replication format
--replicate-do-table=db_name.tbl_name
Command-Line Format
--replicate-do-table=name
Permitted Values
Type
string
Tells the slave SQL thread to restrict replication to the specified table. To
specify more than one table, use this option multiple times, once for each
table. This works for both cross-database updates and default database
updates, in contrast to --replicate-do-db. See Section 17.2.3, How
Servers Evaluate Replication Filtering Rules.
This option affects only statements that apply to tables. It does not affect
statements that apply only to other database objects, such as stored
routines. To filter statements operating on stored routines, use one or more
of the --replicate-*-db options.
--replicate-ignore-table=db_name.tbl_name
Command-Line Format
--replicate-ignore-table=name
Permitted Values
Type
string
Tells the slave SQL thread not to replicate any statement that updates the
specified table, even if any other tables might be updated by the same
statement. To specify more than one table to ignore, use this option
multiple times, once for each table. This works for cross-database updates,
in contrast to --replicate-ignore-db. SeeSection 17.2.3, How Servers
Evaluate Replication Filtering Rules.
This option affects only statements that apply to tables. It does not affect
statements that apply only to other database objects, such as stored
routines. To filter statements operating on stored routines, use one or more
of the --replicate-*-db options.
--replicate-rewrite-db=from_name->to_name
Command-Line Format
--replicate-rewrite-db=old_name->new_name
Permitted Values
Type
string
Tells the slave to translate the default database (that is, the one selected
by USE) to to_name if it was from_nameon the master. Only statements
involving tables are affected (not statements such as CREATE
Statements in which table names are qualified with database names when
using this option do not work with table-level replication filtering options
such as --replicate-do-table. Suppose we have a database
named aon the master, one named b on the slave, each containing a
table t, and have started the master with --replicate-rewrite-db='a>b'. At a later point in time, we execute DELETE FROM a.t. In this case,
table t in database b.
o
so is ignored.
o
--replicate-do-table=*.t is handled identically to --replicatedo-table=a.t, and thus does not work, either.
b.
--replicate-same-server-id
Command-Line Format
Permitted Values
--replicate-same-server-id
Type
boolean
Default
FALSE
c. To be used on slave servers. Usually you should use the default setting of
0, to prevent infinite loops caused by circular replication. If set to 1, the
slave does not skip events having its own server ID. Normally, this is useful
only in rare configurations. Cannot be set to 1 if --log-slave-updates is
used. By default, the slave I/O thread does not write binary log events to
the relay log if they have the slave's server ID (this optimization helps save
disk usage). If you want to use --replicate-same-server-id, be sure
to start the slave with this option before you make the slave read its own
events that you want the slave SQL thread to execute.
d.
--replicate-wild-do-table=db_name.tbl_name
Command-Line Format
--replicate-wild-do-table=name
Permitted Values
Type
string
e. Tells the slave thread to restrict replication to statements where any of the
updated tables match the specified database and table name patterns.
Patterns can contain the % and _ wildcard characters, which have the
same meaning as for the LIKE pattern-matching operator. To specify more
than one table, use this option multiple times, once for each table. This
works for cross-database updates. See Section 17.2.3, How Servers
Evaluate Replication Filtering Rules.
f.
This option applies to tables, views, and triggers. It does not apply to stored
procedures and functions, or events. To filter statements operating on the
latter objects, use one or more of the --replicate-*-db options.
i.
might need to double the backslashes or quote the option value, depending
on your command interpreter. For example, with the bash shell, you would
need to type --replicate-wild-do-table=my\\_own\\%db.
j.
--replicate-wild-ignore-table=db_name.tbl_name
Command-Line Format
--replicate-wild-ignore-table=name
Permitted Values
Type
string
k. Tells the slave thread not to replicate a statement where any table matches
the given wildcard pattern. To specify more than one table to ignore, use
this option multiple times, once for each table. This works for crossdatabase updates. See Section 17.2.3, How Servers Evaluate Replication
Filtering Rules.
l.
m. For information about how matching works, see the description of the -replicate-wild-do-table option. The rules for including literal wildcard
characters in the option value are the same as for --replicate-wildignore-table as well.
n.
--report-host=host_name
Command-Line Format
--report-host=host_name
System Variable
Name
report_host
Variable Scope
Global
Dynamic Variable
No
Permitted Values
Type
string
slave to register itself with the master. Note that it is not sufficient for the
master to simply read the IP address of the slave from the TCP/IP socket
after the slave connects. Due to NAT and other routing issues, that IP may
not be valid for connecting to the slave from the master or other hosts.
p.
--report-password=password
Command-Line Format
--report-password=name
Name
report_password
Variable Scope
Global
System Variable
Dynamic Variable
No
Permitted Values
Type
string
given.
r.
Although the name of this option might imply otherwise, --reportpassword is not connected to the MySQL user privilege system and so is
not necessarily (or even likely to be) the same as the password for the
MySQL replication user account.
s.
--report-port=slave_port_num
Command-Line Format
--report-port=#
System Variable
Name
report_port
Variable Scope
Global
t.
Dynamic Variable
No
Type
integer
Default
3306
Min Value
Max Value
65535
Type
integer
Default
Min Value
Max Value
65535
The TCP/IP port number for connecting to the slave, to be reported to the
master during slave registration. Set this only if the slave is listening on a
nondefault port or if you have a special tunnel from the master or other
clients to the slave. If you are not sure, do not use this option.
u. Prior to MySQL 5.5.23, the default value for this option was 3306. In
MySQL 5.5.23 and later, the value shown is the port number actually used
by the slave (Bug #13333431). This change also affects the default value
displayed by SHOW SLAVE HOSTS.
v.
--report-user=user_name
Command-Line Format
--report-user=name
Name
report_user
Variable Scope
Global
System Variable
Dynamic Variable
No
Permitted Values
Type
string
w. The account user name of the slave to be reported to the master during
slave registration. This value appears in the output of SHOW SLAVE
HOSTS on the master server if the --show-slave-auth-info option is
given.
x. Although the name of this option might imply otherwise, --report-user is
not connected to the MySQL user privilege system and so is not
necessarily (or even likely to be) the same as the name of the MySQL
replication user account.
y.
--show-slave-auth-info
Command-Line Format
--show-slave-auth-info
Permitted Values
Type
boolean
Default
FALSE
z. Display slave user names and passwords in the output of SHOW SLAVE
HOSTS on the master server for slaves started with the --reportuser and --report-password options.
aa. --skip-slave-start
Command-Line Format
--skip-slave-start
Permitted Values
Type
boolean
Default
FALSE
ab. Tells the slave server not to start the slave threads when the server starts.
To start the threads later, use a START SLAVE statement.
ac. --slave_compressed_protocol={0|1}
Command-Line Format
--slave_compressed_protocol
System Variable
Name
slave_compressed_protocol
Variable Scope
Global
Permitted Values
Dynamic Variable
Yes
Type
boolean
Default
OFF
ad. If this option is set to 1, use compression for the slave/master protocol if
both the slave and the master support it. The default is 0 (no compression).
ae. --slave-load-tmpdir=dir_name
Command-Line Format
System Variable
Permitted Values
--slave-load-tmpdir=dir_name
Name
slave_load_tmpdir
Variable Scope
Global
Dynamic Variable
No
Type
directory name
Default
/tmp
af. The name of the directory where the slave creates temporary files. This
option is by default equal to the value of the tmpdir system variable. When
the slave SQL thread replicates a LOAD DATA INFILE statement, it
extracts the file to be loaded from the relay log into temporary files, and
then loads these into the table. If the file loaded on the master is huge, the
temporary files on the slave are huge, too. Therefore, it might be advisable
to use this option to tell the slave to put temporary files in a directory
located in some file system that has a lot of available space. In that case,
the relay logs are huge as well, so you might also want to use the -relay-log option to place the relay logs in that file system.
ag. The directory specified by this option should be located in a disk-based file
system (not a memory-based file system) because the temporary files used
to replicate LOAD DATA INFILE must survive machine restarts. The
directory also should not be one that is cleared by the operating system
during the system startup process.
ah. --slave-net-timeout=seconds
Command-Line Format
System Variable
Permitted Values
--slave-net-timeout=#
Name
slave_net_timeout
Variable Scope
Global
Dynamic Variable
Yes
Type
integer
Default
3600
Min Value
ai. The number of seconds to wait for more data from the master before the
slave considers the connection broken, aborts the read, and tries to
reconnect. The first retry occurs immediately after the timeout. The interval
between retries is controlled by the MASTER_CONNECT_RETRY option for
the CHANGE MASTER TO statement, and the number of reconnection
attempts is limited by the --master-retry-count option. The default is
3600 seconds (one hour).
aj. --slave-skip-errors=[err_code1,err_code2,...|all]
(MySQL Cluster NDB 7.2.6 and later:) --slave-skiperrors=[err_code1,err_code2,...|all|ddl_exist_errors]
Command-Line Format
--slave-skip-errors=name
Name
slave_skip_errors
Variable Scope
Global
System Variable
Dynamic Variable
No
Permitted Values
Type
string
Default
OFF
Valid Values
OFF
[list of error codes]
all
Type
string
Default
OFF
OFF
[list of error codes]
all
Permitted Values
Valid Values
ddl_exist_errors
Type
string
Default
OFF
OFF
[list of error codes]
all
Valid Values
ddl_exist_errors
Normally, replication stops when an error occurs on the slave. This gives you the
opportunity to resolve the inconsistency in the data manually. This option tells the slave
SQL thread to continue replication when a statement returns any of the errors listed in
the option value.
Do not use this option unless you fully understand why you are getting errors. If there
are no bugs in your replication setup and client programs, and no bugs in MySQL itself,
an error that stops replication should never occur. Indiscriminate use of this option
results in slaves becoming hopelessly out of synchrony with the master, with you having
no idea why this has occurred.
For error codes, you should use the numbers provided by the error message in your
slave error log and in the output of SHOW SLAVE STATUS. Appendix B, Errors, Error
Codes, and Common Problems, lists server error codes.
You can also (but should not) use the very nonrecommended value of all to cause the
slave to ignore all error messages and keeps going regardless of what happens.
Needless to say, if you use all, there are no guarantees regarding the integrity of your
data. Please do not complain (or file bug reports) in this case if the slave's data is not
anywhere close to what it is on the master. You have been warned.
MySQL Cluster NDB 7.2.6 and later support an additional shorthand
value ddl_exist_errors for use with the enhanced failover mechanism which is
implemented beginning with that version of MySQL Cluster. This value is equivalent to
the error code list 1007,1008,1050,1051,1054,1060,1061,1068,1094,1146. This
value is not supported by the mysqld binary included with the MySQL Server 5.5
distribution. (Bug #11762277, Bug #54854) For more information, see Section 18.6.8,
Implementing Failover with MySQL Cluster Replication.
Examples:
--slave-skip-errors=1062,1053
--slave-skip-errors=all
--slave-skip-errors=ddl_exist_errors
The following options are removed in MySQL 5.5. If you attempt to start mysqld with any of
these options in MySQL 5.5, the server aborts with an unknown variable error. To set
the replication parameters formerly associated with these options, you must use
the CHANGE MASTER TO ... statement (see Section 13.4.2.1, CHANGE MASTER TO
Syntax).
The options affected are shown in this list:
--master-host
--master-user
--master-password
--master-port
--master-connect-retry
--master-ssl
--master-ssl-ca
--master-ssl-capath
--master-ssl-cert
--master-ssl-cipher
--master-ssl-key
init_slave
Command-Line Format
--init-slave=name
Name
init_slave
Variable Scope
Global
System Variable
Dynamic Variable
Yes
Permitted Values
Type
string
Note
relay_log
Command-Line Format
--relay-log=file_name
System Variable
Name
relay_log
Variable Scope
Global
Permitted Values
relay_log_index
Command-Line Format
System Variable
Permitted Values
Dynamic Variable
No
Type
file name
--relay-log-index
Name
relay_log_index
Variable Scope
Global
Dynamic Variable
No
Type
file name
Default
*host_name*-relay-bin.index
The name of the relay log index file. The default name is host_name-relaybin.index in the data directory, where host_name is the name of the slave
server.
relay_log_info_file
Command-Line Format
System Variable
Permitted Values
--relay-log-info-file=file_name
Name
relay_log_info_file
Variable Scope
Global
Dynamic Variable
No
Type
file name
Default
relay-log.info
The name of the file in which the slave records information about the relay logs.
The default name is relay-log.info in the data directory.
relay_log_recovery
Command-Line Format
System Variable
Permitted Values
--relay-log-recovery
Name
relay_log_recovery
Variable Scope
Global
Dynamic Variable
Yes
Type
boolean
Default
FALSE
Enables automatic relay log recovery immediately following server startup, which
means that the replication slave discards all unprocessed relay logs and retrieves
them from the replication master. This should be used following a crash on the
replication slave to ensure that no possibly corrupted relay logs are processed. The
default value is 0 (disabled). This global variable can be changed dynamically, or
by starting the slave with the --relay-log-recovery option.
rpl_recovery_rank
slave_compressed_protocol
Command-Line Format
System Variable
Permitted Values
--slave_compressed_protocol
Name
slave_compressed_protocol
Variable Scope
Global
Dynamic Variable
Yes
Type
boolean
Default
OFF
Whether to use compression of the slave/master protocol if both the slave and the
master support it.
slave_exec_mode
Command-Line Format
System Variable
--slave-exec-mode=mode
Name
slave_exec_mode
Variable Scope
Global
Dynamic Variable
Yes
Type
enumeration
Default
STRICT (ALL)
Default
IDEMPOTENT (NDB)
IDEMPOTENT
Permitted Values
Valid Values
STRICT
This mode is needed for multi-master replication, circular replication, and some
other special replication scenarios for MySQL Cluster Replication.
(See Section 18.6.10, MySQL Cluster Replication: Multi-Master and Circular
Replication, and Section 18.6.11, MySQL Cluster Replication Conflict
Resolution, for more information.) Themysqld supplied with MySQL Cluster
ignores any value explicitly set for slave_exec_mode, and always treats it
as IDEMPOTENT.
In MySQL Server 5.5, STRICT mode is the default value. This should not be
changed; currently, IDEMPOTENTmode is supported only by NDB.
slave_load_tmpdir
Command-Line Format
--slave-load-tmpdir=dir_name
System Variable
Name
slave_load_tmpdir
Variable Scope
Global
Permitted Values
Dynamic Variable
No
Type
directory name
Default
/tmp
The name of the directory where the slave creates temporary files for
replicating LOAD DATA INFILE statements.
slave_max_allowed_packet
Introduced
System Variable
Permitted Values
5.5.26
Name
slave_max_allowed_packet
Variable Scope
Global
Dynamic Variable
Yes
Type
integer
Default
1073741824
Min Value
1024
Max Value
1073741824
In MySQL 5.5.26 and later, this variable sets the maximum packet size for the slave
SQL and I/O threads, so that large updates using row-based replication do not
cause replication to fail because an update exceededmax_allowed_packet.
This global variable always has a value that is a positive integer multiple of 1024; if
you set it to some value that is not, the value is rounded down to the next highest
multiple of 1024 for it is stored or used; settingslave_max_allowed_packet to 0
causes 1024 to be used. (A truncation warning is issued in all such cases.) The
default and maximum value is 1073741824 (1 GB); the minimum is 1024.
slave_net_timeout
Command-Line Format
System Variable
Permitted Values
--slave-net-timeout=#
Name
slave_net_timeout
Variable Scope
Global
Dynamic Variable
Yes
Type
integer
Default
3600
Min Value
The number of seconds to wait for more data from a master/slave connection
before aborting the read.
slave_skip_errors
Command-Line Format
System Variable
--slave-skip-errors=name
Name
slave_skip_errors
Variable Scope
Global
Dynamic Variable
No
Type
string
Default
OFF
OFF
[list of error codes]
Permitted Values
Valid Values
all
Type
string
Default
OFF
OFF
[list of error codes]
all
Permitted Values
Valid Values
ddl_exist_errors
Type
string
Default
OFF
OFF
[list of error codes]
all
Valid Values
ddl_exist_errors
Normally, replication stops when an error occurs on the slave. This gives you the
opportunity to resolve the inconsistency in the data manually. This variable tells the
slave SQL thread to continue replication when a statement returns any of the errors
listed in the variable value.
slave_transaction_retries
Command-Line Format
--slave_transaction_retries=#
Name
slave_transaction_retries
Variable Scope
Global
Dynamic
System Variable
Variable
Yes
Type
integer
Default
10
Min Value
Max Value
4294967295
Type
integer
Default
10
Min Value
5.5.2)
Max Value
18446744073709547520
Type
integer
Default
10
5.5.3)
Min Value
Max Value
18446744073709551615
slave_type_conversions
Introduced
5.5.3
Command-Line Format
--slave_type_conversions=set
System Variable
Name
slave_type_conversions
Variable Scope
Global
Dynamic Variable
No
Type
set
Default
ALL_LOSSY
Permitted Values
Valid Values
ALL_NON_LOSSY
Controls the type conversion mode in effect on the slave when using row-based
replication, including MySQL Cluster Replication. Its value is a comma-delimited
set of zero or more elements from the list: ALL_LOSSY,ALL_NON_LOSSY. Set this
variable to an empty string to disallow type conversions between the master and
the slave. Changes require a restart of the slave to take effect.
sql_slave_skip_counter
Name
sql_slave_skip_counter
Variable Scope
Global
System Variable
Dynamic Variable
Yes
Permitted Values
Type
integer
The number of events from the master that a slave server should skip.
Important
If skipping the number of events specified by setting this variable would cause the
slave to begin in the middle of an event group, the slave continues to skip until it
finds the beginning of the next event group and begins from that point. For more
information, see Section 13.4.2.4, SET GLOBAL sql_slave_skip_counter Syntax.
sync_master_info
Command-Line Format
System Variable
--sync-master-info=#
Name
sync_master_info
Variable Scope
Global
integer
Default
Min Value
Max Value
4294967295
integer
Default
Min Value
Max Value
18446744073709547520
Type
integer
Default
Min Value
18446744073709551615
sync_relay_log
Command-Line Format
System Variable
--sync-relay-log=#
Name
sync_relay_log
Variable Scope
Global
integer
Default
Min Value
Max Value
4294967295
Type
integer
Default
Min Value
18446744073709547520
integer
Default
Min Value
Max Value
18446744073709551615
If the value of this variable is greater than 0, the MySQL server synchronizes its
relay log to disk (usingfdatasync()) after every sync_relay_log events are
written to the relay log.
A value of 1 is the safest choice because in the event of a crash you lose at most
one event from the relay log. However, it is also the slowest choice (unless the disk
has a battery-backed cache, which makes synchronization very fast).
sync_relay_log_info
Command-Line Format
System Variable
--sync-relay-log-info=#
Name
sync_relay_log_info
Variable Scope
Global
integer
Default
Min Value
Max Value
4294967295
Type
integer
Default
Min Value
18446744073709547520
Type
integer
Default
Min Value
18446744073709551615
User Comments
Posted by Charles Darwin on February 17 2012 3:50pm
[Delete] [Edit]
I had a problem when I just changed the server name. I got the known error:
[ERROR] Failed to open the relay log './zeus-relay-bin.000009' (relay_log_pos 251)
120216 17:11:31 [ERROR] Could not find target log during relay log initialization
When I changed the name from zeus to perseo.
My solution was to delete the files with old server name, I mean zeus-relay-* and delete relaylog.info.
It just worked for me.
Posted by andrew lorien on April 28 2014 1:04am
[Delete] [Edit]
MySQL Enterprise Monitor (supported by a few tech blogs) has an "Slave Detection Of Network
Outages Too High" advisor, which suggests that you "decrease slave_net_timeout so the
outages -- and associated connection retries -- are detected and resolved faster. The default for
this parameter is 3600 seconds (1 hour), which is too high for many environments."
However, in our reasonably high traffic environment (each master has three slaves on a very
low-latency network, a 1G compressed binlog takes about a week to rotate), setting this value to
30 seconds caused recurring replication problems. The slaves started and stopped replicating
with the message "Waiting to reconnect after a failed master event read." stop slave - start slave
did not fix them (in fact we believe it made the problem worse). Removing the slave_net_timeout
value from mysql.ini fixed replication immediately.
Add your ow n comment