Here is a brief introduction of the mysql Hot Backup installation method, mainly in Ubuntu, a friend in need can refer.
Here is a brief introduction of the mysql Hot Backup installation method, mainly in Ubuntu, a friend in need can refer.
1. Install the latest Ubuntu Server version and update the system.
2. Install MySQL Server: sudo apt-get instal-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:
| The Code is as follows: |
|
[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. Here, s3 (for example) needs to be synchronized.
| The Code is as follows: |
|
[Mysqld] Log-bin = mysql-bin Server-id = 1 Binlog-do-db = s3 |
5. Restart the primary database.
| The Code is as follows: |
|
Sudo service start mysql
|
6. Connect to the primary database and create the database to be synchronized. If the database already exists, ignore this step.
| The Code is as follows: |
|
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.
| The Code is as follows: |
|
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.
| The Code is as follows: |
|
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.
| The Code is as follows: |
|
[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:
| The Code is as follows: |
|
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;
|
11. Start the slave backup and view the slave status.
| The Code is as follows: |
|
Start slave; Show slave statusG; * *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.137.12 Master_User: sync Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000007 Read_Master_Log_Pos: 106 Relay_Log_File: S3-DB-SLAVE-1-relay-bin.000010 Relay_Log_Pos: 251 Relay_Master_Log_File: mysql-bin.000007 Slave_IO_Running: Yes Slave_ SQL _Running: Yes Replicate_Do_DB: s3 Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 106 Relay_Log_Space: 559 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_ SQL _Errno: 0 Last_ SQL _Error: 1 row in set (0.00 sec) Slave_IO_Running: Yes Slave_ SQL _Running: Yes |
It indicates that the job is normal and no problem occurs. An important tool to solve the problem is to view the log records.
| The Code is as follows: |
|
Cat/var/log/mysql/error. log |