MySQL master-slave Separation

Source: Internet
Author: User
Tags syslog

MySQL Master/Slave separation master database configuration 1,/etc/my. cnf master database configuration # generally, www.2cto.com server-id = 1 # Database binlog-do-db = search # Database replicate-ignore-db = that does not need to be copied mysqlreplicate-ignore-db = testreplicate-ignore-db = information_schema # files generated for synchronizing data, serial number from: mysql-bin.000001 start log-bin = mysql-bin 2, restart mysql, log on to Mysql, set the permissions required from the database: can log on from any machine, account/password: slave1/passw0rd grant replication slave, reload, super on *. * to 'slave1 '@' % 'identified by 'Pa Ssw0rd '; 3. Check the status of mysql> show master status; + metric + ---------- + -------------- + ---------------- + | File | Position | Binlog_Do_DB | metric | + metric + ---------- + -------------- + metric + | mysql-bin.000005 | 7657 | search | + metric + ---------- + -------------- + ------------------ + 1 row in set (0.01 sec) -------------------------------------------------- ----------------------------------------------- Slave Database Configuration 1,/etc/my. cnf is configured from the database. because Mysql versions do not support parameters similar to "master-host" since 5.1.7, when you use the configuration file to set master-slave synchronization, the following error occurs: mysqld: unknown variable 'master-host = 127.0.0.1 '# Set the server-id in the configuration file to 2server-id = 2 (it may not work. After you log on to the database, use show variables like 'server _ id. Set global server_id = 2;) # Name of the database to be synchronized replicate-do-db = mydatabase 2. Restart mysql, log on to Mysql, and set synchronization settings, syslog.000001 is the log file, and master_log_pos = 0 is the location where logs are copied, that is, data is synchronized from the 0 position of syslog.000001. log files and line numbers are processed based on the actual situation. mysql> stop slave; query OK, 0 rows affected, 1 warning (0.00 sec) mysql> change master to-> master_host = '2017. 103.8.14 ', master_user = 'slave1', master_password = 'passw0rd ',-> master_log_file = 'mysql-bin.000005', master_log_pos = 7657, master_port = 53306; Query OK, 0 rows affected (0.10 sec) mysql> start slave; Query OK, 0 rows affected (0.00 sec) show slave status \ G; command easier

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.