MySQL master slave 1 (2015-11)

Source: Internet
Author: User
Tags egrep

Note: The environment is the primary library single instance, from the library multiple instances.

    1. The main library opens Logbin, confirming that the server ID is different from the library

[Email protected] backup]# egrep "Log-bin|server-id"/etc/my.cnf

Server-id= 1

Log-bin=mysql-bin


[Email protected] backup]# egrep "Log-bin|server-id"/data/3306/my.cnf

#log-bin =/data/3306/mysql-bin

Server-id = 06

2. Master repository user for access from library

[[email protected] backup]# mysql-uroot-p111111-e "Grant replication Slave on * * to ' rep ' @ '% ' identified by ' 111111 '; fl Ush privileges; "

[[email protected] backup]# MYSQL-UROOT-P111111-E "show grants for rep"

+-------------------------------------------------------------------------------------------------------------- --+

|                                                                                               Grants for [email protected]% |

+-------------------------------------------------------------------------------------------------------------- --+

| GRANT REPLICATION SLAVE on * * to ' rep ' @ '% ' identified by PASSWORD ' *FD571203974BA9AFE270FE62151AE967ECA5E0AA ' |

3. Primary Library Backup

Mysqldump-uroot-p111111-a-B--events-master-data=1-x >/backup/db.sql

#备注: Official Recommendation: Lock table view (flush table with read Lock:show master status;show master logs;)---> Backup---> Unlock (unlock tables):


4. Import from library (data SCP has been sent over)


Mysql-uroot-p111111-s/data/3306/mysql.sock </backup/db.sql

5. Change Master,start slave from the library.



Change Master to master_host= ' 192.168.199.21 ', master_port=3306, master_user= ' rep ', master_password= ' 111111 ', master_ Log_file= ' mysql-bin.000025 ', master_log_pos=107;

Start slave;

show slave status \g;

1. Row ***************************

Slave_io_state:waiting for Master to send event

master_host:192.168.199.21

Master_user:rep

master_port:3306

Connect_retry:60

master_log_file:mysql-bin.000025

read_master_log_pos:107

relay_log_file:relay-bin.000002

relay_log_pos:253

relay_master_log_file:mysql-bin.000025

Slave_io_running:yes

Slave_sql_running:yes

....

ERROR:

No query specified


MySQL master slave 1 (2015-11)

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.