MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rpl_reset.inc
1 # ==== Purpose ====
2 #
3 # Reset all replication servers to a clean state:
4 #
5 # - sync all slaves,
6 # - stop all slaves (STOP SLAVE),
7 # - remove all binlogs and relay logs (RESET MASTER and RESET SLAVE),
8 # - start all slaves again (START SLAVE).
9 #
10 # It does not execute CHANGE MASTER, so the replication topology is
11 # kept intact.
12 #
13 #
14 # ==== Usage ====
15 #
16 # [--let $rpl_only_running_threads= 1]
17 # [--let $rpl_debug= 1]
18 # [--let $slave_timeout= NUMBER]
19 # --source include/rpl_end.inc
20 #
21 # Parameters:
22 # $rpl_only_running_threads
23 # If one or both of the IO and SQL threads is stopped, sync and
24 # stop only the threads that are running. See
25 # include/rpl_sync.inc and include/stop_slave.inc for details.
26 #
27 # $rpl_debug
28 # See include/rpl_init.inc
29 #
30 # $rpl_no_start_slave
31 # Don't execute START SLAVE.
32 #
33 # $slave_timeout
34 # Set the timeout when waiting for slave threads to stop and
35 # start, respectively. See include/wait_for_slave_param.inc
36 #
37 # Note:
38 # This script will fail if Last_SQL_Error or Last_IO_Error is
39 # nonempty. If you expect an error in the SQL thread, you should
40 # normally do this before you source include/rpl_reset.inc:
41 #
42 # --source include/wait_for_slave_sql_error.inc
43 # --source include/stop_slave_io.inc
44 # RESET SLAVE;
45 
46 --let $include_filename= rpl_reset.inc
47 --source include/begin_include_file.inc
48 
49 
50 if (!$rpl_debug)
51 {
52  --disable_query_log
53 }
54 
55 
56 --source include/rpl_sync.inc
57 
58 
59 if ($rpl_debug)
60 {
61  --echo ---- Stop and reset all servers ----
62 }
63 --let $_rpl_server= $rpl_server_count
64 while ($_rpl_server)
65 {
66  --let $rpl_connection_name= server_$_rpl_server
67  --source include/rpl_connection.inc
68 
69  # Check if this server is configured to have a master
70  if (`SELECT SUBSTRING('$rpl_master_list', 1 + ($_rpl_server - 1) * $rpl_server_count_length, $rpl_server_count_length) != ''`)
71  {
72  --source include/stop_slave.inc
73  RESET SLAVE;
74  }
75  RESET MASTER;
76  --dec $_rpl_server
77 }
78 
79 
80 if (!$rpl_no_start_slave)
81 {
82  --source include/rpl_start_slaves.inc
83 }
84 
85 
86 --let $include_filename= rpl_reset.inc
87 --source include/end_include_file.inc