介紹mysql
coreseek是一款基於sphinx開源的搜索引擎,專門爲用戶提供免費的中文全文檢索系統,coreseek被稱爲帶有中文分詞的sphinx,與sphinx不一樣的是coreseek增長了一個帶有中文分司的詞庫。c++
1.依賴包的安裝(包名可能不正確,能夠yum search 一下)git
yum install glibc make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-develsql
2.編碼保證爲utf-8
運行locale保證以下設置
LANG=zh_CN.UTF-8
LC_ALL="zh_CN.UTF-8"bootstrap
3.先清除以往autoconfvim
yum erase autoconf
卸載後會發現libtool也被卸載了,會出現以下錯誤
configure.in:26: error: possibly undefined macro: AM_PROG_LIBTOOL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
解決辦法:
wget http://mirror.bjtu.edu.cn/gnu/libtool/libtool-2.4.2.tar.gz
./configure
make
make installsocket
4.autoconf、automake安裝
tar xzvf autoconf-2.64.tar.gz
cd autoconf-2.64
./configure
make
make install測試
tar xzvf automake-1.11.2.tar.gz
cd automake-1.11.2
./configure
make
make installui
5.下載coreseekthis
wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-4.1-beta.tar.gz
tar zxvf coreseek-4.1-beta.tar.gz
cd coreseek-4.1-beta
6.安裝mmseg
cd mmseg-3.2.14
./bootstrap #輸出的warning信息能夠忽略,若是出現error則須要解決
./configure --prefix=/usr/local/mmseg
make && make install
7.安裝coreseek
cd csft-4.1
sh buildconf.sh
./configure --prefix=/usr/local/coreseek --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg/lib/ --with-mysql
此時先修改文件
vim src/Makefile
從
LIBS = -ldl -lm -lz -lexpat -L/usr/local/lib -lrt -lpthread
變成
LIBS = -ldl -lm -lz -lexpat -liconv -L/usr/local/lib -lrt -lpthread
make && make install
8.##測試mmseg分詞,coreseek搜索(須要預先設置好字符集爲zh_CN.UTF-8,確保正確顯示中文)
cd testpack
cat var/test/test.xml #此時應該正確顯示中文
/usr/local/mmseg/bin/mmseg -d /usr/local/mmseg/etc/ /home/software/server/coreseek-4.1-beta/mmseg-3.2.14/src/t1.txt
/usr/local/mmseg/bin/mmseg -d /usr/local/mmseg/etc/ /home/software/server/coreseek-4.1-beta/testpack/var/test/test.xml
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx-min.conf.dist
csft-4.0 版顯示:ERROR: nothing to do.
若發現錯誤
error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
解決方式
cd /etc
ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2
ldconfig
9.配置mysql,導入測試數據
create database test;
mysql -uroot -proot test < /home/software/server/coreseek-4.1-beta/testpack/var/test/documents.sql
quit
cp /home/software/server/coreseek-4.1-beta/testpack/etc/csft_mysql.conf /usr/local/coreseek/etc/
10.配置csft_mysql.conf文件
mkdir /usr/local/coreseek/var/data/
配置csft_mysql.conf文件
vim /usr/local/coreseek/etc/csft_mysql.conf
sql_user = root
sql_pass =
path = /usr/local/coreseek/var/data/mysql
charset_dictpath = /usr/local/mmseg/etc/
pid_file = /usr/local/coreseek/var/log/searchd_mysql.pid
log = /usr/local/coreseek/var/log/searchd_mysql.log
query_log = /usr/local/coreseek/var/log/query_mysql.log
11.啓動sphinx搜索
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/csft_mysql.conf --all
/usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/csft_mysql.conf
若是報錯
WARNING: index 'mysql': preload: failed to open var/data/mysql.sph: No such file or directory; NOT SERVING
FATAL: no valid indexes to serve
解決
新創建索引
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/csft_mysql.conf --all
更改
mysql的問題 stock路徑問題,須要在my.cnf更改 /var/lib/mysql/mysql.sock
vim /etc/my.cnf
#socket = /tmp/mysql.sock
socket = /var/lib/mysql/mysql.sock
防火牆問題 關閉防火牆
12.命令
啓動
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/csft_mysql.conf --all
/usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/csft_mysql.conf
coreseek從新索引(數據有變更時須要從新索引)
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/csft_mysql.conf --all --rotate
13.保證跨機器訪問,關閉防火牆service iptables stop