In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to add a new database to the MySQL master-slave replication environment. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Basic steps of master-slave replication
First of all, let's list the basic steps of master-slave replication (MySQL master-slave needs to be configured on their respective servers first).
(1) copy the database
Mysqldump-- master-data-- single-transaction-R-- databases [db_name] | gzip-9-| pv > all-db-with-master-data.sql.gz
Note: use-single-transaction for innodb and-lock-all-tables for myisam.
(2) copy and import data
Pv
< all-db-with-master-data.sql.gz | zcat | mysql (3)启动slave数据库 slave start 注意:切换到主的语句已经在导出的sql语句里面了,注意查看下面的代码片段。 change master to master_log_file=’(binlog name in relay_master_log_file)’, master_log_pos=(exec_master_log_pos number) 那么,在现有的主从复制结构中,如何增加一个新的数据库进去?我们继续往下看。 添加数据库 比如我们要增加一个数据库在master服务器上,比如,名为newdb的数据库。具体操作如下: (1)从服务上,停掉slave数据库。 stop slave; (2)主服务器上,导出新数据库 mysqldump --master-data --single-transaction -R --databases newdb >Newdb.sql
(3) modify the master server my.cnf file
On the master server, modify the my.cnf file, add a new library to the binlog-do-db parameter, and restart mysql.
(4) find the current log file and location
Find the current log file and location (change master to …) in the exported newdb.sql.
Then let the slave server execute to this location.
Start slave until MASTER_LOG_FILE= "mysql-bin.000001", MASTER_LOG_POS=1222220
Where MASTER_LOG_FILE and MASTER_LOG_POS are found at the top of the exported database newdb.sql.
(5) Import the new library to the slave server
Mysql < newdb.sql
(6) start the slave server
Start slave on MySQL master-slave replication environment how to add a new database to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.