当前位置:网站首页>Deploy redis with docker for high availability master-slave replication
Deploy redis with docker for high availability master-slave replication
2022-07-27 05:47:00 【Code world of super Duoduo and Liu baobao】
List of articles
Preface
Why do I need master-slave replication ?
In high concurrency , High availability has become the mainstream today . If there is only one middleware , failure , So easy to cause a single point of failure . Make the service unavailable . Or the middleware is under storage , How to continue to store information has become one of the problems that need to be solved , Then data backup becomes the basic method to solve this problem .
One 、 What is master-slave replication ?
Procedure to redis-master Service write information , This information will be synchronized to other slave Server . In this cluster ,masterd The written data of will be synchronized to slave in , and slave Can't write , Only read . This is in the subsequent sentinel mode ,slave stay master It will become new under fault master.
Two 、 step
1. Pull the mirror image
I've written on my blog before , Just bring it here
1.docker pull redis
2. because redis There is no local redis.conf file , So download one
2. install master
I am here 1.15.233.184 Install under this server master service , No other operation is required during installation , Create mount directory , Just boot it up .
1.mkdir /data/redis/data ( You can also not mount , Look at yourself )
2. take redis.conf Put it in /data/redis Next
3. modify redis.conf The configuration information of is as follows :
1. take bind 127.0.0.1 Comment out , Give Way redis Can be accessed externally
2.protected-mode yes Comment out
3.requirepass 123456 Set the password
3. start-up :
docker run -p 6379:6379 --name redis-master -v /data/redis/redis.conf:/etc/redis/redis.conf -v /data/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes
install slave
This server is 139.9.186.192
I start directly , It's not mounted
1.docker pull redis
2.docker run -it --name redis-slave -d -p 6379:6379 redis redis-server --requirepass 123456
3.docker exec -it redis-slave redis-cli
4.auth 123456
5.slaveof 1.15.233.184 6379
6.config set masterauth 123456
1. Pull the mirror
2. function redis-slave
3. Enter for operation redis client
4. Input redis password
5. As slave To connect master
6. Set up master Password
If you want to mount , Then you can directly modify config File to start the
1.docker pull redis
2. Create mount directory /data/redis/data, A copy of redis.conf To /data/redis Next
3. modify reids.conf Configuration of files
1.# bind 127.0.0.1
2.daemonize yes
3.requirepass 123456 # Slave password , Optional configuration
4.slaveof 1.15.233.184 6379 # <masterip> Indicates the location of the main library ip, and <masterport> Indicates the port that the main library starts , The default is 6379
5.masterauth 123456 # If the master database has a password, it must be configured ,<master-password> Represents the access password of the main library
4.docker run -it --name redis-slave -d -p 6379:6379 -v /data/redis/redis.conf:/etc/redis/redis.conf -v /data/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes
1. Pull the mirror
2. Create mount files and directories
3. Modify the configuration file
4. function
stay master Add key,slave It can also be displayed 
summary
redis There are many other modes of clustering , What I write today is one master and one slave , There is also one master and many followers , The Lord and from much
边栏推荐
猜你喜欢

Web2.0 giants have deployed VC, and tiger Dao VC may become a shortcut to Web3

Fortex方达发布电子交易生态体系 与客户共享共赢

Build a complete system in the maker education movement

graph-node部署

Minimum handling charges and margins for futures companies

手把手教你搭建钉钉预警机器人

MOVE PROTOCOL推出测试版,更可“0撸”参与P2E

minio8.x版本设置policy桶策略

Getaverse,走向Web3的远方桥梁

How to choose a good futures company for futures account opening?
随机推荐
How can seektiger go against the cold air in the market?
「PHP基础知识」整型数据的使用
Web3流量聚合平台Starfish OS,诠释真正商业的“P2E”生态
SeekTiger即将上线STI聚变Mining功能,获取OKA通证
[MRCTF2020]PYWebsite 1
刷脸支付用户主要优势是智能化程度高
Fortex方达发布电子交易生态体系 与客户共享共赢
解析新时代所需要的创客教育DNA
哪个期货公司手续费低高交返?
Page configuration
NFT新范式,OKALEIDO创新NFT聚合交易生态
jenkins构建镜像自动化部署
How to judge whether a property belongs to an instance object or inherits from a constructor in JS
NFT new paradigm, okaleido innovation NFT aggregation trading ecosystem
ES时间查询报错 - “caused_by“:{“type“:“illegal_argument_exception“,“reason“:“failed to parse date field
刷脸商业逻辑重大改变商户争抢烽烟再起
minio8.x版本设置policy桶策略
Sealem Finance - a new decentralized financial platform based on Web3
Arguments class array in JS
dbswitch数据迁移数据增量时如何不覆盖目标源数据