redis 安装
redis 安装
redis配置文件解释
//redis.conf 配置
#绑定到哪台机器,0.0.0.0表示允许所有主机访问
bind 0.0.0.0
#redis3.2版本之后加入的特性,yes开启后,如果没有配置bind则默认只允许127.0.0.1访问
protected-mode yes
#对外暴露的访问端口
port 6379
#三次握手的时候server端接收到客户端 ack确认号之后的队列值
tcp-backlog 511
#服务端与客户端连接超时时间,0表示永不超时
timeout 0
#连接redis的时候的密码 hello
requirepass hello
#tcp 保持会话时间是300s
tcp-keepalive 300
#redis是否以守护进程运行,如果是,会生成pid
daemonize yes
supervised no
#pid文件路径
pidfile /var/run/redis_6379.pid
#日志级别
loglevel notice
#默认redis有几个db库
databases 16
#每间隔900秒,如果一个键值发生变化就触发快照机制
save 900 1
save 300 10
save 60 10000
#快照出错时,是否禁止redis写入
stop-writes-on-bgsave-error no
#持久化到rdb文件时,是否压缩文件
rdbcompression no
#持久化到rdb文件是,是否RC64开启验证
rdbchecksum no
#持久化输出的时候,rdb文件命名
dbfilename dump.rdb
#持久化文件路径
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
#是否开启aof备份
appendonly yes
#aof备份文件名称
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
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
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
#客户端最大连接数
maxclients 20000
#重命名一些危险操作,这里可选
#rename-command FLUSHALL abcdefghi
#rename-command FLUSHDB 123456778
docker安装redis
mkdir -p /opt/redis/
vim /opt/redis/redis.conf
protected-mode no
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile ""
databases 16
always-show-logo yes
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
requirepass YuaNian@2999!
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
oom-score-adj no
oom-score-adj-values 0 200 800
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
docker run -itd --name redis-for-cicd -v /opt/redis/redis.conf:/usr/local/etc/redis/redis.conf -p 6379:6379 liwenchao1995/redis:6.0.9
执行完后,配置文件外挂,端口是6379,如果没有防火墙限制就可以直接用了
docker-compose安装redis
redis配置文件提前准备,详细配置可以参考上面redis配置解释进行删减
redis配置
protected-mode no
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
loglevel notice
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
rdb-del-sync-files no
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 yes
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
bind 0.0.0.0
pidfile /pid/base_redis705_16379.pid
logfile "/logs/base_redis705_16379.log"
dbfilename base_redis705_16379dump.rdb
dir /data
appendfilename "base_redis705_16379appendonly.aof"
yml文件
version: '3.3'
networks:
zy-base-network:
driver: bridge
ipam:
config:
- subnet: 10.201.0.0/24
services:
redis7:
image: redis:7.0.5
container_name: redis7
volumes:
- "/dpss/services/dpss_base/redis:/usr/local/etc/redis"
- "/dpss/data/dpss_base_data/redis:/data"
- "/dpss/logs/dpss_base_logs/redis:/logs"
environment:
- TZ=Asia/Shanghai
networks:
zy-base-network:
aliases:
- redis7
ports:
- 6379:6379
ulimits:
memlock:
soft: -1
hard: -1
command: [ "redis-server", "/usr/local/etc/redis/redis.conf"]
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!