当前位置:网站首页>Redis6.x.x build rediscluster cluster
Redis6.x.x build rediscluster cluster
2022-06-23 22:22:00 【Is paidaxing there】
2.1 Pull redis Mirror image
docker pull redis
3 Create a private network
3.1 Create a private network
establish docker Container's private network , It is convenient to set up a cluster , The network segment is 172.15.0.0 The network name is named redis_net1.(ps:
If you are reminded that the network segment is occupied , Please change to another network segment by yourself , Such as : 172.16.0.01172.17.0.0 ...)
docker network create --subnet=172.15.0.0/16 redis_net1
3.2 Check out the Internet
docker network inspect redis_net1
4 Create a directory in the host
4.1 Create directory /bizwork/redis-cluster
After the /bizwork/redis-cluster The configuration file and data are stored in the directory
mkdir -p /bizwork/redis-cluster
4.2 Get the configuration file ready
stay /bizwork/redis-cluster Under the table of contents create a file redis-cluster.tmpl
vim /bizwork/redis-cluster/redis-cluster.tmpl
Copy the following to redis-cluster.tmpl In file , We will use later
port ${PORT}requirepass 1234
masterauth 1234
protected-mode no
daemonize no
appendonly yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 15000
cluster-announce-ip xx.xx.xx.xx # Your public network IP Or the Internet IP
cluster-announce-port ${PORT}cluster-announce-bus-port 1${PORT}bind 0.0.0.0
In the host machine /bizwork/redis-cluster Batch creation 8000~8005 Catalog , Used as a container mapping directory
for port in `seq 8000 8005`; do \
mkdir -p ./${port}/conf \ && PORT=${port} envsubst < ./redis-cluster.tmpl > ./${port}/conf/redis.conf \ && mkdir -p ./${port}/data; \done
Batch create container
for port in `seq 8000 8005`; do \
docker run -d -ti -p ${port}:${port} -p 1${port}:1${port} \ -v /bizwork/redis-cluster/${port}/conf/redis.conf:/usr/local/etc/redis/redis.conf \ -v /bizwork/redis-cluster/${port}/data:/data \ --restart always --name redis-${port} --net redis_net1 \--sysctl net.core.somaxconn=1024 redis \
redis-server /usr/local/etc/redis/redis.conf;
done
View the network segment of each container
docker network inspect redis_net1
Output results :
[
{"Name": "redis_net1",
"Id": "01cf151982fdcfa6d59a1c0cf1f82e8778ea5caf55e4ef1101501485b402a5f2",
"Created": "2020-12-31T15:17:28.223939985+08:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {"Driver": "default",
"Options": {},"Config": [
{"Subnet": "172.15.0.0/16"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {"Network": ""
},
"ConfigOnly": false,
"Containers": { "2c908a8d54f9701858f774f0532304687b88b8327cac2e6b607cdf56652e3e58": {"Name": "redis-8002",
"EndpointID": "c3866ce9080d1c446c2861280a15b89e53fef524dcba05623bdf9bc5cec74355",
"MacAddress": "02:42:ac:0f:00:04",
"IPv4Address": "172.15.0.4/16",
"IPv6Address": ""
},
"9e73858fd0c192d5be38a5ee9a79650f109f3b669bbcb0e8fb7f3f5105931f85": {"Name": "redis-8001",
"EndpointID": "ef52a366f26a45a06e2da4b4201955308df7379631c9d5dff35691df1cb66fe0",
"MacAddress": "02:42:ac:0f:00:03",
"IPv4Address": "172.15.0.3/16",
"IPv6Address": ""
},
"aef661f9c8e16b490624b1fd4ed7883659addf7b1aacb13ef9c3b4737bb44a5c": {"Name": "redis-8005",
"EndpointID": "c6e74a5a3de2da545d826097c44c686821c65f01164d35986629b9a1d0838cec",
"MacAddress": "02:42:ac:0f:00:07",
"IPv4Address": "172.15.0.7/16",
"IPv6Address": ""
},
"c5320fc978908440ab52f05f821162c38baaebde4a72abce5e66d9827f7fc010": {"Name": "redis-8000",
"EndpointID": "9b73ee6eb6dbd63722b0275471fde1cae2bd5907c60179fcbc25522ba0e84eb5",
"MacAddress": "02:42:ac:0f:00:02",
"IPv4Address": "172.15.0.2/16",
"IPv6Address": ""
},
"c8ad19e2bd4bfe21968b0105d972ab0140707383a8e33a554c5b205df28953bd": {"Name": "redis-8003",
"EndpointID": "4f84d1ff1cef06b267d97fd1904e11836333a7e6e51c687d849b8767dd1be7fe",
"MacAddress": "02:42:ac:0f:00:05",
"IPv4Address": "172.15.0.5/16",
"IPv6Address": ""
},
"e002e46453501bdf3d7e9cd7d214db63fa981ab053cd5e5bdd10b9fb566839ac": {"Name": "redis-8004",
"EndpointID": "cb36c1d2d8902e9d1c04599e86caf51a4d705960be7ac6e8a7b4b26a1175fbe5",
"MacAddress": "02:42:ac:0f:00:06",
"IPv4Address": "172.15.0.6/16",
"IPv6Address": ""
}
},
"Options": {}, "Labels": {}}
]
Here we can see :
- Containers redis-8000 The network segment is 172.15.0.2
- Containers redis-8001 The network segment is 172.15.0.3
- Containers redis-8002 The network segment is 172.15.0.4
- Containers redis-8003 The network segment is 172.15.0.5
- Containers redis-8004 The network segment is 172.15.0.6
- Containers redis-8005 The network segment is 172.15.0.7
5. Create clusters
Enter any container , I enter here redis-8000 Container to execute commands to create a cluster
docker exec -it redis-8000 bash
Use redis-cli --cluster create Command create cluster ( If the password is set , Password parameters are required ) As follows :
redis-cli -a 1234 --cluster create 172.15.0.2:8000 172.15.0.3:8001 172.15.0.4:8002 172.15.0.5:8003 172.15.0.6:8004 172.15.0.7:8005 --cluster-replicas 1
common problem :
Self built redis cluster The pit of tread , I hope it can save you time .
1、 The visit appears Redis: ERR unknown command 'CLUSTER'
After the cluster is configured for the project , Wrong interview ERR unknown command 'CLUSTER', as a result of `redis
cluster The server cluster was not set up successfully , I checked it again , The reason why it failed to build is my redis-8000 Of the container's configuration file cluster-config-file
node_8000.conf With... In other containers cluster-config-file node_8000.conf` identical
2、Redis Cannot use other libraries
Redis Cluster The cluster solution only supports one database (db 0)
3、SpringBoot Configuration cluster failed to start
2021-01-02 21:33:39.990 ERROR 10096 --- [isson-netty-2-7] o.r.cluster.ClusterConnectionManager : Can't connect to master: redis://172.21.0.12:8000 with slot ranges: [[0-5460]]
2021-01-02 21:33:39.991 ERROR 10096 --- [isson-netty-2-8] o.r.cluster.ClusterConnectionManager : Can't connect to master: redis://172.21.0.12:8002 with slot ranges: [[10923-16383]]
2021-01-02 21:33:39.990 ERROR 10096 --- [isson-netty-2-9] o.r.cluster.ClusterConnectionManager : Can't connect to master: redis://172.21.0.12:8001 with slot ranges: [[5461-10922]]
边栏推荐
- Hugegraph: hugegraph Hubble web based visual graph management
- How to defend the security importance of API gateway
- 北大、加州伯克利大學等聯合| Domain-Adaptive Text Classification with Structured Knowledge from Unlabeled Data(基於未標記數據的結構化知識的領域自適應文本分類)
- 2021-12-19: find the missing numbers in all arrays. Give you an n
- WordPress preview email for wocomerce 1.6.8 cross site scripting
- What is the difference between RosettaNet, EDI ANSI X12 and EDIFACT
- 為什麼你的數據圖譜分析圖上只顯示一個值?
- What is dynamic registration? What is static registration?
- API gateway verification token the role of adding a new authentication token in API gateway
- Peking University, University of California Berkeley and others jointly | domain adaptive text classification with structured knowledge from unlabeled data (Domain Adaptive Text Classification Based o
猜你喜欢

MySQL de duplication query only keeps one latest record

為什麼你的數據圖譜分析圖上只顯示一個值?

ICML2022 | 基于对比学习的离线元强化学习的鲁棒任务表示

北大、加州伯克利大学等联合| Domain-Adaptive Text Classification with Structured Knowledge from Unlabeled Data(基于未标记数据的结构化知识的领域自适应文本分类)

Acl2022 | MVR: multi view document representation for open domain retrieval

北大、加州伯克利大學等聯合| Domain-Adaptive Text Classification with Structured Knowledge from Unlabeled Data(基於未標記數據的結構化知識的領域自適應文本分類)

University of North China, Berkeley University of California, etc. | Domain Adaptive Text Classification with structural Knowledge from unlabeled data

游戏安全丨喊话CALL分析-写代码

The latest research progress of domain generalization from CVPR 2022

openGauss Developer Day 2022正式开启,与开发者共建开源数据库根社区
随机推荐
使用 Provider 改造屎一样的代码,代码量降低了2/3!
Low code technology
How to control the quality of omics research—— Mosein
What should be done when the encryptor fails to authenticate in the new version of easycvr?
Take you to understand the lazy loading of pictures
Question: how to understand the network protocol and why the OSI reference model is divided into seven layers
Usage of cobaltstrike: Part 1 (basic usage, listener, redirector)
Peking University, University of California Berkeley and others jointly | domain adaptive text classification with structured knowledge from unlabeled data (Domain Adaptive Text Classification Based o
How to build an API gateway and how to maintain an API gateway?
Impala port
Like playing a game? Take it and use it to build the park scene
5 minutes to explain what is redis?
JWT implementation
Assembly deployment process
KnowDA: All-in-One Knowledge Mixture Model for Data Augmentation in Few-Shot NLP(KnowDA:用于 Few-Shot NLP 中数据增强的多合一知识混合模型)
How to build the server fortress machine? What is the function of the fortress machine?
Using h5ai to build Download Station
How to configure Nessus vulnerability scanning policy?
Kubecon2021 video collection
Freiburg University, Hildesheim University and other universities in Germany jointly | zero shot automl with pre trained models (zero sample automl based on pre training model)