当前位置:网站首页>Kubesphere - set up redis cluster
Kubesphere - set up redis cluster
2022-07-03 06:07:00 【Xiao bichao】
One 、KubeSphere - build Redis colony
In the last article, we introduced the use of KubeSphere stay k8s Created in mysql Master slave replication structure , In this article, we use KubeSphere stay k8s Build in Redis colony , Here is the address of the last article :
Before the experiment , Please make sure that the installation is complete k8s And kubesphere Environmental Science :
Two 、 establish redis.conf Prepare a dictionary

Name the preparation :
Add data , The key is redis.conf, Value is written in the following :
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
cluster-require-full-coverage no
cluster-migration-barrier 1
appendonly yes


3、 ... and 、 establish redis service
Click Create , Choose stateful Services :
Also create a name for the service :
We choose the number of containers below 6 individual , Build a three master and three slave structure :
What I choose to mirror is redis:6.2.3 Version of , Use the default port , And according to the size of their services , Reasonably set resource limits :
Also specify redis The start command of : redis-server /etc/redis/redis.conf
Click next , Here we need to select the storage volume template , Let different containers correspond to different storage volumes :
Select the storage type 、 Access pattern 、 And container size , And mount redis Of /data :
Then select mount configuration , mount redis.conf :
Select the configuration dictionary created above , And mount /etc/redis Next :
And then the next step , establish , Click this service to enter details , You can see the created container :
Because we all adopt a stateful way , By default Headless, So each redis The interview of , We can all use dns How to use domain name , The format is :
(podname).(headless server name).(namespace).svc.cluster.local
Here we go through : Container name . Service DNS.svc.cluster.local :
So the visit redis-cluster-v1-0 Of redis Words , Direct access redis-cluster-v1-0.redis-cluster.test-project.svc.cluster.local:6379 that will do , Such as into the redis-cluster-v1-2 Terminal , Link to the address above :
So now we can use the domain name redis Cluster initialization , Enter one at random redis Under the terminal of the node , Type in the command , Initialize the cluster :
redis-cli --cluster create redis-cluster-v1-0.redis-cluster.test-project.svc.cluster.local:6379 redis-cluster-v1-0.redis-cluster.test-project.svc.cluster.local:6379 redis-cluster-v1-0.redis-cluster.test-project.svc.cluster.local:6379 redis-cluster-v1-0.redis-cluster.test-project.svc.cluster.local:6379 redis-cluster-v1-0.redis-cluster.test-project.svc.cluster.local:6379 redis-cluster-v1-0.redis-cluster.test-project.svc.cluster.local:6379 --cluster-replicas 1
Enter yes, Use this fragmentation scheme :
You will find that there is an error :
This is because redis The domain name support is not very good , have access to ip + port The way , But in k8s If the container goes down, it will start automatically , After startup ip It's possible to change , So in k8s in Use ip + port It is not advisable to initialize the cluster in the way of , So what's the solution ? Now we can use it Redis-tribe Tools , however Redis-tribe Not recommended and redis Install together , You can start a new one Ubuntu Containers , Dedicated to K8S Management and control of some services within the cluster .
Four 、Redis-tribe initialization Redis colony
Someone has packed it Redis-tribe Mirror image , We can use it directly , This mainly refers to the following article :
https://blog.csdn.net/wangmiaoyan/article/details/106193388
Select Create service , Select directly to yml The way 
Enter the following , Be careful namespace Fill in your project name , Otherwise, it's not in one namespace Next , The container cannot be found in the container group .
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: test-project
labels:
app: redis-cluster-tools
name: redis-cluster-tools
spec:
replicas: 1
selector:
matchLabels:
app: redis-cluster-tools
template:
metadata:
labels:
app: redis-cluster-tools
name: pos-redis
spec:
containers:
- name: pos-redis
image: sunnywang/redis-tools-ubuntu:v0.5.1
imagePullPolicy: IfNotPresent
args:
- /bin/bash
- -c
- sleep 3600
Click create , You can see the created container in the container group .
Click the terminal to enter the container , initialization master node , Pay attention to modify the format of your domain name :
redis-trib.py create `dig +short redis-cluster-v1-0.redis-cluster.test-project.svc.cluster.local`:6379 `dig +short redis-cluster-v1-1.redis-cluster.test-project.svc.cluster.local`:6379 `dig +short redis-cluster-v1-2.redis-cluster.test-project.svc.cluster.local`:6379

