Brief Introduction to Ubuntu MySQL Hot Backup Installation

Source: Internet
Author: User

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

 

The Code is as follows: Copy code

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

 

The Code is as follows: Copy code

[Mysqld]

Log-bin = mysql-bin
Server-id = 1
Binlog-do-db = s3

5. Restart the primary database.

The Code is as follows: Copy code
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: Copy code
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: Copy code
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: Copy code
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: Copy code
[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: Copy code
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: Copy code

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: Copy code

Cat/var/log/mysql/error. log

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.