summaryrefslogtreecommitdiff
path: root/mysql-test/include/circular_rpl_for_4_hosts_init.inc
blob: ac6654777db8468ed2580af1151d7c5f36ec5553 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#############################################################
#
# Author:  Serge Kozlov <skozlov@mysql.com>
# Date:    03/11/2008
# Purpose: Set up circular replication based on schema 
# A->B->C->D->A
#
# Notes:
# 1. --slave-num=3 must be added to *-master.opt file
# 2. Even the test uses new names for servers but file names 
#    of log files are still old:
#    master_a -> master.[log|err]
#    master_b -> slave.[log|err]
#    master_c -> slave1.[log|err]
#    master_d -> slave2.[log|err]
#
#############################################################
--source include/master-slave.inc

#
# Set up circular ring by schema A->B->C->D->A 
#

--connection slave
STOP SLAVE;
RESET SLAVE;

# master a
--connection master
--disconnect master
connect (master_a,127.0.0.1,root,,test,$MASTER_MYPORT,);
RESET MASTER;
--disable_warnings
STOP SLAVE;
--enable_warnings
RESET SLAVE;
SET auto_increment_increment = 4;
SET auto_increment_offset = 1;
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);

# master b
--connection slave
--disconnect slave
connect (master_b,127.0.0.1,root,,test,$SLAVE_MYPORT,);
RESET MASTER;
RESET SLAVE;
--replace_result $MASTER_MYPORT MASTER_A_PORT $_binlog_file MASTER_A_LOG_FILE
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$MASTER_MYPORT,master_user='root',MASTER_LOG_FILE='$_binlog_file'
SET auto_increment_increment = 4;
SET auto_increment_offset = 2;
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);

# master c
--connection slave1
--disconnect slave1
connect (master_c,127.0.0.1,root,,test,$SLAVE_MYPORT1,);
RESET MASTER;
--disable_warnings
STOP SLAVE;
--enable_warnings
RESET SLAVE;
--replace_result $SLAVE_MYPORT MASTER_B_PORT $_binlog_file MASTER_B_LOG_FILE
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT,master_user='root',MASTER_LOG_FILE='$_binlog_file'
SET auto_increment_increment = 4;
SET auto_increment_offset = 3;
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);

# master d 
connect (master_d,127.0.0.1,root,,test,$SLAVE_MYPORT2,);
RESET MASTER;
--disable_warnings
STOP SLAVE;
--enable_warnings
RESET SLAVE;
--replace_result $SLAVE_MYPORT1 MASTER_C_PORT $_binlog_file MASTER_C_LOG_FILE
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT1,master_user='root',MASTER_LOG_FILE='$_binlog_file'
SET auto_increment_increment = 4;
SET auto_increment_offset = 4;
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);

# master a
--connection master_a
--replace_result $SLAVE_MYPORT2 MASTER_D_PORT $_binlog_file MASTER_D_LOG_FILE
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT2,master_user='root',MASTER_LOG_FILE='$_binlog_file'



# Check server_ids: they should be different
--connection master_a
let $_id_a= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
SHOW VARIABLES LIKE 'auto_increment_%';
--connection master_b
let $_id_b= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
SHOW VARIABLES LIKE 'auto_increment_%';
--connection master_c
let $_id_c= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
SHOW VARIABLES LIKE 'auto_increment_%';
--connection master_d
let $_id_d= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
SHOW VARIABLES LIKE 'auto_increment_%';
--connection master_a
let $_compared_ids= (($_id_a <> $_id_b) AND ($_id_a <> $_id_c) AND ($_id_a <> $_id_d) AND ($_id_b <> $_id_c) AND ($_id_b <> $_id_d) AND ($_id_c <> $_id_d)) AS a;
let $_compared_ids_result= query_get_value(SELECT $_compared_ids, a, 1);
--echo $_compared_ids_result

# Start ring
--connection master_a
connect(slave,127.0.0.1,root,,test,$MASTER_MYPORT);
START SLAVE;
--source include/wait_for_slave_to_start.inc
--disconnect slave

--connection master_b
connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT1);
START SLAVE;
--source include/wait_for_slave_to_start.inc
--disconnect slave

--connection master_c
connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
START SLAVE;
--source include/wait_for_slave_to_start.inc
--disconnect slave

--connection master_d
connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT2);
START SLAVE;
--source include/wait_for_slave_to_start.inc
--disconnect slave