Showing posts with label Sphinx Search Engine. Show all posts
Showing posts with label Sphinx Search Engine. Show all posts

Friday, April 8, 2011

Install Sphinx as Service on Redhat/CentOS

Thanks Steve Kamerman

Create this searchd script under /etc/init.d, & alter the SUDO_USER & BASEPATH to fit your environment.

#!/bin/bash## Init file for searchd## chkconfig: 2345 55 25## description: searchd ## USE "chkconfig --add searchd" to configure Sphinx searchd service## by Steve Kamerman April 14, 2010# http://www.tera-wurfl.com# public domainSUDO_USER=sphinxBASE_PATH=/usr/local/sphinxPID_FILE=$BASE_PATH/var/log/searchd.pidCONFIG_FILE=$BASE_PATH/etc/sphinx.confEXEC_PATH=$BASE_PATH/binLOG_PATH=$BASE_PATH/var/logDATA_PATH=$BASE_PATH/var/dataRETVAL=0prog="searchd"do_config() {	chown -R $SUDO_USER $EXEC_PATH	chown -R $SUDO_USER $CONFIG_FILE	chown -R $SUDO_USER $DATA_PATH	chown -R $SUDO_USER $LOG_PATH	chmod 600 $CONFIG_FILE	chmod u+rwx $EXEC_PATH/*	chmod -R u+rw,go-rwx $DATA_PATH	chmod -R u+rw,go-rwx $LOG_PATH}do_start() {	echo "Starting $prog"	sudo -u $SUDO_USER $EXEC_PATH/$prog --config $CONFIG_FILE	RETVAL=$?	echo	return $RETVAL}do_stop() {	echo "Stopping $prog"	if [ -e $PID_FILE ] ; then		sudo -u $SUDO_USER $EXEC_PATH/$prog --stop		sleep 2		if [ -e $PID_FILE ] ; then			echo "WARNING: searchd may still be alive: $PID_FILE"		fi	fi	RETVAL=$?	echo	return $RETVAL}do_status() {	RETVAL=$?	if [ -e $PID_FILE ] ; then 		sudo -u $SUDO_USER $EXEC_PATH/$prog --status		echo "---"		echo "$prog is running (`cat $PID_FILE`)"	else		echo "$prog is not running"	fi	return $RETVAL}do_reindex() {	echo "Reindexing all $prog indices"	if [ -e $PID_FILE ] ; then		sudo -u $SUDO_USER $EXEC_PATH/indexer --all --rotate	else		sudo -u $SUDO_USER $EXEC_PATH/indexer --all	fi	echo "done."	echo	RETVAL=$?	return $RETVAL}case $* inconfig)	do_config	;;start)	do_start	;;stop)	do_stop	;;status)	do_status	;;reindex)	do_reindex	;;*)	echo "usage: $0 {start|stop|config|status|reindex}" >&2	exit 1	;;esacexit $RETVAL

Then alter the permission to make it executable.

chown root:root /etc/init.d/searchdchmod 755 /etc/init.d/searchd

Finalise, make it automatically start on system boot

chkconfig --level 345 searchd on

Now you can use

service searchd start/stop/status

to control the sphinx service

Wednesday, February 23, 2011

Awesome new feature - sql_attr_string in sphinx search 1.10

Sphinx search engine 1.10 brings a new attribute sql_attr_string which allows sorting the search result by string rather than integer before. This extremely helpful in my current project, however, this version of sphinx is still in beta, hope they can release the stable version soon.

Friday, September 24, 2010

Sphinx service crashes

The sphinx sometime crashes if you set seamless_rotate = 1 in your sphinx config file

Set seamless_rotate = 0; may resolve the problem

Wednesday, September 15, 2010

Access denied due to hash character in MYSQL password

The db password in sphinx configure file should not contains any hash characters which cause access denied during connecting to the database server.