MySQL master-slave configuration (super Simple)

Source: Internet
Author: User
Tags unique id

1, preparation (version and data consistency):
Primary server 192.168.2.41 (master)
From server 192.168.2.42 (from)

2. Modify Master server Master:

#VI  my.cnf[mysqld]log-bin=mysql-bin  #[must be] enable binary log server-id=       #[must] server unique ID, default is 1, usually take IP last paragraph

3. Modify the slave from the server:

#VI  my.cnf[mysqld]log-bin=mysql-bin  #[must be] enable binary log server-id=       #[must] server unique ID, default is 1, usually take IP last paragraph

4. Restart MySQL for two servers

/etc/init.d/mysql restart

5. Establish an account on the primary server and authorize slave:

GRANT REPLICATION SLAVE on * * to ' SLAVE ' @ ' 192.168.2.42 ' identified by ' 12345678 ' ; 0 1 Warning (0.01  sec) MySQL> flush Privileges; 0 rows affected (0.01  sec) Note:% indicates that all clients may be connected, as long as the account number, the password is correct, here can be replaced by specific client IP, such as 192. 168.2.  the (from the library IP can be connected), to enhance security.

6, log on to the master server MySQL, query the status of master

Mysql> Show master status; mysql-bin.000003 56051 | | | |+------------------+----------+--------------+------------------+-------------------+1   in Set (0.02  sec) Note: Do not re-operate the master server MySQL after performing this step to prevent changes in the primary server state value

7. Configure the slave from the server:

Change master to master_host= ' 192.168.2.41 ', master_user= ' slave ', master_password= ' 12345678 ', master_log_file= ' Mysql-bin.000003 ', master_log_pos=56051; 0 1 Warning (0.02  sec) MySQL> start slave; 0 rows affected (0.01 sec)

8. Check the status of the replication function from the server:

Mysql>Show Slave Status\g***************************1. Row ***************************slave_io_state:waiting forMaster to send eventmaster_host:192.168.2.41Master_user:slavemaster_port:3306Connect_retry: -Master_log_file:mysql-bin.000003Read_master_log_pos:56051Relay_log_file:a13ecaa37c21-relay-bin.000002Relay_log_pos: theRelay_master_log_file:mysql-bin.000003Slave_IO_Running:YesSlave_SQL_Running:YesReplicate_Do_DB: ...

Note: The slave_io and slave_sql processes must function normally, that is, the Yes state, otherwise it is an error state (e.g., one of the No is an error).

The master-Slave server configuration is complete.

MySQL master-slave configuration (super Simple)

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.