System environment:
os:centos6.4 64-bit
mysql:5.1.63
coreseek:4.1
The installation and configuration process is as follows:
#当前路径
[Root@e sphinx]# pwd
/home/sphinx
#安装依赖包
[Root@e sphinx]# yum install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel
#下载coreseek4.1
[Root@e sphinx]# wget http://www.coreseek.cn/uploads/csft/4.0/coreseek-4.1-beta.tar.gz
#解压缩
[Root@e sphinx]# tar zxvf coreseek-4.1-beta.tar.gz
#安装mmseg
[Root@e sphinx]# CD coreseek-4.1-beta/mmseg-3.2.14/
[Root@e mmseg-3.2.14]#./bootstrap #输出的warning信息可以忽略, if error occurs, it needs to be resolved.
[Root@e mmseg-3.2.14]#./configure--prefix=/usr/local/mmseg3
[Root@e mmseg-3.2.14]# make && make install
[Root@e mmseg-3.2.14]# CD ...
# #安装coreseek
[Root@e coreseek-4.1-beta]# CD CSFT-4.1/
[Root@e csft-4.1]# sh buildconf.sh #输出的warning信息可以忽略, if error occurs, it needs to be resolved
[Root@e csft-4.1]#./configure--prefix=/usr/local/coreseek--without-unixodbc--with-mmseg--with-mmseg-includes=/ usr/local/mmseg3/include/mmseg/--with-mmseg-libs=/usr/local/mmseg3/lib/--with-mysql
[Root@e csft-4.1]# make && make install
[Root@e csft-4.1]# CD ...
#测试mmseg分词, Coreseek search (requires a pre-set character set to ZH_CN.) UTF-8, make sure Chinese is displayed correctly)
[Root@e coreseek-4.1-beta]# CD testpack/
[Root@e testpack]# cat Var/test/test.xml #此时应该正确显示中文
Specify a data source #mmseg程序-D Word Library Directory
[Root@e testpack]#/usr/local/mmseg3/bin/mmseg-d/usr/local/mmseg3/etc var/test/test.xml
#创建索引
[Root@e testpack]#/usr/local/coreseek/bin/indexer-c etc/csft.conf--all
#执行搜索测试
[Root@e testpack]#/usr/local/coreseek/bin/search-c etc/csft.conf Network Search
#测试成功
Coreseek fulltext 4.1 [Sphinx 2.0.2-dev (r2922)]
Copyright (c) 2007-2011,
Beijing Choice Software Technologies Inc. (http://www.coreseek.com)
Using config file ' etc/csft.conf ' ...
Index ' XML ': Query ' Web search ': returned 1 matches of 1 total in 0.000 sec
displaying matches:
1. Document=1, weight=1590, Published=thu Apr 1 22:20:07, author_id=1
Words
1. ' Network ': 1 documents, 1 hits
2. ' Search ': 2 documents, 5 hits
#为了使sphinx直接支持mysql数据源 need to recompile the installation of Coreseek
#重新编译安装后的coreseek可以支持mysql和xml数据源
[Root@e testpack]# CD ...
[Root@e coreseek-4.1-beta]# pwd
/home/sphinx/coreseek-4.1-beta
[Root@e coreseek-4.1-beta]# cd csft-4.1/$ make clean
[Root@e coreseek-4.1-beta]#./configure--prefix=/usr/local/coreseek--without-unixodbc--with-mmseg-- with-mmseg-includes=/usr/local/mmseg3/include/mmseg/--with-mmseg-libs=/usr/local/mmseg3/lib/--with-mysql
# # #配置, test MySQL data source ###
Import test Data SQL click to download
#安装mysql依赖包
Yum install MySQL mysql-server php-mysql-y
#修改配置配置文件
[Root@e testpack]# CD ... /testpack/
[Root@e testpack]# VI etc/csft_mysql.conf
#只需要修改 the related configuration of the database in the source definition (database address, user name, password, library name) Other configurations do not need to be modified as follows:
#源定义
SOURCE MySQL
{
Type = MySQL
Sql_host = localhost #数据库主机地址
Sql_user = root #数据库用户名
Sql_pass = 111111 #数据库密码
sql_db = Sphinx #数据库库名
Sql_port = 3306
Sql_query_pre = SET NAMES UTF8
Sql_query = SELECT ID, group_id, Unix_timestamp (date_added) as date_added, title, content from documents
#sql_query第一列id需为整数
#title, content as a string/text field, Full-text indexed
Sql_attr_uint = group_id #从SQL读取到的值必须为整数
Sql_attr_timestamp = date_added #从SQL读取到的值必须为整数, as time attribute
Sql_query_info_pre = set NAMES UTF8 #命令行查询时, setting the correct
Character
Sql_query_info = SELECT * from documents WHERE id= $id #命令行查询时 to read raw data information from the database
}
#创建mysql数据源索引
[Root@e testpack]# pwd
/home/sphinx/coreseek-4.1-beta/testpack
#索引器-C configuration file--all
[Root@e testpack]#/usr/local/coreseek/bin/indexer-c etc/csft_mysql.conf--all
Coreseek fulltext 4.1 [Sphinx 2.0.2-dev (r2922)]
Copyright (c) 2007-2011,
Beijing Choice Software Technologies Inc. (http://www.coreseek.com)
Using config file ' etc/csft_mysql.conf ' ...
Indexing index ' MySQL ' ...
Error:index ' mysql ': Sql_connect:can ' t connect to the local MySQL server through socket '/var/lib/mysql/mysql.sock ' (2) (DSN =mysql://root:*** @localhost: 3306/sphinx).
Total 0 docs, 0 bytes
Total 0.000 sec, 0 bytes/sec, 0.00 docs/sec
Total 0 Reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
Total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
Failed to create INDEX #上面有报错
#找到mysql. Sock path (can go to MySQL's profile/etc/my.cnf to view the native in/tmp/mysql.sock)
#建立软连接
[Root@e testpack]# Mkdir/var/lib/mysql
[Root@e testpack]# ln-s/tmp/mysql.sock/var/lib/mysql/mysql.sock
#创建mysql数据源索引成功
[Root@e testpack]#/usr/local/coreseek/bin/indexer-c etc/csft_mysql.conf--all
Coreseek fulltext 4.1 [Sphinx 2.0.2-dev (r2922)]
Copyright (c) 2007-2011,
Beijing Choice Software Technologies Inc. (http://www.coreseek.com)
Using config file ' etc/csft_mysql.conf ' ...
Indexing index ' MySQL ' ...
Collected 3 docs, 0.0 MB
Sorted 0.0 mhits, 100.0% done
Total 3 docs, 7545 bytes
Total 0.016 sec, 467269 bytes/sec, 185.79 docs/sec
Total 3 Reads, 0.000 sec, 2.8 kb/call AVG, 0.0 msec/call avg
Total 9 writes, 0.000 sec, 2.2 kb/call avg, 0.0 msec/call avg
#测试mysql数据源 Search
[Root@e testpack]#/usr/local/coreseek/bin/search-c etc/csft_mysql.conf Network Search
Coreseek fulltext 4.1 [Sphinx 2.0.2-dev (r2922)]
Copyright (c) 2007-2011,
Beijing Choice Software Technologies Inc. (http://www.coreseek.com)
Using config file ' etc/csft_mysql.conf ' ...
Index ' mysql ': Query ' Web search ': returned 1 matches of 1 total in 0.000 sec
displaying matches:
1. Document=1, weight=1590, group_id=2, Date_added=thu Apr 1 22:20:07 2010
Id=1
title= April Fool's Day best bewitched the material Google 30 billion dollars to buy Baidu
Content= according to foreign media reports, Google will invest heavily to buy Baidu,......< text omitted a lot of words ... Li also admitted that Baidu is still in the primary stage of development in Japan, but he also predicted that "2012, Baidu and Google to govern", we will wait and see!
Date_added=2010-04-01 22:20:07
Author_id=1
group_id=2
Words
1. ' Network ': 1 documents, 1 hits