当前位置:网站首页>Docker安装Redis
Docker安装Redis
2022-07-06 10:31:00 【一个正在努力的菜鸡】
Docker安装Redis
1.下载redis镜像

2.创建本地目录方便数据卷映射
- 创建目录结构如下

- 下载redis.conf并修改配置
1.基本配置
#bind 127.0.0.1 #注释掉,使redis可以被外部访问
requirepass a #给redis设置密码a
logfile/data/redis.log #指定日志文件
protected-mode no #关闭保护模式
2.RDB数据文件基本配置
#设置RDB文件名与文件路径
dbfilename dump.rdb #默认
dir /data #./改成/data
#设置快照间隔,可根据实际请求压力调整
save 3600 1 #3600s内有1条key变化就快照,压力小
save 300 100 #300s内有10条key变化就快照
save 60 10000 #60s内有10000条key变化就快照,压力大
#redis是内存库,但内存就怕关机,所以要及时将数据持久化到磁盘
rdbcompression yes #备份文件压缩
rdbchecksum yes #校验码
stop-writes-on-bgsave-error yes #持久化出错,主程序是否停止写入
3.AOF日志文件基本配置
appendonly yes #AOF追加模式备份
dir /data #备份文件存放位置
aof-use-rdb-preamble yes #混合持久化方式
3.启动redis
- 图中语句有错误,正确命令如下代码中

docker run -itd --name redis -p 6379:6379 --restart=always -v d:\dockercontainers\redis\redis.conf:/etc/redis/redis.conf -v d:\dockercontainers\redis\data:/data redis redis-server /etc/redis/redis.conf
4.进入容器
docker exec -it redis /bin/bash
5.下载redis软件,测试连接


边栏推荐
- Introduction to the usage of model view delegate principal-agent mechanism in QT
- Automatic reservation of air tickets in C language
- UDP protocol: simple because of good nature, it is inevitable to encounter "city can play"
- 1700C - Helping the Nature
- HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
- Release of the sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
- Comparative examples of C language pointers *p++, * (p++), * ++p, * (++p), (*p) + +, +(*p)
- 2022 Summer Project Training (II)
- 传输层 拥塞控制-慢开始和拥塞避免 快重传 快恢复
- Declval of template in generic programming
猜你喜欢

微信为什么使用 SQLite 保存聊天记录?

30 分钟看懂 PCA 主成分分析

Take you through ancient Rome, the meta universe bus is coming # Invisible Cities

UDP协议:因性善而简单,难免碰到“城会玩”

Interesting - questions about undefined

Scratch epidemic isolation and nucleic acid detection Analog Electronics Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022

Prophet模型的简介以及案例分析

78 year old professor Huake has been chasing dreams for 40 years, and the domestic database reaches dreams to sprint for IPO

Excellent open source fonts for programmers
![[.Net core] solution to error reporting due to too long request length](/img/62/6bdc43885f9be3fa4538276c0dc122.png)
[.Net core] solution to error reporting due to too long request length
随机推荐
std::true_type和std::false_type
首先看K一个难看的数字
随着MapReduce job实现去加重,多种输出文件夹
Interview shock 62: what are the precautions for group by?
Declval of template in generic programming
[Android] kotlin code writing standardization document
OpenEuler 会长久吗
2019 Alibaba cluster dataset Usage Summary
Virtual machine VirtualBox and vagrant installation
图片缩放中心
Codeforces Round #803 (Div. 2)
1700C - Helping the Nature
1700C - Helping the Nature
测试123
declval(指导函数返回值范例)
Top command details
Brief description of SQL optimization problems
重磅硬核 | 一文聊透对象在 JVM 中的内存布局,以及内存对齐和压缩指针的原理及应用
容器里用systemctl运行服务报错:Failed to get D-Bus connection: Operation not permitted(解决方法)
使用block实现两个页面之间的传统价值观