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分析过去?
一:在主库上创建用于复制的账号并在从库上连接测试
- [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.
- mysql> grant replication slave on *.* to 'r_test'@'192.168.123.14' identified by '123456';
- 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.
- mysql> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | test |
- +--------------------+
- 2 rows in set (0.01 sec)
相关推荐
emmm00 2020-11-17
暗夜之城 2020-11-11
疯狂老司机 2020-09-08
要啥自行车一把梭 2020-09-10
CoderToy 2020-11-16
bianruifeng 2020-11-16
云中舞步 2020-11-12
世樹 2020-11-11
Coder技术文摘 2020-09-29
huacuilaifa 2020-10-29
Gexrior 2020-10-22
tufeiax 2020-09-03
王艺强 2020-11-17
aydh 2020-11-12
zry 2020-11-11
URML 2020-11-11
spurity 2020-11-10
yifangs 2020-10-13
Andrea0 2020-09-18
Ida 2020-09-16
ltd00 2020-09-12
xjd0 2020-09-10