欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 新车 > docker 安装redis 7.4.2并挂载配置文件以及设置密码

docker 安装redis 7.4.2并挂载配置文件以及设置密码

2025/2/24 21:18:54 来源:https://blog.csdn.net/qq_49841284/article/details/145781036  浏览:    关键词:docker 安装redis 7.4.2并挂载配置文件以及设置密码

文章目录

  • docker 安装redis 7.4.2
    • 下载 redis
    • 如果你喜欢使用最新的版本
    • 创建挂载redis 配置文件
    • 创建容器

docker 安装redis 7.4.2

截至2025年2月21日,Redis的最新稳定版本是 7.4.2。

下载 redis

如果你想拉取Redis的特定版本(例如最新的稳定版本 7.4.2),可以使用以下命令

docker pull redis:7.4.2

如果你喜欢使用最新的版本

如果你想使用Redis的最新稳定版本(由latest标签指向)

docker pull redis:latest

拉取镜像后,你可以使用以下命令查看本地已下载的Docker镜像

docker images

在这里插入图片描述

创建挂载redis 配置文件

在 /docker/redis 目录下创建两个子目录:conf 和 data

mkdir -p /docker/redis/{conf,data}

切换到 /docker/redis/conf 目录,方便后续操作。

cd docker/redis/conf

在 /docker/redis/conf 目录下创建一个空的 redis.conf 文件

touch redis.conf

使用 vim 编辑器打开 redis.conf 文件,进行配置

vim redis.conf

redis.conf 配置信息

bind 0.0.0.0protected-mode yesport 6379tcp-backlog 511timeout 0tcp-keepalive 300daemonize nosupervised nopidfile /docker/redis/redis_6379.pidloglevel noticelogfile ""databases 16always-show-logo yessave 900 1
save 300 10
save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbrdb-del-sync-files nodir ./replica-serve-stale-data yesreplica-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-diskless-load disabledrepl-disable-tcp-nodelay noreplica-priority 100acllog-max-len 128lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush nolazyfree-lazy-user-del nooom-score-adj nooom-score-adj-values 0 200 800appendonly yesappendfilename "appendonly.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mbaof-load-truncated yesaof-use-rdb-preamble yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512
hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128
zset-max-ziplist-value 64hll-sparse-max-bytes 3000stream-node-max-bytes 4096
stream-node-max-entries 100activerehashing yesclient-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60hz 10dynamic-hz yesaof-rewrite-incremental-fsync yesrdb-save-incremental-fsync yesjemalloc-bg-thread yes

退出编辑

创建容器

docker run -p 6379:6379 --name redis -v /docker/redis/conf:/etc/redis/redis.conf -d redis --requirepass "123456"

在这里插入图片描述

如果是云服务器,记得配置安全组
在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词