Mysql的主从配置本来是很简单,捉住几个重点就行了:主锁表——主查指针——导数据——从写入指针——从开启进程 这样一个过程就可以了,可是今天我配置的时候还是遇到一些问题:
1、innodb引擎使用了FLUSH TABLES WITH READ LOCK 之后,再用mysqldump导出数据失败,其实也不算是失败只是停在那里导不出来。
解决办法:
my.cnf没有对innodb引擎做优化,然后我加入以下配置:
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 512M
innodb_data_file_path = ibdata1:256M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0
重启mysql之后问题解决!
注意对my.cnf做修改前应该对数据库做一次全备份,以免造成数据库损坏那就蛋痛了。
2、从数据库启动slave进程后出现错误:
120116 13:20:13 [ERROR] Slave: According to the master's version ('5.0.30-log'), it is probable that master suffers from this bug: http://bugs.mysql.com/bug.php?id=24432 and thus replicating the current binary log event may make the slave's data become different from the master's data. To take no risk, slave refuses to replicate this event and stops. We recommend that all updates be stopped on the master and slave, that the data of both be manually synchronized, that master's binary logs be deleted, that master be upgraded to a version at least equal to '5.0.38'. Then replication can be restarted. Error_code: 1105
造成这个原因是主数据库的版本太低,解决办法:
升级 主数据库版本 或者是 降低从数据库版本
尽量地保证主从数据库的版本是一致的,避免出现不必要的问题!
3、启动slave进程后出现1062错误,这是一个数据冲突错误
解决办法:可以先找出来重复的数据,然后删掉,也可以在my.cnf中加入slave-skip-errors=126,1062 跳过错误
本文转自运维笔记博客51CTO博客,原文链接http://blog.51cto.com/lihuipeng/764827如需转载请自行联系原作者
lihuipeng