手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

MySQL复制和性能优化

[日期:2011-05-17] 来源:51cto  作者:lyp0909 [字体:大 中 小]

主服务器:

MySQL> flush tables with read lock;

mysql> flush logs;

mysql> \q

[root@station39~]# mysqldump -uroot --all-database --master-data=2 >/root/master.sql

[root@station39 ~]# vim /root/master.sql

--CHANGE MASTER TO

MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=106; //**备份内容截止点

mysql> unlock tables;

将数据发送到从服务器上:

[root@station39 ~]# scp /root/master.sql 192.168.1.13:/root

从服务器:

[root@station26 ~]# mysql -uroot

mysql> change master to

     > master_host='192.168.1.11',

     >master_port=3306,     

     > master_user='rep',

     > master_password='RedHat',

     > master_log_file='master-bin.000003',

     >master_log_pos=106;

日志相关参数:

mysql> show binlog events\G;

MySQL

Event_type:This is the type of the event.

Server_id:This is the server ID of the server that created the event.

Log_name:The name of the file that stores the event.

Pos:This is the position of the file where the event starts; that is, it’s the first byte of the event.

End_log_pos:This gives the position in the file where the event ends and the next event starts.

Info:This is human-readable text with information about the event.

Filter 过滤功能:

在主服务器上过滤:

binlog-do-db:指定当前主服务器中仅允许客户端复制的数据库

binlog-do-ignore-db:指定当前主服务器哪些数据库的更新不记录在Binary Log中,可能会造成主服务器无法进行时间点恢复的致命错误。

MySQL

linux
相关资讯       MySQL教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款