【发布时间】:2013-09-11 21:48:00
【问题描述】:
我正在按照在生产机器上安装 Redis 的说明进行操作(CentOS 使用 chkconfig)。
给我的示例脚本需要参数 start 来实际启动它,而 init.d 似乎没有这样做(传递参数)。
必须运行的真正命令是/etc/init.d/redis_6379 start,但它实际调用的是/etc/inti.d/redis_6379,它只是说use start or stop as an argument
因此,当我的服务器重新启动时,它实际上并没有启动 redis。我应该在这里做什么?
这是初始配置
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis_6379
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
【问题讨论】:
-
/etc/rc3.d中的链接名称是什么?如果它以S开头,我认为应该给它start参数。 -
尝试
service --status-all并检查redis_6379是否已添加为[+]。如果是,那么即使在重新启动后它也可以工作。
标签: linux bash shell redis centos