References:
Http://www.cnblogs.com/wuhou/archive/2008/09/28/1301071.html
Http://www.hebaodans.com/2009/02/m-y-s-q-l-shu-ju-ku-de-tong-bu-wen-ti-shuang-ji-re-bei/
1. Install the latest Ubuntu Server version and update the system.
2. Install MySQL Server: sudo apt-get instal mysql-server, set the administrator password, and remove the local address binding for remote access.
MASTER: 192.168.137.12
From: 192.168.137.13
|
3. Set the utf8 character set to support Chinese characters. Add the following to the configuration file/etc/mysql/my. cnf of the Master/Slave Server:
[Client] Default-character-set = utf8 [Mysqld] Default-character-set = utf8 Init_connect = 'set NAMES utf8 ;' |
4. Start the backup on the server. First, add the following content to the configuration file of the master server. S3 (for example) is the database to be synchronized.
[Mysqld] Log-bin = mysql-bin Server-id = 1 Binlog-do-db = s3 |
5. Restart the primary database.
6. Connect to the primary database and create the database to be synchronized. If the database already exists, ignore this step.
Mysql-u root-p Create database s3; |
7. It is important to add an account (sync) to the server to synchronize the database and grant the backup permission.
Grant replication slave on *. * to 'sync' @ '%' identified by '123' |
8. record the name and location of the log file of the s3 database for the location starting from the backup.
Mysql> show master status; + ------------------ + ---------- + -------------- + ------------------ + | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | + ------------------ + ---------- + -------------- + ------------------ + | Mysql-bin.000007 | 106 | s3 | + ------------------ + ---------- + -------------- + ----------------- |
9. modify the configuration file of the slave machine.
[Mysqld] Server-id = 2 Read-only Master-connect-retry = 60 Replicate-do-db = s3 |
10. Restart the slave machine, create a database (s3), or restore the database from the original database. Run the following command:
Change master to MASTER_HOST = '192. 168.137.12 ', MASTER_USER = 'sync', MASTER_PASSWORD = '000000', MASTER_LOG_FILE = 'mysql-bin.000007', MASTER_LOG_POS = 192; |