docker run -p 6379:6379 --name redis --privileged=true -v D:/docker/redis/redis:/etc/redis -v D:/docker/redis/data:/data -d redis
外面存储D:/docker/redis/redis和D:/docker/redis/data
D:/docker/redis/redis目录下创建文件redis.conf,持久化
requirepass 123
maxclients 10000
#如果要外网访问,请注释掉下面,或者修改为0.0.0.0,保险起见,也可以把protected-mode设置为no
bind 0.0.0.0
protected-mode no
#注意修改这里端口,根据你实际暴露端口情况配置
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
#注意这里要把后台运行设置为no,避免docker后台运行冲突
daemonize no
supervised no
pidfile /docker/redis/redis.pid
loglevel notice
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
#注意修改这里的目录为容器内目录,默认reids进来是在/data/目录
dir /data/
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
replica-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
#注意修改这里的配置,yes开启持久化,no关闭持久化
appendonly yes
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
容器内存储/etc/redis
和/data