And then to master Add replica nodes :
redis-trib.py replicate --master-addr `dig +short redis-cluster-v1-0.redis-cluster.test-project.svc.cluster.local`:6379 --slave-addr `dig +short redis-cluster-v1-3.redis-cluster.test-project.svc.cluster.local`:6379

redis-trib.py replicate --master-addr `dig +short redis-cluster-v1-1.redis-cluster.test-project.svc.cluster.local`:6379 --slave-addr `dig +short redis-cluster-v1-4.redis-cluster.test-project.svc.cluster.local`:6379

redis-trib.py replicate --master-addr `dig +short redis-cluster-v1-2.redis-cluster.test-project.svc.cluster.local`:6379 --slave-addr `dig +short redis-cluster-v1-5.redis-cluster.test-project.svc.cluster.local`:6379

Enter one randomly below redis Check the status of the cluster in the terminal :
cluster info

Here we are redis The cluster has been built successfully .

Love little buddy can pay attention to my personal WeChat official account. , Get more learning materials !
边栏推荐
- Simple handwritten ORM framework
- CAD插件的安裝和自動加載dll、arx
- 理解 期望(均值/估计值)和方差
- Core principles and source code analysis of disruptor
- Code generator - single table query crud - generator
- 从 Amazon Aurora 迁移数据到 TiDB
- 轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
- 从小数据量分库分表 MySQL 合并迁移数据到 TiDB
- [function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram
- [set theory] relational closure (reflexive closure | symmetric closure | transitive closure)
猜你喜欢

Kubernetes notes (IX) kubernetes application encapsulation and expansion

轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷

Apache+php+mysql environment construction is super detailed!!!
![[teacher Zhao Yuqiang] use Oracle's tracking file](/img/0e/698478876d0dbfb37904d7b9ff9aca.jpg)
[teacher Zhao Yuqiang] use Oracle's tracking file

为什么网站打开速度慢?
![[teacher Zhao Yuqiang] calculate aggregation using MapReduce in mongodb](/img/cc/5509b62756dddc6e5d4facbc6a7c5f.jpg)
[teacher Zhao Yuqiang] calculate aggregation using MapReduce in mongodb
![[minesweeping of two-dimensional array application] | [simple version] [detailed steps + code]](/img/b0/aa5dce0bb60c50eea907de9e127d6c.jpg)
[minesweeping of two-dimensional array application] | [simple version] [detailed steps + code]
![[advanced pointer (1)] | detailed explanation of character pointer, pointer array, array pointer](/img/9e/a4558e8e53c9655cbc1a38e8c0536e.jpg)
[advanced pointer (1)] | detailed explanation of character pointer, pointer array, array pointer

Understand one-way hash function

Redhat7 system root user password cracking
随机推荐
CKA certification notes - CKA certification experience post
phpstudy设置项目可以由局域网的其他电脑可以访问
Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
Simple handwritten ORM framework
BeanDefinitionRegistryPostProcessor
[teacher Zhao Yuqiang] MySQL high availability architecture: MHA
Oauth2.0 - user defined mode authorization - SMS verification code login
[teacher Zhao Yuqiang] use the catalog database of Oracle
Deep learning, thinking from one dimensional input to multi-dimensional feature input
MySQL带二进制的库表导出导入
Oauth2.0 - use database to store client information and authorization code
从 Amazon Aurora 迁移数据到 TiDB
Clickhouse learning notes (2): execution plan, table creation optimization, syntax optimization rules, query optimization, data consistency
Txt document download save as solution
Common exceptions when Jenkins is released (continuous update...)
使用 Abp.Zero 搭建第三方登录模块(一):原理篇
JS implements the problem of closing the current child window and refreshing the parent window
CAD插件的安裝和自動加載dll、arx
Crontab command usage
[teacher Zhao Yuqiang] index in mongodb (Part 1)