In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Let me tell you a little bit about how to configure the master-slave replication of mysql in the centos7 system. Have you known about similar topics before? If you are interested, let's take a look at this article. I believe it is more or less helpful for everyone to see how the centos7 system configures the master-slave replication of mysql.
Master 192.168.2.10
From 192.168.2.11
Configure the primary mysql first
Vi / etc/my.cnf
Locate [mysqld] and add the following configuration after that:
This MySQL CVM is uniquely identified. The default value is 1, which generally adopts the terminal value of the IP to which it belongs.
Server-id=1
The name of the binary log file. This configuration must be enabled for the MySQL primary CVM.
Log-bin=master-bin-log
The name of the database participating in master-slave replication in the MySQL master CVM; if there are multiple databases, this parameter can be multiple, one per row, and the division corresponds to a different database
Binlog-do-db=db_master_backup
The index name of the binary log file in the MySQL primary CVM
Og-bin-index=master-bin-log.index
Create a database db_master_backup
Create database db_master_backup
Create the user backup and set the password backup_123456:
Create user 'backup'@'%' identified by' backup_123456'
Assign user backup all permissions on the db_master_backup database:
Grant all on db_master_backup.* to 'backup'@'%'
Assign local access to user backup:
Grant all privileges on db_master_backup.* to 'backup'@'localhost' identified by' backup_123456'
The slave CVM is authorized to access the master server through backup users:
Grant replication slave on *. * to 'backup'@'%' identified by' backup_123456' with grant option
Configure slave database
Vi / etc/my.cnf
# uniquely identify this MySQL CVM. The default value is 1, which is generally the end value of the IP to which it belongs.
Server-id=2
# MySQL index the file name from the log of the CVM
Relay-log-index=slave-relay-log.index
# MySQL log file name of slave CVM
Relay-log=slave-relay-log
Create a database db_master_backup
Create database db_master_backup
Restart two mysql services
View the status of the primary CVM:
Show master status
Perform the following configuration on the slave service:
Change master to master_host='192.168.2.10', / / main CVM IP
Master_port=3306
Master_user='user_master'
Master_password='Password_Master_123456'
Master_log_file='master-bin-log.000001', / / the value of the primary CVM master_log_file
Master_log_pos=364; / / the value of the primary CVM master_log_pos
Mysql > stop slave
Mysql > start slave
Execute show slave status\ G
If an error is reported by Error reading packet from server for channel': Could not find first log file name in binary log index file
Resolution steps:
Restart the master library: service mysqld restart
Mysql > show master status
Execute on the slave library
Mysql > stop slave
Mysql > change master to Master_Log_File='master-bin-log.000002',Master_Log_Pos=154
Mysql > slave start
Mysql > show slave status\ G
Add data to the user name t_user in the db_master_backup library of MySQL master CVM:
Mysql > insert into t_user (id, name) values (1, 'idea1')
Mysql > select * from t_user
Set up a script on the primary cloud server to insert data into the t_user
#! / bin/bash
ITunes 1
MAX_INSERT_ROW_COUNT=$1
While [$I-lt 100]
Do
Mysql-uroot-p123456 db_master_backup-e "insert into t_user () values
Echo "INSERT HELLO $I @ @ $d"
ITunes $(($item1))
Sleep 0.05
Done
Exit 0
Check whether the data is synchronized from the database
Mysql > select * from t_user
What do you think of the centos7 system how to configure the master-slave copy of mysql? how about this article, whether there is anything to gain. If you want to know more about it, you can continue to follow our industry information section.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.