In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, Xiaobian will bring you about how to configure master-slave replication in Mysql 5.5. The article is rich in content and analyzed and described from a professional perspective. After reading this article, I hope you can gain something.
1. Main library editor my.cnf:
[mysqld]
log-bin=NEW_NAME
server-id=1 #with a unique ID number, 1 to 32.
#Set the name to copy or not to copy master-slave, and also set it on Slave.
binlog-do-db= database name 1
binlog-do-db= database name2
binlog-ignore-db= database name 1
binlog-ignore-db= database name2
> grant replication slave on *.* to slaveuser@192.168.1.101 identified by '123456' ;
mysql> flush privileges;
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000008 | 337 | | |
+------------------+----------+--------------+------------------+
Record the binary log file name and location
2. Edit my.cnf from the library and change server-id to a number that is not the same as the host.
If you only want to synchronize a specified database, you can add replicate-do-db = yourdatabase,
Sync a few copy a few, change the database name is good.
[mysqld]
server-id=2 #Unique
#Set the name of the database to be replicated or not to be replicated, and also set it on Master.
replicate-do-db= database name 1
replicate-do-db= database name 2
replicate-ignore-db= database name 1
replicate-ignore-db= database name2
mysql> change master to master_host='192.168.1.100',master_user='slaveuser',master_password='123456', master_log_file='mysql-bin.000008',master_log_pos=337;
mysql> start slave;
mysql> show slave status\G;
If:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
If both of the above are Yes, that means there is no problem. If individual databases are specified, you can also see
Note: If Slave_SQL_Running: connecting occurs, first enter:
#mysql -uslaveuser -h 192.168.1.100 -p123456
See if you can log in to mysql, if it is rejected and other prompts, then check whether the user's permissions are set correctly from the library authorization operation on the host.
If the initial environment is not a master-slave architecture, and there is data after running for a while, then lock the host first: flush tables with read lock;
Package the data directory of the host: #tar zcf /tmpdatabak.tgz /opt/data, copy this compressed package to the slave, decompress it, and configure the master and slave.
Then unlock: unlock tables;
The above is how to configure master-slave replication in Mysql 5.5 shared by Xiaobian. If there is a similar doubt, please refer to the above analysis for understanding. If you want to know more about it, please pay attention to the industry information channel.
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.