Coreseek为企业级搜索建立索引

bosong 2012-07-23

cmake-2.8.3+mysql5.5.9+mmseg-3.2.14+csft-4.0.1生产环境中安装
 
注:该文档是Dell 2950 服务器上进行安装的,本文档只讲解安装的过程,给出测试的步骤,但是不给出配置文件;
首先介绍一下coreseek:
Coreseek 是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索、论坛/站内搜索、数据库搜索、文档/文献检索、信息检索、数据挖掘等应用场景,用户可以下载使用;同时针对有实际需要的客户,我们还提供专业的搜索技术与本地化Sphinx技术支持服务(客户中,记录量最大已超过30亿条,文本容量最大已超过5TB),官网http://www.coreseek.cn
 
一、环境:
1.系统版本:
[root@luowei01 bin]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.7 (Final)
Release: 5.7
Codename: Final
 
2.内核版本:
[root@luowei01 bin]# uname -r
2.6.18-274.7.1.el5
 
3.CPU个数
[root@luowei01 bin]# cat /proc/cpuinfo |grep -c processor
4
 
4.硬件制造商
[root@luowei01 bin]#  dmidecode -s system-product-name
PowerEdge 2950

二、所需软件包:
wget http://admin.ooopic.com/soft/linux/coreseek-4.0.1-beta.tar.gz
wget http://admin.ooopic.com/soft/linux/cmake-2.8.3.tar.gz
wget http://admin.ooopic.com/soft/linux/mysql-5.5.9.tar.gz
wget http://admin.ooopic.com/soft/linux/Sphinx_1.11-dev_sphinxse_mysql-5.5.8.diff
wget http://admin.ooopic.com/soft/linux/sphinx-trunk.tar.gz

三、软件依序列安装:
1.编译安装cmake
tar zxvf cmake-2.8.3.tar.gz
cd cmake-2.8.3
./bootstrap
make
make install
cd ../
tar zxvf coreseek-4.0.1-beta.tar.gz
tar zxvf sphinx-trunk.tar.gz
tar zxvf mysql-5.5.9.tar.gz
cd sphinx-trunk
patch -p0 < ../Sphinx_1.11-dev_sphinxse_mysql-5.5.8.diff  
cp -R mysqlse ../mysql-5.5.9/storage/sphinx
cd ../
 
2.安装MySQL
cd mysql-5.5.9/
sh BUILD/autorun.sh
mkdir -p /var/lib/mysql
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DMYSQL_DATADIR=/data/mysql \
-DDEFAULT_CHARSET=gbk -DEXTRA_CHARSETS=all -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DCMAKE_BUILD_TYPE=Release -DWITH_SPHINX_STORAGE_ENGINE=1
make
make install
/usr/local/useradd -M -o -r -d /var/lib/mysql -s /bin/bash -c "MySQL Server" -u 27 mysql
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
chown -R mysql:mysql /data/mysql
chmod -R 755 /data/mysql
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
cp -rf support-files/my-medium.cnf /etc/my.cnf
cp -rf support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
/sbin/chkconfig --add mysqld
/sbin/chkconfig mysqld on
cp -rf /usr/local/mysql/bin/* /usr/sbin
ln -s /usr/localmysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
cd ../
echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
echo "/usr/local/lib" >> /etc/ld.so.conf.d/mysql.conf
ldconfig -v
service mysqld start
mysql -uroot -p
GRANT ALL PRIVILEGES ON *.* TO [email protected] IDENTIFIED BY 'RedHat' WITH GRANT OPTION;
INSTALL PLUGIN sphinx SONAME "ha_sphinx.so";
SHOW ENGINES;
 
3.编译安装coreseek的mmseg分词
cd coreseek-4.0.1-beta/mmseg-3.2.14
./bootstrap
./configure --prefix=/usr/local/mmseg
make
make install
cd ../../
 
4.编译安装csft
cd coreseek-4.0.1-beta/csft-4.0.1
sh buildconf.sh
./configure --prefix=/usr/local/sphinx --with-mysql=/usr/local/mysql --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg/lib/ --with-mysql
vim /opt/coreseek-4.0.1-beta/csft-4.0.1 文件

LIBS = -lm -lexpat -L/usr/local/lib
改成
LIBS = -lm -lexpat -liconv -L/usr/local/lib
make
make install
cd ../
 
5.导入测试sql并测试
cd /usr/local/sphinx/etc
cp sphinx.conf.dist csft.conf
mysql -uroot test < /usr/local/sphinx/etc/example.sql
ln -sv /usr/local/mysql/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16
/usr/local/sphinx/bin/indexer --all
/usr/local/mmseg/bin/mmseg -d /usr/local/mmseg/etc var/test/test.xml
/usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/sphinx.conf
/usr/local/sphinx/bin/search --config /usr/local/sphinx/etc/sphinx.conf  'abc'
 
安装过程中遇到的问题及解决方法:
1.在INSTALL PLUGIN sphinx SONAME "ha_sphinx.so";时候,找不到ha_sphinx.so的解决方法:
Q:Can't open shared library '/usr/local/mysql/lib/plugin/ha_sphinx.so'
A:
Download the patch file from
http://www.coreseek.cn/uploads/csft/patch/Sphinx_1.11-dev_sphinxse_mysql-5.5.8.diff
cd path_of_sphinx ; patch -p1 < /path/to/Sphinx_1.11-dev_sphinxse_mysql-5.5.8.diff
 
2.提示FATAL: no readable config file (looked in /usr/local/sphinx/etc/csft.conf, ./csft.conf).
解决方法:
cp /PATH_TO_SPHINX/etc/sphinx.conf.dist /PATH_TO_SPHINX/etc/csft.conf
 
3.提示error while loading shared libraries libmysqlclient.so.16
解决方法:
echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
ldconfig
ln -sv /usr/local/mysql/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16
 
希望此文档能帮助更多爱好开源事业的人!

相关推荐