mysql-replication
Contents
Myql replicatoin
Process
- Clean the salve db
1
2
3
4DROP_DB_LIST=`mysql -Nse "SET group_concat_max_len = 81920; SELECT GROUP_CONCAT(SCHEMA_NAME SEPARATOR ';\nDROP DATABASE ') FROM information_schema.SCHEMATA WHERE SCHEMA_NAME NOT IN ('mysql','information_schema','performance_schema','sys');"`
echo -e $DROP_DB_LIST > /tmp/delete.sh
vim /tmp/delete.sh
mysql < /tmp/delete.sh
dump on the 1st slave
1 | DB_LIST=`mysql -Nse "SELECT GROUP_CONCAT(SCHEMA_NAME SEPARATOR ' ') FROM information_schema.SCHEMATA WHERE SCHEMA_NAME NOT IN (' |
restore on the 2nd slave
1 | mysql < restore_file.sql |
common problems
dropping a database with a special character in the databsename
error message:
1 | [root@au3-db-03 mysql]# mysql < /tmp/deletenewnew.sh |
fix by:
1 | mysql> drop database `supd-123`; |