MySQL Master/Slave Server Configuration

Source: Internet
Author: User
LAST_INSERT_ID() 
 
A is the host, B is the backup machine, and is also a dual-nic, and can be connected through the Intranet

A Intranet IP Address: 192.168.195.28

B Intranet IP Address: 192.168.195.30

The database version (5.0.22), directory, initial database, and table are the same.

Database ad_data, alexa_info, log_db, oblog, union_db, zm0061_db to be backed up

MySQL and test databases that do not need to be backed up

Statement

1. Add the account mysqlrepl to the host as the backup account

Grant replication slave on *. * To 'mysqlrepl' @ '192. 168.195.30 'identified by '123 ';

For versions earlier than 4.02

Grant file on *. * To 'mysqlrepl' @ '192. 168.195.30 'identified by '123 ';

Then let the databases of the two machines shut down and lock the table. But for the direct purpose, I didn't play that deep.

2. Modify/data/8le8le/database/statusdb/CNF/my-status.cnf on machine

# Log name
Log-bin = mysql-bin
# Master server ID
Server-id = 1
# Databases to be backed up
BINLOG-do-DB = ad_data
BINLOG-do-DB = alexa_info
BINLOG-do-DB = log_db
BINLOG-do-DB = oblog
BINLOG-do-DB = union_db
BINLOG-do-DB = zm0061_db
# Ignored Database
BINLOG-ignore-DB = MySQL
BINLOG-ignore-DB = test


3. Modify/data/8le8le/database/statusdb/CNF/my-status.cnf on machine B

# Log name
Log-bin = mysql-bin
# Slave server ID
Server-id = 2
# IP address or domain name of the master server
Master-host = 192.168.195.28
# Master database port number
Master-Port = 30001
# Database Synchronization users
Master-user = mysqlrepl
# Synchronize database passwords
Masters-Password = 123456789
# Time Difference in reconnection if the master server is disconnected from the slave server
Master-connect-retry = 60
# Databases to be backed up
Replicate-do-DB = ad_data
Replicate-do-DB = alexa_info
Replicate-do-DB = log_db
Replicate-do-DB = oblog
Replicate-do-DB = union_db
Replicate-do-DB = zm0061_db
# Ignored Database
Replicate-ignore-DB = MySQL
Replicate-ignore-DB = test


4. Start the master server and start the slave server

Attach the B server to the database
Mysql> show slave status/g;
Two rows are displayed.
Slave_io_running: Yes
Slave_ SQL _running: Yes

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.