Configure the Mysql Master/Slave database in Ubuntu

Source: Internet
Author: User

The MySQL database supports the master-slave replication function of the database, so it has its unique advantages in the cluster. Among the many large website architectures at home and abroad, MySQL master-slave database configuration is used to achieve query load, Database Hot Backup and other functions. This requirement is also involved in my actual Web project. Here I will summarize how to configure and implement it.

Environment: Virtual Machine

Server: Ubuntu 14.04 LTS
Database: 5.5.37
Port 3306
Primary IP Address: 192.168.63.small
Slave IP: 192.168.63.134
Authorized account:
User: suxh
Password: 111111
After the environment is fully explained, we can directly configure:
Step 1: The master and slave servers must have the same database (which needs to be synchronized). Here we use the backup database (not to mention it much, (www.jbxue.com) before the synchronization starts, copy the master database to the slave database)
Step 2 configure the master database to edit/etc/my. cnf. It mainly enables binary logs and sets parameters such as the database to be synchronized.

# binary logging format - mixed recommendedbinlog_format=mixedbinlog-ignore-db=mysqlbinlog-do-db=backup# required unique id between 1 and 2^32 - 1# defaults to 1 if master-host is not set# but will not function as a master if omittedserver-id = 1

Parameter explanation:

The server-id is unique and cannot be the same as the server.
Binlog_format binary file format
Database ignored by binlog_ignore-db
Binlog-do-db: database to be synchronized
After the settings are complete, restart the database.
Step 3 from the database:
Similarly, modification of the/etc/my. cnf parameter in mysql 5.1.7 does not support the master-host parameter. Therefore, you only need to configure server-id = 2 here.
Then log on to the slave database and set
Change master to master_host = '192. 168.63.20.', master_user = 'suxh', master_password = '2016 ';
Slave start;

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.