MySQL provides the master-slave replication function, which is similar to Oracle's slave uard. However, configuration and management are far simpler than slave uard, and there is no so-called physical slave database or logical slave database, there is no corresponding data protection mode, and only the master and slave database roles are provided. This architecture is widely used in major portals and game websites to provide the database read/write splitting function; in contrast, oracle's read/write function can be fully implemented with active standby uard in version 11. Otherwise, it can only use logical standby, but many data types and operations are not supported by the logical standby database!
I have previously used the master-slave architecture of MySQL and for read/write separation of CMS databases. It has a very painful experience. due to various reasons, the master-slave data is not synchronized, then, no additional synchronization mechanism is provided (not learned), so the master-slave architecture is often reconstructed at the end of work. The next step is to test the mha architecture on the MySQL5.5 platform, therefore, this article records how to build a master-slave Database Replication environment on the MySQL5.5 platform. In addition, MySQL's master-slave database can also be seen as MySQL's real-time backup, which has certain data disaster recovery functions, mySQL itself does not provide a hot backup tool similar to oracle rman. Therefore, in most scenarios, a real-time backup is performed on the database using the master and slave nodes for backup from time to time! PS: How does MySQL do incomplete restoration based on time or SCN? Do I really need to analyze binlogs one by one?
I. Create an account for replication on the master database and test the connection on the slave database.
- [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,201 1, 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 '123 ';
- 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,201 1, 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)