当前位置:网站首页>Implementation of deploying redis sentry in k8s
Implementation of deploying redis sentry in k8s
2022-07-01 15:05:00 【1024 questions】
One 、 Get ready redis Mirror image
Two 、 Get ready k8s yml—redis-sentinel.yml
3、 ... and 、 see redis Sentinel information
Four 、 Connect redis sentry
One 、 Get ready redis Mirror imageDockerfile
FROM redis:6.0MAINTAINER Operation and maintenance @ Soldier COPY *.conf /opt/conf/COPY run.sh /opt/run.shRUN apt update -y;apt-get install vim net-tools -y;apt-get clean && \ chmod +x /opt/run.shCMD /opt/run.shredis The configuration file redis.conf
# To which machine ,0.0.0.0 Indicates that all hosts are allowed to access bind 0.0.0.0#redis3.2 Features added after version ,yes After opening , If not configured bind Only... Is allowed by default 127.0.0.1 visit protected-mode yes# Exposed access port port 6379# The login password requirepass devops# Master slave synchronous authentication password masterauth devops# Three handshakes server The end receives the client ack The queue value after the confirmation number tcp-backlog 511# Timeout of connection between server and client ,0 Means never time out timeout 0# Connect redis The password at the time of hello#requirepass hello#tcp Keep the conversation for 300stcp-keepalive 300#redis Whether to run as a daemons , If it is , Will generate piddaemonize yessupervised no#pid File path pidfile /var/run/redis_6379.pid# The level of logging loglevel noticelogfile /var/log/redis.log# Default redis There are several db library databases 32# Every interval 900 second , If a key value changes, the snapshot mechanism is triggered save 900 1save 300 10save 60 10000# Error in snapshot , Whether to ban redis write in stop-writes-on-bgsave-error no# Persist to rdb When you file , Whether to compress the file rdbcompression no# Persist to rdb File is , whether RC64 Turn on Validation rdbchecksum no# When persisting output ,rdb File naming dbfilename dump.rdb# Persistent file path slave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100# Open or not aof Backup appendonly yes#aof Backup file name appendfilename "appendonly.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes# Maximum number of client connections maxclients 20000lazyfree-lazy-eviction yeslazyfree-lazy-expire yeslazyfree-lazy-server-del yesslave-lazy-flush yesredis Sentry profile sentinel.conf
# sentry sentinel The port on which the instance runs Default 26379port 26379# sentry sentinel Working directory of dir "/tmp"sentinel deny-scripts-reconfig yessentinel monitor mymaster redis-0.redis 6379 2sentinel auth-pass mymaster devopssentinel down-after-milliseconds mymaster 5000sentinel failover-timeout mymaster 15000# Set up 5 No response in seconds , The server is down , You need to put the configuration in sentinel monitor master 127.0.0.1 6379 below sentinel parallel-syncs mymaster 2# Set up 15 Seconds master Not alive , Re elect the Lord sentinel config-epoch mymaster 3#. Said if master After re selecting , Other slave Nodes can run in parallel at the same time master How many synchronous caches are there , Obviously the greater the value , all slave The faster the node can complete the synchronous handover , But if someone happens to be visiting these slave, It's possible to make # Failed to read , It will have a wider impact . The most stable setting is 1, Only at the same time , Only one can do it , So other slave And continue to serve , But all slave The process of complete cache update synchronization will be slow .sentinel leader-epoch mymaster 3 The startup script run.sh
#!/bin/bashpod_seq=$(echo $POD_NAME | awk -F"-" '{print $2}')if [[ ${pod_seq} -ne 0 ]];then # For slave sed -i '/^slaveof /d' /opt/conf/redis.conf echo "slaveof redis-0.redis 6379" >> /opt/conf/redis.conf#redis-0.redis On behalf of the first redis Access address of fi/usr/local/bin/redis-server /opt/conf/redis.confsleep 15 # If redis-0 Didn't get up , The sentry in it can't get up , Wait a while before starting the sentry /usr/local/bin/redis-sentinel /opt/conf/sentinel.conf &tail -f /var/log/redis.log Build a mirror image
docker build --pull -t 192.168.1.2/common/redis_sentinel:6.0 .docker push 192.168.1.2/common/redis_sentinel:6.0 Two 、 Get ready k8s yml—redis-sentinel.ymlStatefulSet Please refer to :K8S And StatefulSet Stateful service
apiVersion: apps/v1kind: StatefulSetmetadata: name: redis namespace: redis-nsspec: serviceName: redis selector: matchLabels: app: redis replicas: 3 template: metadata: labels: app: redis spec: nodeSelector: productLine: redis-ns area: wuhan restartPolicy: Always containers: - name: redis image: 192.168.1.2/common/redis_sentinel:6.0 imagePullPolicy: Always env: - name: POD_NAME valueFrom: fieldRef: fieldPath: metadata.name livenessProbe: tcpSocket: port: 6379 initialDelaySeconds: 3 periodSeconds: 5 readinessProbe: tcpSocket: port: 6379 initialDelaySeconds: 3 periodSeconds: 5 ports: - containerPort: 6379 resources: requests: memory: 256Mi cpu: 50m limits: memory: 256Mi cpu: 200m---apiVersion: v1kind: Servicemetadata: name: redis namespace: redis-nsspec: type: NodePort ports: - name: redis port: 6379 targetPort: 6379 nodePort: 26380 selector: app: rediskubectl apply -f redis-sentinel.yml
Will create three redis pod
kubectl get pod -n redis-ns
kubectl exec -it redis-0 -n redis-ns -- [email protected]:/data# redis-cli127.0.0.1:6379> AUTH devops127.0.0.1:6379> info Replication# View master-slave information 
127.0.0.1:6379> [email protected]:/data# redis-cli -p 26379127.0.0.1:26379> info sentinel# Check the sentry information 
k8s Other command space java Process connection redis sentry
127.0.0.1:6379> [email protected]:/data# redis-cli -p 26379127.0.0.1:26379> info sentinel# Check the sentry information Client connection redis
node node IP:26380 password :devops
This is about k8s Deploy redis This is the end of the article on the implementation of sentinel , More about k8s Deploy redis sentry Please search the previous articles of software development network or continue to browse the relevant articles below. I hope you will support software development network more in the future !
边栏推荐
- TS reports an error don't use 'object' as a type The `object` type is currently hard to use
- 数据产品经理需要掌握哪些数据能力?
- Intelligent operation and maintenance practice: banking business process and single transaction tracking
- Day-02 database
- Redis installation and setting up SSDB master-slave environment under Ubuntu 14.04
- opencv学习笔记四--银行卡号识别
- 定了!2022海南二级造价工程师考试时间确定!报名通道已开启!
- Internet hospital system source code hospital applet source code smart hospital source code online consultation system source code
- MongoDB第二話 -- MongoDB高可用集群實現
- 项目中字符串判空总结
猜你喜欢

