二、备库操作 1、清空备库数据库(保留information_schema、performance_schema、mysql三个库),然后导入主库的数据 确认慢日志有没有关闭:SET GLOBAL slow_query_log=off; 如果没关闭导入时会报错:ERROR 1580 (HY000) at line 3405: You cannot ‘DROP‘ a log table if logging is enabled
mysql -h192.168.1.8 -uroot -proot < /gyj/backup_20150520.mysql
三、主库操作 1、建复制用户 GRANT REPLICATION SLAVE ON *.* TO ‘repl‘@‘%‘ IDENTIFIED BY ‘slavepass‘;
mysql> select * from t1; +------+ | id | +------+ | 1 | | 2 | +------+ 2 rows in set (0.00 sec)
2、备库操作 mysql> select * from t1; +------+ | id | +------+ | 1 | +------+ 1 row in set (0.00 sec)
3、备库上没有同步过去,但我在备库操作flush logs;命令就能同步过来!
4、查主库上的几个参数: mysql> show variables like ‘%autocommit%‘; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | autocommit | ON | +---------------+-------+ 1 row in set (0.00 sec)
mysql> show variables like ‘%innodb_flush_metho%‘; +---------------------+----------+ | Variable_name | Value | +---------------------+----------+ | innodb_flush_method | O_DIRECT | +---------------------+----------+ 1 row in set (0.00 sec)
mysql> show variables like ‘%sync_binlog%‘; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | sync_binlog | 100 | +---------------+-------+ 1 row in set (0.00 sec)
5、找到原因:sync_binlog=100,在主库把参数:sync_binlog设为1即可!!! set global sync_binlog=1; ---最好永久设置改my.cnf配置文件
6、记下常用几个命令 reset master; show master status\G; show binlog events in ‘binlog.000001‘; flush logs;