当前位置:网站首页>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 !
边栏推荐
- [written examination question analysis] | | get [sizeof and strlen] [pointer and array] graphic explanation + code analysis
- Simple handwritten ORM framework
- pytorch DataLoader实现miniBatch(未完成)
- Clickhouse learning notes (I): Clickhouse installation, data type, table engine, SQL operation
- 1. 两数之和
- Kubernetes notes (VIII) kubernetes security
- Understand the first prediction stage of yolov1
- How to create and configure ZABBIX
- 有意思的鼠标指针交互探究
- Jackson: what if there is a lack of property- Jackson: What happens if a property is missing?
猜你喜欢
项目总结--04
Es remote cluster configuration and cross cluster search
Kubernetes notes (10) kubernetes Monitoring & debugging
[trivia of two-dimensional array application] | [simple version] [detailed steps + code]
Skywalking8.7 source code analysis (I): agent startup process, agent configuration loading process, custom class loader agentclassloader, plug-in definition system, plug-in loading
Tabbar settings
Solve the 1251 client does not support authentication protocol error of Navicat for MySQL connection MySQL 8.0.11
[teacher Zhao Yuqiang] Cassandra foundation of NoSQL database
Clickhouse learning notes (I): Clickhouse installation, data type, table engine, SQL operation
The most responsible command line beautification tutorial
随机推荐
The server data is all gone! Thinking caused by a RAID5 crash
[teacher Zhao Yuqiang] calculate aggregation using MapReduce in mongodb
[written examination question analysis] | | get [sizeof and strlen] [pointer and array] graphic explanation + code analysis
Leetcode solution - 02 Add Two Numbers
Download the corresponding version of chromedriver
BeanDefinitionRegistryPostProcessor
Apt update and apt upgrade commands - what is the difference?
Skywalking8.7 source code analysis (II): Custom agent, service loading, witness component version identification, transform workflow
BeanDefinitionRegistryPostProcessor
Personal outlook | looking forward to the future from Xiaobai's self analysis and future planning
CAD插件的安裝和自動加載dll、arx
Mysql database table export and import with binary
Es remote cluster configuration and cross cluster search
Multithreading and high concurrency (7) -- from reentrantlock to AQS source code (20000 words, one understanding AQS)
[teacher Zhao Yuqiang] MySQL flashback
JDBC connection database steps
Detailed explanation of contextclassloader
[teacher Zhao Yuqiang] Cassandra foundation of NoSQL database
[teacher Zhao Yuqiang] kubernetes' probe
Understand the first prediction stage of yolov1