您的位置:首页 > 运维架构 > Shell

[shell]管理 Sphinx 启动|停止|重新生成索引的脚本

2011-08-25 15:12 543 查看
因为工作需要,所以把管理 Sphinx 的相关操作写成一个管理脚本,方便日常使用。

#!/bin/sh
#file: /usr/local/bin/sphinx
#
#~ power by yagas60@21cn.com
#~ blog: http://blog.csdn.net/yagas 
. /etc/rc.d/init.d/functions

appName="Sphinx"

stop(){
/usr/local/bin/searchd -c /usr/local/coreseek/etc/sphinx.conf --stop > /dev/null 2>&1
ret=$?
if [ $ret -eq 0 ]; then
action $"Stoping $appName: " /bin/true
else
action $"Stoping $appName: " /bin/false
fi
return $ret
}

start(){
/usr/local/bin/searchd -c /usr/local/coreseek/etc/sphinx.conf > /dev/null 2>&1
ret=$?
if [ $ret -eq 0 ]; then
action $"Starting $appName: " /bin/true
else
action $"Starting $appName: " /bin/false
fi
return $ret
}

indexer(){
/usr/local/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --all > /dev/null 2>&1
ret=$?
if [ $ret -eq 0 ]; then
action $"$appName making index: " /bin/true
else
action $"$appName making index: " /bin/false
fi
return $ret
}

case $1 in
restart)
stop
indexer
start
;;

stop)
stop
;;

start)
start
;;
esac

exit 0


使用方法:

启动服务 sphinx start

停止服务 sphinx stop

重新生成搜索 sphinx restart

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: