当前位置:网站首页>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 !
边栏推荐
- ThreadLocal的简单理解
- Understand expectations (mean / estimate) and variances
- Alibaba cloud OOS file upload
- BeanDefinitionRegistryPostProcessor
- [teacher Zhao Yuqiang] MySQL high availability architecture: MHA
- Oauth2.0 - using JWT to replace token and JWT content enhancement
- BeanDefinitionRegistryPostProcessor
- Cesium 点击获三维坐标(经纬度高程)
- Solve the problem that Anaconda environment cannot be accessed in PowerShell
- QT read write excel -- qxlsx insert chart 5
猜你喜欢
[advanced pointer (2)] | [function pointer, function pointer array, callback function] key analysis + code explanation
Clickhouse learning notes (2): execution plan, table creation optimization, syntax optimization rules, query optimization, data consistency
智牛股项目--05
[teacher Zhao Yuqiang] use Oracle's tracking file
[set theory] relational closure (reflexive closure | symmetric closure | transitive closure)
[teacher Zhao Yuqiang] MySQL high availability architecture: MHA
[function explanation (Part 1)] | | knowledge sorting + code analysis + graphic interpretation
Oauth2.0 - using JWT to replace token and JWT content enhancement
CKA certification notes - CKA certification experience post
有意思的鼠标指针交互探究
随机推荐
Kubernetes notes (VII) kuberetes scheduling
[teacher Zhao Yuqiang] Alibaba cloud big data ACP certified Alibaba big data product system
Kubernetes notes (II) pod usage notes
Understand the first prediction stage of yolov1
Leetcode solution - 01 Two Sum
[explain in depth the creation and destruction of function stack frames] | detailed analysis + graphic analysis
Apple submitted the new MAC model to the regulatory database before the spring conference
Merge and migrate data from small data volume, sub database and sub table Mysql to tidb
多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)
PMP笔记记录
C 语言文件操作函数大全 (超详细)
Solve the problem of automatic disconnection of SecureCRT timeout connection
Intel's new GPU patent shows that its graphics card products will use MCM Packaging Technology
Bernoulli distribution, binomial distribution and Poisson distribution, and the relationship between maximum likelihood (incomplete)
Jackson: what if there is a lack of property- Jackson: What happens if a property is missing?
Code generator - single table query crud - generator
Phpstudy setting items can be accessed by other computers on the LAN
Alibaba cloud OOS file upload
Multithreading and high concurrency (7) -- from reentrantlock to AQS source code (20000 words, one understanding AQS)
pytorch 多分类中的损失函数