st0*_*0rk 5 linux bash shell centos redis
我正在按照有关在生产机器(使用 chkconfig 的 CentOS)上安装 Redis 的说明进行操作。
我给出的示例脚本需要参数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
Run Code Online (Sandbox Code Playgroud)
确保您的脚本已添加用于服务管理chkconfig。使用chkconfig --list查看列表和使用chkconfig --add scriptname,如果它不存在。之后配置您希望它被调用的运行级别。我想这是3,4和5这样:chkconfig --level 345 scriptname on。
您应该告诉我们您从 init.d 运行脚本的具体情况
但这是一个肮脏的解决方法:
换线
start)
Run Code Online (Sandbox Code Playgroud)
到
start|'')
Run Code Online (Sandbox Code Playgroud)
如果没有传递参数,这将使其启动。
| 归档时间: |
|
| 查看次数: |
10373 次 |
| 最近记录: |