InnoDB Engine Database Master-slave replication synchronization new sharing _mysql
Source: Internet
Author: User
The company's MySQL architecture has recently been upgraded, from the original one of the main more from the Drbd+heartbeat double master from, just have a new E-commerce site project will be online, with the Drbd+heartbeat dual-master one from, Since this process is still different from the previous MyISAM engine, it is summed up here:
1 MySQL replication process is an asynchronous synchronization process, not complete master-slave synchronization, so the process of synchronization is delayed, if the separation of read and write business, it is recommended to monitor this delay time;
2 MySQL master and slave machine remember Server-id to remain inconsistent, if the same, replication process will appear as follows:
Fatal error:the slave I/O thread stops because master and slavehave equal MySQL server IDs; These IDs must is different for replication to work (or the--replicate-same-server-id option must is used on slave but thi s doesnot always make sense; Please check the manual before using it).
This problem is very good to deal with, will slave machine Server-id modified to be inconsistent with Master machine.
3 My previous misunderstanding is that the slave machine is using its own binary log to complete the replication process, in fact, is not the case, according to the principle of duplication of work: Slave server is the copy master server binary log to its own relay log, That is, the Relay-log log (that is, centos3-relay-bin.000002 this name), and then the update application to their own database, so the slave machine does not need to open binary log, so the process will be successful, unless you are ready to master the main architecture, this requires the slave machine to open Binary log, this problem has been guiding me, I have always thought slave machine to build replication environment is to open the binary,
4 in the Master machine authorization, as far as possible only to a certain or a few fixed machine permissions, so that they only replication Slav,replication client permissions, as far as possible not to grant permissions; In addition, although the database we generally operate through the intranet, But the more in the intranet to the MySQL database authorization operation, the more should pay attention to security;
5 Replication build process to follow the normal flow of words, generally very easy to implement success, if the error, more than check the network environment, permission issues, generally speaking, the entire construction process should still be relatively smooth.
In the early days of database design, I have defined this E-commerce database engine as InnoDB, in addition to the system tables in the database, the other tables are all converted from MyISAM to InnoDB, for two reasons:
1 e-commerce business will involve transaction payment, in this basic OLTP application, InnoDB should be the primary storage engine of the core application table;
2 DRBD System Restart process will be relatively slow, will frequently read the table, if the table engine for MyISAM the words are very likely to be damaged, in order to create unnecessary problems, I will be the database table engine from MyISAM to the InnoDB engine of the table.
Drbd+heartbeat+mysql reference to the previous working documents, build a relatively smooth, is to build replication environment encountered 1062 error, the detailed process is as follows:
The initial reference to the MySQL manual operation, take the master machine snapshot backup, with the--single-transaction option, and then the synchronization process frequently 1062 error, the error log is as follows:
Last_sql_error:error ' Duplicate entry ' d36ad91bff36308de540bbd9ae6f4279 ' for key ' PRIMARY ' on query. Default database: ' MyProject '. Query: ' INSERT into ' lee_sessions ' (' session_id ', ' ip_address ', ' user_agent ', ' last_activity ', ' User_data ') VALUES (' d36ad91bff36308de540bbd9ae6f4279 ', ' 180.153.201.218 ', ' mozilla/4.0 ', 1353394206, ') '
Later I changed my mind and used the--MASTER-DATA option to take the master Master snapshot backup, as shown in the following command:
Mysqldump-uroot--quick--flush-logs--master-data=1-p myproject > Myproject.sql
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service