后面是与默认配置的差异,这里稍微解释一下
Option | Comment |
---|---|
daemonize no | 不以后台服务的形式运行 |
timeout 1800 | 将超时时间限定为半小时,默认是不限的 |
logfile "/data/redis6379.log" | 指定日志的路径 |
databases 50 | 将数据库设为50个 |
dir /data/ | 指定存储目录 |
dbfilename dump6379.rdb | 指定数据文件名 |
appendfilename "appendonly6379.aof" | 指定append文件名 |
Note: 为什么普通情况下使用redis都是开启后台服务模式,而这里要使用前台模式呢,那是因为,容器化后,必须终结于一个前台进程,否则容器就直接退出了,这涉及容器交互模式运行和后台运行的一些特性
[root@h104 x]# pwd
/tmp/x
[root@h104 x]# ls
redis6379.conf
[root@h104 x]# docker run --name myredis -d -v /tmp/x:/data redis redis-server /data/redis6379.conf
a1a4cfe7e7498827aeeb770744a9443a89212017282b41233cb3c4258a9a0b61
[root@h104 x]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a1a4cfe7e749 redis "docker-entrypoint.sh" 12 seconds ago Up 11 seconds 6379/tcp myredis
[root@h104 x]#
这里对 docker run --name myredis -d -v /tmp/x:/data redis redis-server /data/redis6379.conf
进行一下解析
Option | Comment |
---|---|
docker run | 调用 docker 命令的 run 子命令 |
--name myredis | 给这个容器取名为 myredis |
-d | 后台模式运行 |
-v /tmp/x:/data | 将本地的 /tmp/x 目录挂载到容器中的 /data 目录 |
redis | 使用redis镜像 |
redis-server /data/redis6379.conf | 使用指定的配置初始化并启动redis服务 |
因为本地目录挂载到了容器中,那么日志根据映射就直接记录到了本地
[root@h104 x]# pwd
/tmp/x
[root@h104 x]# ls
redis6379.conf redis6379.log
[root@h104 x]# cat /tmp/x/redis6379.log
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.7 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
1:M 28 Apr 14:47:24.523 # 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 28 Apr 14:47:24.523 # Server started, Redis version 3.0.7
1:M 28 Apr 14:47:24.523 # 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 28 Apr 14:47:24.524 # 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 28 Apr 14:47:24.524 * The server is now ready to accept connections on port 6379
[root@h104 x]#
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。