在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
一、找到一个合适的docker的redis的版本可以去docker hub中去找一下 https://hub.docker.com/_/redis?tab=tags 二、使用docker安装redissudo docker pull redis 安装好之后使用 truedei@truedei:~$ truedei@truedei:~$ sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 987b78fc9e38 10 days ago 104MB httpd latest a8a9cbaadb0c 2 weeks ago 166MB fjudith/draw.io latest 7b136fc80d31 3 weeks ago 683MB mysql 5.7.29 f5829c0eee9e 5 weeks ago 455MB truedei@truedei:~$ truedei@truedei:~$ 三、准备redis的配置文件因为需要redis的配置文件,这里最好还是去redis的官方去下载一个redis使用里面的配置文件即可 redis中文官方网站:http://www.redis.cn/download.html 下载后解压出来: 这个 四、配置redis.conf配置文件修改
五、创建本地与docker映射的目录,即本地存放的位置创建本地存放redis的位置;
truedei@truedei:redis-5.0.5$ sudo cp -p redis.conf /data/redis/ truedei@truedei:redis-5.0.5$ 把
truedei@truedei:redis-5.0.5$ sudo cp -p redis.conf /data/redis/ truedei@truedei:redis-5.0.5$ 六、启动docker redis启动: truedei@truedei:~$ sudo docker run -p 6379:6379 --name redis -v /data/redis/redis.conf:/etc/redis/redis.conf -v /data/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes 参数解释:
七、查看是否启动成功查看是否成功启动: truedei@truedei:~$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 85cb7d83a2ff redis "docker-entrypoint.s…" 7 minutes ago Up 7 minutes 0.0.0.0:6379->6379/tcp redis 0a122a08125f mysql:5.7.29 "docker-entrypoint.s…" 5 weeks ago Up About an hour 0.0.0.0:3306->3306/tcp, 33060/tcp mysql57 truedei@truedei:~$ 可以查看一下日志: truedei@truedei:~$ sudo docker logs redis 1:C 29 May 2020 01:16:22.107 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 1:C 29 May 2020 01:16:22.107 # Redis version=6.0.3, bits=64, commit=00000000, modified=0, pid=1, just started 1:C 29 May 2020 01:16:22.107 # Configuration loaded _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 6.0.3 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 1 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 1:M 29 May 2020 01:16:22.108 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 1:M 29 May 2020 01:16:22.108 # Server initialized 1:M 29 May 2020 01:16:22.108 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. 1:M 29 May 2020 01:16:22.108 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. 1:M 29 May 2020 01:16:22.108 * Ready to accept connections truedei@truedei:~$ 到此这篇关于最详细的docker中安装并配置redis(图文详解)的文章就介绍到这了,更多相关docker安装配置redis内容请搜索极客世界以前的文章或继续浏览下面的相关文章希望大家以后多多支持极客世界! |
请发表评论