Add slave database for mysql database

Source: Internet
Author: User
Tags mysql code


Mysql database addition slave database mysql Master/Slave configuration has been applied in a lot of businesses. Although I know about the mechanism, I have never processed it. For more information, I have performed Master/Slave configuration on mysql: 3306 slave Database: 33071 master database configuration: www.2cto.com My. conf code [mysqld] # log-bin =/data0/mysql/3306/binlog log-bin-index =/data0/mysql/3306/binlog /binlog. index server-id = 1 # the configuration of the slave database cannot be the same as that of the master database. Note: Check whether binlog-do-db exists in the original configuration file. If the database is specified, only this database can perform master-slave operations. Users who need to configure (restart the service) to add REPLICATION permissions (read binary files) as needed: grant replication slave, replication client on *. * TO 'username '@ 'IP' identified by 'Password'; Java code mysql> show master status; View file and position www.2cto.com

2 slave Database Configuration: My. conf code [mysqld] # configure relaylog. If you do not have relaylog, create the directory relay-log-index =/data0/mysql/3307/relaylog # relay- log-info-file =/data0/mysql/3307/relaylog # relay log file replicate-ignore-db = mysql # Shield mysql synchronization, multiple applications can be set ", "Separate server-id = 2 # different from the master database configuration. Similarly, you must note that the binlog-do-db configuration www.2cto.com restarts the Service database to operate Mysql code mysql> change master to master_host = 'master database ip Address ',> master_port = 3306,> master_user = 'user name ',> Master_password = 'Password',> master_log_file = 'binlog. * ** ',> master_log_pos = 101; www.2cto.com master_log_file and master_log_pos are queried in the master database and then: Mysql code mysql> slave start; # view slave database status mysql> show slave status \ G; information: Slave_IO_Running: Yes Slave_ SQL _Running: Yes indicates that the configuration is successful and whether the synchronization of data written to the master database from the slave database is successful.

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.