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

对于启动sphinx的服务,可以直接输入如下命令

 /usr/bin/searchd -c /etc/sphinx/sphinx.conf

<!-- /usr/local/bin/searchd -c /etc/sphinx.conf -->

下面是写成脚本的方式方便以后维护

因为工作需要,所以把管理 Sphinx 的相关操作写成一个管理脚本,方便日常使用。

 

[plain] view plain copy
 
  1. #!/bin/sh  
  2. #file: /usr/local/bin/sphinx  
  3. #  
  4. #~ power by yagas60@21cn.com  
  5. #~ blog: http://blog.csdn.net/yagas  
  6.   
  7.   
  8. . /etc/rc.d/init.d/functions  
  9.   
  10. appName="Sphinx"  
  11.   
  12. stop(){  
  13.     /usr/local/bin/searchd -c /usr/local/coreseek/etc/sphinx.conf --stop > /dev/null 2>&1   
  14.         ret=$?  
  15.         if [ $ret -eq 0 ]; then  
  16.             action $"Stoping $appName: " /bin/true  
  17.         else  
  18.             action $"Stoping $appName: " /bin/false  
  19.         fi  
  20.     return $ret  
  21. }  
  22.   
  23. start(){  
  24.     /usr/local/bin/searchd -c /usr/local/coreseek/etc/sphinx.conf > /dev/null 2>&1   
  25.         ret=$?  
  26.         if [ $ret -eq 0 ]; then  
  27.             action $"Starting $appName: " /bin/true  
  28.         else  
  29.             action $"Starting $appName: " /bin/false  
  30.         fi  
  31.     return $ret  
  32. }  
  33.   
  34. indexer(){  
  35.         /usr/local/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --all > /dev/null 2>&1  
  36.     ret=$?  
  37.         if [ $ret -eq 0 ]; then  
  38.             action $"$appName making index: " /bin/true  
  39.         else  
  40.             action $"$appName making index: " /bin/false  
  41.         fi  
  42.         return $ret  
  43. }  
  44.   
  45.   
  46. case $1 in  
  47.     restart)  
  48.     stop  
  49.     indexer  
  50.     start  
  51.     ;;  
  52.   
  53.     stop)  
  54.     stop  
  55.     ;;  
  56.       
  57.     start)  
  58.     start  
  59.     ;;  
  60. esac  
  61.   
  62. exit 0  


使用方法:

 

启动服务 sphinx start

停止服务 sphinx stop

重新生成搜索 sphinx restart

 

文章摘自http://blog.csdn.net/yagas/article/details/6718532

posted @ 2016-03-16 10:00  JasonXu_徐晓峰的博客  阅读(1935)  评论(0编辑  收藏  举报