Changes between Version 17 and Version 18 of MySqlReplication
- Timestamp:
- Nov 7, 2014, 10:01:56 AM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
MySqlReplication
v17 v18 174 174 *) Make sure that slave01 and slave02 both run the exact same version of mysql 175 175 176 *) Stop the replicationon slave01177 {{{ 178 mysql@slave01> STOP SLAVE; 176 *) Stop the mysql server on slave01 177 {{{ 178 shell@slave01> mysqladmin -u root -p shutdown now 179 179 }}} 180 180 181 181 *) RSync the contents of /var/lib/mysql on slave01 to /var/lib/mysql.slave01 on slave02 182 182 {{{ 183 shell > rsync -av root@slave01:/var/lib/mysql /var/lib/mysql.slave01183 shell@slave02> rsync -av root@slave01:/var/lib/mysql /var/lib/mysql.slave01 184 184 }}} 185 185 186 186 *) Stop the mysql server on slave02 if it is running, backup /etc/mysql/my.cnf on slave02 and copy /etc/mysql/my.cnf from slave01 there 187 187 {{{ 188 shell > mysqladmin -u root -p shutdown now189 shell > cd /etc/mysql190 shell > mv my.cnf my.cnf.before_rsync191 shell > scp root@slave01:/etc/mysql/my.cnf .188 shell@slave02> mysqladmin -u root -p shutdown now 189 shell@slave02> cd /etc/mysql 190 shell@slave02> mv my.cnf my.cnf.before_rsync 191 shell@slave02> scp root@slave01:/etc/mysql/my.cnf . 192 192 }}} 193 193 194 194 *) Edit /etc/mysql/my.cnf on slave02 and change the server-id. 195 The server-id value has to be a number, I usually use 195 The server-id value has to be a number, I usually use YYYYMMDD<RUNNING NUMBER>, e.g. for the 5th slave install on 2025 Nov 6th (busy day), I would use: 196 {{{ 197 server-id = 2025110605 198 }}} 199 200 *) If you want to be super-safe (and if you have space), make a copy of the rsync on slave02 201 {{{ 202 shell> cp -a /var/lib/mysql.slave01 /var/lib/mysql.slave01.sos 203 }}} 204 205 *) Make mysql.slave01 the new mysql data directory 206 {{{ 207 shell@slave02> mv /var/lib/mysql /var/lib/mysql.before_rsync.delete_me_when_working 208 shell@slave02> mv /var/lib/mysql.slave01 /var/lib/mysql 209 }}} 210 211 *) Start the mysql server on slave02 212 {{{ 213 shell@slave02> /etc/init.d/mysql zap 214 shell@slave02> /etc/init.d/mysql start 215 }}} 216 196 217 = Enjoy... = 197 218 It might be necessary to tell the slave to ignore some updates:
