Deploy MySQL Master/Slave on CentOS7 and centos7mysql

Source: Internet
Author: User

Deploy MySQL Master/Slave on CentOS7 and centos7mysql

Deploy MySQL Master/Slave on CentOS71. Connect to the MySQL master server through SecureCRT; 2. Find my. directory of the cnf file: mysql -- help | grep my. cnf General situation my. cnf is located in the/etc/directory. 3. Use vim to open the MySQL configuration file my. cnf: vim/etc/my. cnf4 locate [mysqld] and add the following configuration after it: # uniquely identifies this MySQL server. The default value is 1, generally, the end value of the IP address is server-id = 1 # binary log file name, the MySQL master server must enable this configuration log-bin = master-bin-log # Name of the database on the MySQL master server that participates in master-slave replication; If there are multiple databases, this parameter can have multiple, one in each line, segment corresponds to different database binlog-do-db = db_master_slave # index name of the binary log file in the MySQL master server log-bin-index = master-bin-log.index5 on the MySQL slave server also open my. in the cnf file, locate [mysqld] and add the following configuration after it: # uniquely identifies the MySQL server. The default value is 1, generally use the IP end value server-id = 2 # MySQL slave server log index file name relay-log-index = slave-relay-log.index # MySQL slave server log file name relay-log = slave-relay-log6 in create the database db_master_slave on the MySQL master and slave servers respectively: create database db_master_slave; 7. create user_master on the MySQL master server and set the Password Password_Master_123456: create user 'user _ master' @ '%' identified by 'password _ master_123456 '; 8. grant all permissions on the db_master_slave database to user_master on the MySQL master server: grant all on db_master_slave. * to 'user _ master' @ '%'; 9 grant the user user_master local access permission on the MySQL master server: grant all privileges on db_master_slave. * to 'user _ master' @ 'localhost' identified by 'password _ Master_123456 '; 10. Authorize the MySQL slave server on the MySQL master server to access the master server through the user_master user: grant replication slave on *. * to 'user _ master' @ '%' identified by 'password _ Master_123456 'with grant option; 11 restart the MySQL service on the MySQL master and slave servers respectively: Disable the MySQL service: service mysqld stop open MySQL service: service mysqld start
Restart the MySQL service:
Service mysql restart12 enters the database db_master_slave on the MySQL master and slave servers respectively, and creates the user table t_user: create table t_user (id int (3 ), name varchar (128); 13 check the MySQL master server status: show master status; and record the master_log_file attribute and master_log_pos attribute values; 14. Execute the following configuration on the MySQL slave service: change master to master_host = '2017. 168.1.10 ', // MySQL master server IP master_port = 3306, master_user = 'user _ Master', master_password = 'password _ Master_123456', master_log_file = 'master-bin-log.000004 ', // The value of master_log_file on the MySQL master server is master_log_pos = 654; // The value of master_log_pos on the MySQL master server is 15. In the db_master_slave database on the MySQL master server, add data as the user name t_user: mysql> insert into t_user (id, name) values (1, 'idea1'); mysql> select * from t_user; 16 add data for the user name t_user in the db_master_slave database of the MySQL slave server: mysql> insert into t_user (id, name) values (1, 'idea1'); mysql> select * from t_user; 17 how to find it on the MySQL slave server: slave_IO_running = NO, run the following command: mysql> stop slave; mysql> start slave; 18. view the server_id value in MySQL running: show variables like 'server _ id ';

 

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.