我之前安装了redis2.4.14。昨天拿到redis2.6.14,直接“cd redis-2.6.14/src ; make && make install”。我删除了redis-2.4.14的dump.rdb和redis.log。我还将配置文件升级到了 2.6.14。我在安装 redis-2.4.14 时将 redis 添加到服务中。我执行命令“service redis start”,但它总是挂起,没有“ok”信息。
[tys@localhost bin]# service redis start
Starting redis-server:
我可以正常使用redis
[tys@localhost redis]# redis-cli
redis 127.0.0.1:6379> set name tys
OK
redis 127.0.0.1:6379> get name
"tys"
但是如果我输入“ctrl + c”或“ctrl + z”,“redis-cli”会挂起。
当我重新启动系统时,linux 启动过程会挂在“正在启动 redis-server”(对不起,我太“年轻”无法发布图像。https://groups.google.com/forum/# !topic/redis-db/ iQnlyAAWE9Y )
但是我可以ssh它。它是一个虚拟机。redis.log 中没有错误。
[1420] 11 Aug 04:27:05.879 # Server started, Redis version 2.6.14
[1420] 11 Aug 04:27:05.880 # 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.
[1420] 11 Aug 04:27:05.903 * DB loaded from disk: 0.023 seconds
[1420] 11 Aug 04:27:05.903 * The server is now ready to accept connections on port 6379
这是我的 redis init.d 脚本:
#!/bin/bash
#
#redis - this script starts and stops the redis-server daemon
#
# chkconfig: 235 90 10
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
redis="/usr/local/bin/redis-server"
prog=$(basename $redis)
REDIS_CONF_FILE="/etc/redis.conf"
[ -f /etc/sysconfig/redis ] && . /etc/sysconfig/redis
lockfile=/var/lock/subsys/redis
start() {
[ -x $redis ] || exit 5
[ -f $REDIS_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $redis $REDIS_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading $prog: "
killproc $redis -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac