当前位置:网站首页>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 !
边栏推荐
- [zero basic IOT pwn] reproduce Netgear wnap320 rce
- Mongodb second call -- implementation of mongodb high availability cluster
- tensorflow2-savedmodel convert to tflite
- Junda technology - wechat cloud monitoring scheme for multiple precision air conditioners
- 厦门灌口镇田头村特色农产品 甜头村特色农产品蚂蚁新村7.1答案
- 榨汁机UL982测试项目有哪些
- Day-02 database
- 首届技术播客月开播在即
- 22-06-26周总结
- openssl客户端编程:一个不起眼的函数导致的SSL会话失败问题
猜你喜欢

Cannot link redis when redis is enabled

The markdown editor uses basic syntax
k8s部署redis哨兵的实现

微信网页订阅消息实现

Markdown编辑器使用基本语法

音乐播放器开发实例(可毕设)

Skywalking 6.4 distributed link tracking usage notes
![[advanced ROS] lesson 5 TF coordinate transformation in ROS](/img/4d/ae7d477bf6928005e16f046d461dcb.png)
[advanced ROS] lesson 5 TF coordinate transformation in ROS

竣达技术丨室内空气环境监测终端 pm2.5、温湿度TVOC等多参数监测

Basic operations of SQL database
随机推荐
DirectX repair tool v4.1 public beta! [easy to understand]
Skywalking 6.4 distributed link tracking usage notes
Reorganize the trivial knowledge points at the end of the term
k8s部署redis哨兵的实现
OpenSSL client programming: SSL session failure caused by an insignificant function
Storage form of in-depth analysis data in memory
What is the relationship between network speed, broadband, bandwidth and traffic?
厦门灌口镇田头村特色农产品 甜头村特色农产品蚂蚁新村7.1答案
tensorflow2-savedmodel convert to tflite
TS报错 Don‘t use `object` as a type. The `object` type is currently hard to use
skywalking 6.4 分布式链路跟踪 使用笔记
JVM第一话 -- JVM入门详解以及运行时数据区分析
三十之前一定要明白的职场潜规则
TS reports an error don't use 'object' as a type The `object` type is currently hard to use
Error-tf.function-decorated function tried to create variables on non-first call
QT capture interface is displayed as picture or label
[advanced ROS] lesson 5 TF coordinate transformation in ROS
关于重载运算符的再整理
tensorflow2-savedmodel convert to pb(frozen_graph)
常见健身器材EN ISO 20957认证标准有哪些