|NO.Z.00255|——————————|CloudNative|——|KuberNetes&中间件容器化及helm.V02|——|中间件.v02|redis.v5.0.4|ratel方式部署|

一、部署Redis到k8s上:通过资源管理创建
### --- 下载官方redis.conf配置模板:
~~~     官方地址:

[root@k8s-master01 redis]#  wget -c http://download.redis.io/redis-stable/redis.conf
### --- 取消配置文件中的空格及注释#号

[root@k8s-master01 redis]# grep -v "#" redis.conf |grep -v "^$"
### --- 获取到的配置文件参数如下

[root@k8s-master01 redis]# vim redis.conf 

bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "/tmp/redis.log"        # log日志地址
databases 16
always-show-logo no
set-proc-title yes
proc-title-template "{title} {listen-addr} {server-mode}"
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir /data                       # dir地址更改为data
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
acllog-max-len 128
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
lazyfree-lazy-user-flush no
oom-score-adj no
oom-score-adj-values 0 200 800
disable-thp yes
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
jemalloc-bg-thread yes
二、创建redis-configmap:
### --- 创建redis-configmap:通过资源管理平台来创建配置文件,通过configmap的配置来修改

~~~     ——>创建configmap:资源配置——>ConfigMap——>选择集群:test1
~~~     ——>namespace:ratel-test1——>configmap名称:redis-conf——>Data名称:redis.conf
~~~     ——>数据:redis.conf模板——>Create——>END
三、创建redis-deployment
### --- 下载一个redis的5.0.4-alpine镜像

[root@k8s-master01 redis]# docker images | grep redis
redis                                                             latest         bc8d70f9ef6c   5 days ago      105MB
redis                                                             5.0.4-alpine   631bf69df08e   2 years ago     50.9MB
### --- 创建redis-deployment

~~~     # 创建deployment:deployment——>
~~~     ——>Metadata:选择集群:test1——>Namespace:retal-test1——>Name:redis-single-node——>重启策略——>Always——>DNS策略:ClusterFirst——>节点故障停留时间——>副本数:1——>尽量部署在不同宿主机上——>NEXT
~~~     ——>Volumes:volumes——>名称:redis-conf——>Voume类型:ConfigMap——>ConfigMap名称:redis-configmap——>Next
~~~     # ——>Containers:容器名称:redis-single-node——>镜像地址:redis:5.0.4-alpine
~~~     ——>启动命令:sh,,,-c,,,redis-server"/mnt/redis.conf"
~~~     ——>Memory Request&limit(单位:Mi):10~399
~~~     ——>LivenessProbe健康检查:准备时间:10;检查端口:6379;检查方式:tcpSocket
~~~     ——>ReadinessProbe:准备时间:10;检查端口:6379;检查方式:tcpSocket
~~~     ——>镜像下载策略:IfNotPresent——>容器端口:6379
~~~     ——>文件挂载:Volume名称:redis-conf;挂载目录:/mnt;只读:true——>Next
~~~     # ——>Init Containers:——>Next
~~~     ——>Services:添加Service——>默认——>Next
~~~     ——>Ingress:Create——>END
四、查看创建的redis单节点pod
### --- 查看启动的redis的pod

[root@k8s-master01 redis]# kubectl get po -n ratel-test1 -owide
NAME                                READY   STATUS    RESTARTS   AGE   IP              NODE           NOMINATED NODE   READINESS GATES
redis-single-node-df78c5db8-jlbcn   1/1     Running   0          15m   172.25.92.115   k8s-master02   <none>           <none>
### --- 查看启动的svc

[root@k8s-master01 redis]# kubectl get svc -n ratel-test1 -owide
NAME                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE   SELECTOR
redis-single-node   ClusterIP   10.107.230.191   <none>        6379/TCP   41m   app=redis-single-node
### --- 查看启动的ep

[root@k8s-master01 redis]# kubectl get ep -n ratel-test1 -owide
NAME                ENDPOINTS            AGE
redis-single-node   172.25.92.115:6379   41m

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(36)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示