问题描述
开发环境:macbookpro 10.11.4,docker for mac 1.12.3,redis 3.2.6,镜像源为DAOCLOUD
打算搭建redis主从服务,自己设置redis.conf,但是把容器当中的运行redis-server /usr/local/bin/redis.conf无法生效,已通过redis-cli info验证过了,并且如果是在启动时加上-d选项设置启动参数指定配置文件时则容器无法启动。
下面是containerlog
1:C 17 Dec 14:34:47.683 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_.__.-``__ ’’-._ _.-`` `. `_. ’’-._ Redis 3.2.6 (00000000/0) 64 bit .-`` .-". "/ _.,_ ’’-._ ( ’ , .-` | `, ) Running in standalone mode|`-._`-...-` __...-.``-._|’` _.-’| Port: 6379| `-._ `._ / _.-’ | PID: 1 `-._ `-._ `-./ _.-’ _.-’ |`-._`-._ `-.__.-’ _.-’_.-’| | `-._`-.__.-’_.-’ | http://redis.io `-._ `-._`-.__.-’_.-’ _.-’ |`-._`-._ `-.__.-’ _.-’_.-’| | `-._`-.__.-’_.-’ | `-._ `-._`-.__.-’_.-’ _.-’`-._ `-.__.-’ _.-’`-.__.-’ `-.__.-’
2016-12-17T14:34:47.685186833Z 1:M 17 Dec 14:34:47.685 # 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 17 Dec 14:34:47.685 # Server started, Redis version 3.2.6 1:M 17 Dec 14:34:47.685 # 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 17 Dec 14:34:47.689 * DB loaded from disk: 0.004 seconds 1:M 17 Dec 14:34:47.689 * The server is now ready to accept connections on port 6379
redis.conf
protected-mode noport 6379tcp-backlog 511timeout 0tcp-keepalive 300daemonize yessupervised nopidfile /var/run/redis_6379.pidloglevel noticelogfile ''databases 16save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir ./slave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100appendonly noappendfilename 'appendonly.aof'appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100aof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ''hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes
问题解答
回答1:docker run -v /myredis/conf/redis.conf:/usr/local/etc/redis/redis.conf --name myredis redis redis-server /usr/local/etc/redis/redis.conf

