sphinx的Coreseek安装

http://blog.csdn.net/fafa211/article/details/8028921


远程访问的PHP代码,一定要保存文本为utf-8,不然查询不了中文

文件-》另存为 格式 utf-8 

1.yum install glibc make gcc g++ gcc-c++ libtool autoconf automake imake MySQL-devel libxml2-devel expat-devel

 

2.
运行locale保证如下设置
LANG=zh_CN.UTF-8
LC_ALL="zh_CN.UTF-8"

 

3.
先清除以往autoconf
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 install


4.
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 install

 

5.
下载coreseek
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.
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


防火墙问题  关闭防火墙


9.
启动
/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


10.保证跨机器访问,关闭防火墙
service iptables stop


你可能感兴趣的:(sphinx全文搜索,ubuntu)