当前位置:网站首页>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>
边栏推荐
- How to set up an H5 demo of easyplayer locally to play h265 video streams?
- Deep learning environment configuration (III) pytorch GPU under Anaconda
- Direct collection - super easy to use domestic color matching website
- Goframe framework (RK boot): fast implementation of server-side JWT verification
- Buuctf misc-[bjdctf2020] Nani
- Goframe framework (RK boot): rapid configuration of server CORS
- Use of apicloud AVM framework list component list view and flex layout tutorial
- Quick sorting C language code + auxiliary diagram + Notes
- How to make word notes beautiful
- Cut! 39 year old Ali P9 saved 150million
猜你喜欢

Spark broadcast variables and accumulators (cases attached)

Reptile lesson 1

what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!

Performance testing -- Interpretation and practice of 16 enterprise level project framework

My good brother gave me a difficult problem: retry mechanism

Soft exam information system project manager_ Contract Law_ Copyright_ Implementation Regulations - Senior Information System Project Manager of soft exam 030

Analog Electronic Technology

Information theory and coding

Mongodb aggregate query implements multi table associated query, type conversion, and returns specified parameters.

Google account cannot be logged in & external links cannot be opened automatically & words with words cannot be used
随机推荐
Learning about urldns chains
Canvas draw the clock
Use of apicloud AVM framework list component list view and flex layout tutorial
[data preparation and Feature Engineering] perceived data
Goframe framework (RK boot): fast implementation of server-side JWT verification
How to generate DataMatrix code in batch through TXT file
Interviewer: why does TCP shake hands three times and break up four times? Most people can't answer!
Ugui empty button implementation
How to set up an H5 demo of easyplayer locally to play h265 video streams?
Log a log4j2 vulnerability handling
Why is BeanUtils not recommended?
Salesforce fileUpload (I) how to configure the file upload function
Gorilla/mux framework (RK boot): add swagger UI
Soft exam information system project manager_ Contract Law_ Copyright_ Implementation Regulations - Senior Information System Project Manager of soft exam 030
WebService details
OVS port traffic statistics practice
Special exercise split line-----------------------------
Spark broadcast variables and accumulators (cases attached)
PNAs: power spectrum shows obvious bold resting state time process in white matter
Spread spectrum and frequency hopping