docker方式实现redis数据持久化离线安装

图片

保存镜像

root@hello:~# docker pull redis:latest
latest: Pulling from library/redis
a2abf6c4d29d: Already exists 
c7a4e4382001: Pull complete 
4044b9ba67c9: Pull complete 
c8388a79482f: Pull complete 
413c8bb60be2: Pull complete 
1abfd3011519: Pull complete 
Digest: sha256:db485f2e245b5b3329fdc7eff4eb00f913e09d8feb9ca720788059fdc2ed8339
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest
root@hello:~# 
root@hello:~# docker save > redis.tar redis:latest 
root@hello:~# 
root@hello:~# ll redis.tar 
-rw-r--r-- 1 root root 116304384 Mar 30 07:30 redis.tar
root@hello:~#

导入镜像

创建目录,修改配置

修改redis.conf配置文件:

主要配置的如下:

bind 127.0.0.1 #注释掉这部分,使redis可以外部访问

daemonize no#用守护线程的方式启动

requirepass thinekr #给redis设置密码

appendonly yes #redis持久化  默认是no

tcp-keepalive 300 #防止出现远程主机强迫关闭了一个现有的连接的错误 默认是300

启动容器

测试

https://www.oiox.cn/

https://www.chenby.cn/

https://cby-chen.github.io/

https://weibo.com/u/5982474121

https://blog.csdn.net/qq_33921750

https://my.oschina.net/u/3981543

https://www.zhihu.com/people/chen-bu-yun-2

https://segmentfault.com/u/hppyvyv6/articles

https://juejin.cn/user/3315782802482007

https://space.bilibili.com/352476552/article

https://cloud.tencent.com/developer/column/93230

https://www.jianshu.com/u/0f894314ae2c

https://www.toutiao.com/c/user/token/MS4wLjABAAAAeqOrhjsoRZSj7iBJbjLJyMwYT5D0mLOgCoo4pEmpr4A/

CSDN、GitHub、知乎、开源中国、思否、掘金、简书、腾讯云、哔哩哔哩、今日头条、新浪微博、个人博客、全网可搜《小陈运维》

最后更新于