wget http://sphinxsearch.com/files/sphinx-3.4.1-efbcc65-linux-amd64.tar.gz
tar zxvf ./sphinx-3.4.1-efbcc65-linux-amd64.tar.gz
mv ./sphinx-3.4.1 /www/server
mkdir /www/server/sphinx-3.4.1/data
mkdir -p /www/server/sphinx-3.4.1/data/index/question
mkdir -p /www/server/sphinx-3.4.1/data/searchd/log
mkdir -p /www/server/sphinx-3.4.1/data/searchd/data
配置文件如下
#
# Minimal Sphinx configuration sample (clean, simple, functional)
#
source question_src
{
type = mysql
sql_host = 127.0.0.1
sql_user = learn_gao_jiu_feng_db
sql_pass = HkjwmgEzCnwALiGS1024DG
sql_db = learn_gaojiufeng
sql_port = 3306 # optional, default is 3306
sql_query = \
SELECT id,course_id,question_name \
FROM think_course_question
#sql_attr_uint = id
sql_attr_uint = course_id
}
index question
{
source = question_src
path = /www/server/sphinx-3.4.1/data/index/question
ngram_len = 1
ngram_chars = U+3000..U+2FA1F
}
indexer
{
mem_limit = 128M
}
searchd
{
listen = 9312
listen = 9306:mysql41
log = /www/server/sphinx-3.4.1/data/searchd/log/searchd.log
query_log = /www/server/sphinx-3.4.1/data/searchd/log/query.log
read_timeout = 5
max_children = 30
pid_file = /www/server/sphinx-3.4.1/data/searchd/searchd.pid
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_path = /www/server/sphinx-3.4.1/data/searchd/data
}
生成索引
/www/server/sphinx-3.4.1/bin/indexer -c /www/server/sphinx-3.4.1/etc/sphinx-min.conf question
启动搜索
/www/server/sphinx-3.4.1/bin/searchd -c /www/server/sphinx-3.4.1/etc/sphinx-min.conf