Welcome 微信登录

首页 / 数据库 / MySQL / MySQL 5.5配置主从复制

MySQL提供了主从复制的功能,作用类似Oracle的dataguard,但是配置和管理远比dataguard简单,没有所谓的物理备库和逻辑备库之分,也没有提供相应的数据保护模式,只有master和slave数据库角色,这种架构广泛应用于各大门户,游戏网站中,提供数据库的读写分离功能;相比之下oracle的读写功能到了11g版本才能借助active dataguard完美实现,否则就只能用logical standby,但又有许多的数据类型和操作不被逻辑备库支持!先前使用过MySQL5.1.36版本的master-slave架构做CMS数据库的读写分离,有着非常痛苦的使用经历,经常由于各种各样的原因的导致主从数据不同步,然后又没有提供额外的同步机制(确切的说是没学会),于是经常在下班时间重构主从架构;下一步将在MySQL5.5平台测试mha架构,故本文记录下如何在MySQL5.5平台下构建主从数据库复制环境;另外MySQL的主从也可看为是MySQL的实时备份,有一定的数据灾备功能,MySQL本身没有提供类似oracle rman的热备份工具,因而多数场景下会使用主从对数据库做一个实时备份,以备不时只需!PS:一直比较不解的MySQL如何做基于时间或者SCN的不完全恢复?难道真要一个个binlog分析过去?一:在主库上创建用于复制的账号并在从库上连接测试
  1. [root@dg53 ~]# mysql  
  2. Welcome to the MySQL monitor.  Commands end with ; or g.  
  3. Your MySQL connection id is 1  
  4. Server version: 5.5.25-log Source distribution  
  5.  
  6. Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.  
  7.  
  8. Oracle is a registered trademark of Oracle Corporation and/or its  
  9. affiliates. Other names may be trademarks of their respective  
  10. owners.  
  11.  
  12. Type "help;" or "h" for help. Type "c" to clear the current input statement.  
  13.  
  14. mysql> grant replication slave on *.* to "r_test"@"192.168.123.14" identified by "123456";  
  15. Query OK, 0 rows affected (0.00 sec)  
  16.  
  17. [root@dg54 ~]# mysql -u r_test -h 192.168.123.13 -p  
  18. Enter password:   
  19. Welcome to the MySQL monitor.  Commands end with ; or g.  
  20. Your MySQL connection id is 2  
  21. Server version: 5.5.25-log Source distribution  
  22.  
  23. Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.  
  24.  
  25. Oracle is a registered trademark of Oracle Corporation and/or its  
  26. affiliates. Other names may be trademarks of their respective  
  27. owners.  
  28.  
  29. Type "help;" or "h" for help. Type "c" to clear the current input statement.  
  30.  
  31. mysql> show databases;  
  32. +--------------------+  
  33. | Database           |  
  34. +--------------------+  
  35. | information_schema |  
  36. | test               |  
  37. +--------------------+  
  38. 2 rows in set (0.01 sec) 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 下一页
MySQL大小写敏感问题和命名规范MySQL数据库备份及增量备份相关资讯      MySQL教程 
  • 30分钟带你快速入门MySQL教程  (02月03日)
  • MySQL教程:关于I/O内存方面的一些  (01月24日)
  • CentOS上开启MySQL远程访问权限  (01/29/2013 10:58:40)
  • MySQL教程:关于checkpoint机制  (01月24日)
  • MySQL::Sandbox  (04/14/2013 08:03:38)
  • 生产环境MySQL 5.5.x单机多实例配  (11/02/2012 21:02:36)
本文评论 查看全部评论 (0)
表情: 姓名: 字数