一、環境架構:
ip:192.168.0.200
os:redhat5.4(64位)html
二、安裝
mysql
三、配置
linux
#cd /usr/local/sphinx
#cp etc/sphinx.conf.dist etc/sphinx.conf
#vim etc/sphinx.conf #修改配置文件
source goods_src
{
type = mysql
sql_host = localhost
sql_user = ecshop
sql_pass = ecshop
sql_db = ecshop
sql_port = 3306
sql_sock = /tmp/mysql.sock
sql_query_pre = SET NAMES utf8
sql_query_pre = SET SESSION query_cache_type=OFF
sql_query = \
SELECT goods_id,cat_id,goods_sn,goods_name,brand_id,provider_name,goods_number,goods_weight,market_price,shop_price,promote_price,promote_start_date,keywords \
FROM ecs_goods
sql_attr_multi = uint gid from query; SELECT goods_id,cat_id FROM ecs_goods
sql_attr_uint = brand_id
sql_attr_float = market_price
sql_attr_float = shop_price
sql_attr_float = promote_price
sql_attr_float = goods_weight
sql_attr_str2ordinal = goods_sn
sql_attr_str2ordinal = goods_name
sql_ranged_throttle = 100
}
index goods
{
source = goods_src
path = /usr/local/sphinx/var/data/goods
docinfo = extern
mlock = 1
morphology = none
min_stemming_len = 1
min_word_len = 1
charset_type = utf-8
charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F
ignore_chars = U+00AD
ngram_len = 1
html_strip = 0sql
}vim
indexer
{
mem_limit = 1024M //建議256到1024之間
}
searchd
{
listen = 9312
log = /usr/local/sphinx/var/log/searchd.log
query_log = /usr/local/sphinx/var/log/query.log
read_timeout = 5
client_timeout = 300
max_children = 30
pid_file = /usr/local/sphinx/var/log/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
mva_updates_pool = 1M
max_packet_size = 8M
max_filters = 256
max_filter_values = 4096
}架構
四、啓動
less
#/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf --all #建立索引
#/usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/sphinx.conf #啓動索引服務ide
#crontab -e #加入crontab五分鐘從新索引
*/5 * * * */usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf --rotateui
如此linux下的sphinx就完成了安裝,並配置好了。但願本文能夠幫助到你們。spa