Using MySQL built-in replication to optimize usability (ii) _php tutorial

Source: Internet
Author: User
First step: Configure the master server
In the remainder of this article, I'll specify two servers. A (IP is 10.1.1.1) as the primary server (referred to as the host). B (IP is 10.1.1.2) as a backup server (for short, standby).
The MySQL replication feature is implemented as: Standby (B) connects to host (A), then reads out the binary update log of the host and merges the changes that occur into the database itself. The standby machine needs a user account to connect with the host, so create an account on the host and give it file permissions, as follows:
GRANT FILE on *. replicate@10.1.1.2 identified by "password";
For the standby machine to be able to connect with the host, to run "FLUSH privileges" on the host, but do not worry, because we will stop the server in the following steps.
Now we need a snapshot of the host database, and the host is configured to allow the generation of binary update logs. First edit the "my.cnf" file to allow the binary update log, so add a line somewhere below the [mysqld] section: "Log-bin". On the next server startup, the host will generate a binary update log (named: $#@60; hostname $#@62;-bin.$#@60; delta ordinal #$#@62;). In order for the binary update log to be valid, close the MySQL service program, then all the database directories on the host to another directory, and then restart Mysqld. Make sure that you have all the databases, otherwise when replicating, if a table exists on the host but does not exist on the standby, it will exit because of an error. Now you've got a snapshot of the data, and a binary log from the snapshot, which records any modifications to the database. Please note the MySQL data file (*. myd,*. Myi and *.FRM) are dependent on the file system, so you can't just transfer files, such as from Solaris to Linux. If you are in a heterogeneous server environment, you will have to use the Mysqldump utility or other custom scripts to get a snapshot of the data.

http://www.bkjia.com/PHPjc/532379.html www.bkjia.com true http://www.bkjia.com/PHPjc/532379.html techarticle First step: Configure the master server in the remainder of this article, I will specify two servers. A (IP is 10.1.1.1) as the primary server (referred to as the host). B (IP is 10.1.1.2) for ...

  • Related Article

    Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.