基于docker 部署redis

1、拉取镜像

复制代码
docker pull redis:latest

如果拉取失败可以尝试下配置镜像源,具体参考如下,目前暂可以使用

Docker切换镜像源-CSDN博客

2、创建配置文件

mkdir /usr/local/redis/conf

vim redis.conf

复制代码
bind 0.0.0.0

#protected-mode no
port 6379
tcp-backlog 511
# 登录密码
requirepass 123456
timeout 0
tcp-keepalive 300
daemonize no
pidfile /var/run/redis_6379.pid
loglevel notice
# 默认没有日志
logfile ""
# 指定日志输出位置
# logfile /var/log/redis/redis-server.log
databases 30
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
appendonly yes
appendfilename "appendonly.aof"
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-max-len 128
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
hz 10
aof-rewrite-incremental-fsync yes

3、执行镜像

复制代码
docker run  -p 6379:6379 --name redis --restart=always \
     -v /usr/local/redis/conf/redis.conf:/etc/redis/redis.conf \
     -v /usr/local/redis/data:/data \
     -d redis redis-server /etc/redis/redis.conf \
     --appendonly yes --requirepass 123456
相关推荐
2601_9620715719 分钟前
数据库系统架构与DBMS功能探微:现代信息时代数据管理的关键
java·开发语言·数据库
梦想的旅途220 分钟前
如何高效调用企业微信通讯录API管理组织架构
java·开发语言·企业微信
2601_962065251 小时前
2.启动mysql容器
java·数据库·mysql
2601_962065491 小时前
PHP For 循环
android·java·php
2601_962201721 小时前
Java进阶,集合,Colllection,常见数据结构
java·数据结构·windows
彷徨而立1 小时前
【C/C++】多线程读写普通 int 变量的一些问题
java·c语言·c++
卓怡学长1 小时前
w175基于springboot校园二手物品交易平台
java·spring boot·spring·maven·intellij-idea
chen<>1 小时前
malloc 和 free 背后发生了什么?
java·linux·服务器·操作系统
sunzy_泽阳1 小时前
Java + Spring 实现 Hermes Agent:从源码看多模型接入、子代理、人审与沙箱
java
2601_961133281 小时前
同花顺期货通指标公式通达信指标
java