mysql提供了主从复制的功能,作用类似oracle的dataguard,但是配置和管理远比dataguard简单,没有所谓的物理备库和逻辑备库之分,
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分析过去?
一:在主库上创建用于复制的账号并在从库上连接测试
[root@dg53 ~]# mysql welcome to the mysql monitor. commands end with ; or \g. your mysql connection id is 1 server version: 5.5.25-log source distribution copyright (c) 2000, 2011, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or its affiliates. other names may be trademarks of their respective owners. type 'help;' or '\h' for help. type '\c' to clear the current input statement. query ok, 0 rows affected (0.00 sec) [root@dg54 ~]# mysql -u r_test -h 192.168.123.13 -p enter password: welcome to the mysql monitor. commands end with ; or \g. your mysql connection id is 2 server version: 5.5.25-log source distribution copyright (c) 2000, 2011, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or its affiliates. other names may be trademarks of their respective owners. type 'help;' or '\h' for help. type '\c' to clear the current input statement. +--------------------+ | database | +--------------------+ | information_schema | | test | +--------------------+ 2 rows in set (0.01 sec)