redis线上配置

关闭了持久化,和对客户端的链接进行了简单的调优,使用的是本地存储。

redis.conf: |-
   dir /tmp
   #appendonly yes
   #appendfsync everysec
   #auto-aof-rewrite-percentage 100
   #auto-aof-rewrite-min-size 64mb
   #aof-load-truncated yes
   #dbfilename dump.rdb
   #save 60 100000
   save ""
   maxclients 65535
   maxmemory 6G
   slowlog-log-slower-than 10000
   slowlog-max-len 128
   timeout 10
   tcp-keepalive 30

第二份

cm
  redis.conf: |-
    # User-supplied common configuration:
    dir /data
    appendonly yes

    appendfsync everysec
    auto-aof-rewrite-percentage 100
    auto-aof-rewrite-min-size 64mb
    aof-load-truncated yes
    dbfilename dump.rdb
    save 60 10000
    # End of common configuration

# 如果是用的host的网络模式
# sts 两个容器的HOSTNAME变量需要修改
        - name: HOSTNAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.name
--- pod的调度
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - preference:
              matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - k8s-node-06
                - k8s-node-07
                - k8s-node-08
            weight: 100

# 正式现在的配置
  redis.conf: |-
    dir /tmp
    save ""
    maxclients 65535
    maxmemory 6G
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    timeout 10
    tcp-keepalive 30

# DNS 策略需要修改
      dnsPolicy: ClusterFirstWithHostNet

# 主机网络模式需要修改
      hostNetwork: true

auth  AdVj
#列出所有被监视的主服务器
127.0.0.1:26380> SENTINEL masters

#列出所有被监视的从服务器
127.0.0.1:26380> SENTINEL slaves mymaster

# 模拟master漂移
SENTINEL failover mymaster

#返回给定名字的主服务器的IP地址和端口号
127.0.0.1:26380> SENTINEL get-master-addr-by-name mymaster
1) "172.16.1.51"
2) "6379


kubectl -n jian-butler exec -it redis-node-2 -- redis-cli -p 26379 --pass AdVj SENTINEL masters
nkubectl -n jian-butler exec -it redis-node-2 -- redis-cli -p 6379 --pass AdVj info replication

# 启动的探针
        startupProbe:
          exec:
            command:
            - sh
            - -c
            - /health/ping_sentinel.sh 5
			
        readinessProbe:
          exec:
            command:
            - sh
            - -c
            - /health/ping_sentinel.sh 1
			
            command:
            - sh
            - -c
            - /health/ping_sentinel.sh 5

      securityContext:
        sysctls:
          - name: net.core.somaxconn
            value: "2048"
          - name: net.core.somaxconn
            value: "2048"



# 晚上要修改的两个参数
1、仲裁节点是 2
2、数据目录是  /tmp
3、取消持久化配置
4、测试漂移。


timeout:                     这是控制客户端连接的最大空闲时间的配置项。如果一个连接在指定的时间内没有任何操作,它将被关闭。
tcp-keepalive:               这是TCP保活的配置项,用于检测长时间空闲的连接。如果启用,它将在一定时间内发送TCP保活包,以确保连接的存活性。
client-output-buffer-limit:  如果客户端的输出缓冲区超过指定的限制,连接可能会被关闭。这也可以被视为一种连接超时的保护机制。


config set timeout 10
当一个redis-client一直没有请求发向server端,那么server端有权主动关闭这个连接,可以通过timeout来设置“空闲超时时限”,0表示永不关闭。

config set tcp-keepalive 30
连接保活策略,可以通过tcp-keepalive配置项来进行设置,单位为秒,假如设置为60秒,则server端会每60秒向连接空闲的客户端发起一次ACK请求,以检查客户端是否已经挂掉,对于无响应的客户端则会关闭其连接。所以关闭一个连接最长需要120秒的时间。如果设置为0,则不会进行保活检测。

---

      initContainers:
        - image: busybox
          command:
            - sh
            - -c
            - |
              sysctl -w net.core.somaxconn=65535
              sysctl -w fs.file-max=1048576
          imagePullPolicy: Always
          name: setsysctl
          securityContext:
            privileged: true
posted @ 2024-02-27 17:01  Gshelldon  阅读(2)  评论(0编辑  收藏  举报