当前位置:网站首页>Docker builds MySQL master-slave
Docker builds MySQL master-slave
2022-06-23 02:43:00 【buiu】
mysql Master-slave
# Lord mysql start-up docker run --privileged=true -d -p 3307:3306 --name='mysql_master' \ -e MYSQL_ROOT_PASSWORD=123456 \ -v /opt/mysql_master/log:/var/log/mysql \ -v /opt/mysql_master/data:/var/lib/mysql \ -v /opt/mysql_master/conf:/etc/mysql/conf.d mysql # from mysql start-up docker run --privileged=true -d -p 3308:3306 \ -e MYSQL_ROOT_PASSWORD=123456 --name='mysql_slave' \ -v /opt/mysql_slave/log:/var/log/mysql \ -v /opt/mysql_slave/data:/var/lib/mysql \ -v /opt/mysql_slave/conf:/etc/mysql/conf.d mysql # Lord mysql To configure # Lord mysql The configuration file vim /opt/mysql_master/conf/my.cnf # Restart master mysql docker restart mysql_master docker exec -it mysql_master /bin/bash # Create a user for data synchronization mysql -uroot -p123456 create user 'slave'@'%' identified by '123456'; grant replication slave,replication client on *.* to 'slave'@'%'; # Access configuration # Confirm master mysql Master slave status of show master status; # from mysql To configure # from mysql The configuration file vim /opt/mysql_slave/conf/my.cnf # Restart from mysql docker restart mysql_slave docker exec -it mysql_slave /bin/bash mysql -uroot -p123456 # Configure master-slave replication change master to master_host='10.122.1.86', master_user='slave', master_password='123456', master_port=3307, master_log_file='mall-mysql-bin.000001', master_log_pos=784, master_connect_retry=30; # Parameters, : master_log_file and master_log_pos In the main mysql Use in show master status; master_connect_retry Connection failure retry interval ; master_log_pos Specify where the database starts copying data # Enable master-slave replication start slave; # confirm show slave status \G;
<details>
<summary> Lord mysql The configuration file </summary>
<pre><code>
mysqld
It should be unique in the same LAN
server-id=101
Specify the name of the database that does not need to be synchronized
binlog-ignore-db=mysql
Turn on binary log
log-bin=mall-mysql-bin
Set the memory size of binary log ( Business )
binlog_cache_size=1M
Set the binary log format to use (mixed, statement, row)
binlog_format=mixed
Binary log expiration cleanup time , The default value is 0, Does not automatically clean up
expire_logs_days=7
Skip the types of some errors encountered during master-slave replication
slave_skip_errors=1062
</code></pre>
</details>
<details>
<summary> from mysql The configuration file </summary>
<pre><code>
mysqld
It should be unique in the same LAN
server-id=102
Specify the name of the database that does not need to be synchronized
binlog-ignore-db=mysql
Turn on binary log function , in preparation for slave As an instance of other databases master When using
log-bin=mall-mysql-slave1-bin
Set the memory size of binary log ( Business )
binlog_cache_size=1M
Set the binary log format to use (mixed, statement, row)
binlog_format=mixed
Binary log expiration cleanup time , The default value is 0, Does not automatically clean up
expire_logs_days=7
Skip the types of some errors encountered during master-slave replication
slave_skip_errors=1062
relay_log Configure relay logs
relay_log=mall-mysql-relay-bin
log_slave_updates Express slave Write the copy event to your own binary log
log_slave_updates=1
slave Set to read only
read_only=1
</code></pre>
</details>
边栏推荐
- [data preparation and Feature Engineering] data cleaning
- How PHP uses redis
- Detailed explanation of online reputation management
- How to set up an H5 demo of easyplayer locally to play h265 video streams?
- Interviewer: why does TCP shake hands three times and break up four times? Most people can't answer!
- Single chip microcomputer (STC series 8051 core single chip microcomputer)
- Analog Electronic Technology
- Gorilla/mux framework (RK boot): add swagger UI
- Chapter 3 tensorflow linear regression
- Summary of easy-to-use MySQL interview questions (Part 1)
猜你喜欢

Vulnhub DC-5

Spark broadcast variables and accumulators (cases attached)

Performance test -- Jenkins environment construction for 15jmeter performance test

Nebula operator cloud practice

Cut! 39 year old Ali P9 saved 150million

Application and challenge of ten billion level map data in Kwai security intelligence

WebService details

Understand GB, gbdt and xgboost step by step

Interviewer: with the for loop, why do you need foreach??

Xgboost principle
随机推荐
Reptile lesson 1
Learning about urldns chains
Mobile communication Overview - Architecture
Get the structure of the class through reflection, little chestnut
Weekly Postgres world news 2022w04
About the use of mock framework
Analysis of ThreadLocal
Docker installs mysql5.7 and mounts the configuration file
Tencent cloud server CVM system tool configuration
Source code analysis | activity setcontentview I don't flash
Ansible practice of Nepal graph
Small knowledge points of asset
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
Understand GB, gbdt and xgboost step by step
Nebula operator cloud practice
Spark broadcast variables and accumulators (cases attached)
How to set up an H5 demo of easyplayer locally to play h265 video streams?
Log a log4j2 vulnerability handling
PNAs: power spectrum shows obvious bold resting state time process in white matter
Simple implementation of promise basic method