MySQL审计插件介绍

Opencv Learning Notes 6 -- image mosaic

JVM第二话 -- JVM内存模型以及垃圾回收

opencv学习笔记四--银行卡号识别

The data in the database table recursively forms a closed-loop data. How can we get these data
k8s部署redis哨兵的实现

炎炎夏日,这份安全用气指南请街坊们收好!

Junda technology indoor air environment monitoring terminal PM2.5, temperature and humidity TVOC and other multi parameter monitoring

Basic use process of cmake

关于重载运算符的再整理
随机推荐
网速、宽带、带宽、流量三者之间的关系是什么?
官宣:Apache Doris 顺利毕业,成为 ASF 顶级项目!
Markdown编辑器使用基本语法
Opencv learning notes 5 -- document scanning +ocr character recognition
Day-02 database
The difference between arrow function and ordinary function in JS
竣达技术丨室内空气环境监测终端 pm2.5、温湿度TVOC等多参数监测
数字化转型:数据可视化赋能销售管理
SQL常用的四个排序函数梳理
skywalking 6.4 分布式链路跟踪 使用笔记
Mongodb second call -- implementation of mongodb high availability cluster
Hidden rules of the workplace that must be understood before 30
APK签名原理
厦门灌口镇田头村特色农产品 甜头村特色农产品蚂蚁新村7.1答案
Internet hospital system source code hospital applet source code smart hospital source code online consultation system source code
Storage form of in-depth analysis data in memory
TypeScript:const
Apk signature principle
Flink 系例 之 TableAPI & SQL 与 MYSQL 分组统计
Wechat official account subscription message Wx open subscribe implementation and pit closure guide