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;