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 ...