MySQL Ubuntu master-Slave sync Configuration

Source: Internet
Author: User

MySQL Ubuntu master-Slave sync Configuration

One, install MySQL on two Linux machines

Second, Master master server configuration (192.168.1.3)

1. Edit my.cnf (Command Find file location: Find/-name my.cnf)

Vi/etc/mysql/my.cnf

Add in [mysqld]:

Server-id = 1

Log_bin = Master-bin

Log_bin_index = Master-bin.index

binlog_do_db = My_data

binlog_ignore_db = MySQL

Note: Server-id server Unique identification, Log_bin starts the MySQL binary log, binlog_do_db specifies the database that logs the binary log, binlog_ignore_db specifies a database that does not log binary logs.

2. Log in to the master server to create the account and permissions to use from the server:

Grant Replication Slave on * * to ' masterbackup ' @ ' 192.168.1.% ' identified by ' masterbackup ';

(192.168.1.% wildcard, which indicates that 0-255 of IP are accessible to the primary server, formal environment please configure specify from server IP)

3. Restart MySQL, command:/etc/init.d/mysql restart

4. Check the status of the primary server:

Show master status;

Iii. slave from server configuration (192.168.1.5)

1. Edit my.cnf (Command Find file location: Find/-name my.cnf)

Vi/etc/mysql/my.cnf

Add in [mysqld]:

Server-id = 2

Relay-log = Slave-relay-bin

Relay-log-index = Slave-relay-bin.index

2. Restart slave from server mysql, command:/etc/init.d/mysql restart

3. Log slave from the server and connect to master master server:

Change Master to master_host= ' 192.168.1.103 ', master_port=3306,master_user= ' masterbackup ', master_password= ' Masterbackup ', master_log_file= ' master-bin.000001 ', master_log_pos=2403;

Note: Master_log_file corresponds to the file column shown in Show Master status: Master-bin.000001;master_log_pos corresponds to position column: 2403, otherwise synchronization failure may occur.

4. Start slave data synchronization.

Start slave;

5. View slave information:

show slave status\g;

Note: Both slave_io_running and slave_sql_running are yes to indicate that the synchronization was successful.

Manuscripts: Diligent Learning qkxue.net

Extended reading:

MySQL Ubuntu master-Slave sync Configuration

Http://qkxue.net/info/30550/MySQL-Ubuntu

MySQL Ubuntu master-Slave sync Configuration

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.