In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "docker how to build a read-write separation environment". The explanation content in the article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian to study and learn "docker how to build a read-write separation environment" together.
#Read-write separation ##Local directory structure/root - /dev - /mysql-master - /conf.d - docker.cnf - mysql.cnf - /data - /mysql-slave0 - /conf.d - docker.cnf - mysql.cnf - /data ## master configuration file docker.cnf[mysqld]skip-host-cacheskip-name-resolveserver-id = 1log-bin = master-bindefault-storage-engine=INNODBsymbolic-links=0binlog-ignore-db=mysql## masterdocker run -p 3308:3306 \ -v /root/dev/mysql-master/conf.d/:/etc/mysql/conf.d/ \ -v /root/dev/mysql-master/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=123456 \ --privileged=true \ --name mysql-master \ -d mysql \ --character-set-server=utf8mb4 \ --collection-server =utf8mb4_unicode_ci ## slave configuration file [mysqld]skip-host-cacheskip-name-resolveserver-id = 2read-only = 1relay-log = slave-relay-binlog-slave-updates = 1skip-log-binsymbolic-links = 0default-storage-engine=INNODB## slavedocker run -p 3309:3306 \ -v /root/dev/mysql-slave0/conf.d/:/etc/mysql/conf.d/ \ -v /root/dev/mysql-slave0/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=123456 \ --privileged=true \ --name mysql-slave0 \ --link mysql-master:mysql-master-host \ -d mysql \ --character-set-server=utf8mb4 \ --collection-server =utf8mb4_unicode_ci#create user 'rep1'@'%' identified by 'rep1'GRANT REPLICATION SLAVE ON *.* TO rep1@'%' with grant option;flush privileges;##check file and positionshow master status;#stop slave;change master to master_host='mysql-master-host' , master_user='rep1' , master_password='rep1' , master_log_file='master-bin.000003' , master_log_pos=156;start slave;show slave status\G Slave_IO_Running: YesSlave_SQL_Running: Yes Synchronization is correct #Set the permission to write to the library, read the library to write only the permission to read #Note: root account is a super account, setting read-only is invalid. Therefore, you need to open a new account. The steps for setting read-only are as follows: ##Create an account CREATE USER 'base_sa'@'%' identified by 'base_sa';##Authorize. At this time, check the reading database and find that the account has been successfully synchronized. GRANT ALL PRIVILEGES ON testdatabase.* TO 'base_sa'@'%' WITH GRANT OPTION;##How to set read-only library Two methods: Method 1: Set read-only = 1 in docker.cnf configuration file Method 2: Run set global read_only = 1 directly; Thank you for reading, the above is the content of "docker how to build a read-write separation environment", after the study of this article, I believe that everyone has a deeper understanding of how docker builds a read-write separation environment, and the specific use needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.