sphinx安装记录 转
【转】sphinx服务器安装及配置详解 安装PHP sphinx扩展
2、安装
#cd /usr/local/src
#yum -y install mysql-devel #安装mysql头文件支持mysql
#wget http://sphinxsearch.com/files/sphinx-0.9.9.tar.gz
#tar -xvzf sphinx-0.9.9.tar.gz
#cd sphinx-0.9.9
#./configure --prefix=/usr/local/sphinx --with-mysql --with-iconv --enable-id64
#make
#make install
3、配置
#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 = 0
}
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
}
4、启动
#/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 #启动索引服务
#crontab -e 加入crontab五分钟重新索引
*/5 * * * */usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf --rotate
下面是安装PHP sphinx扩展
1、安装
1、先安装sphinxclient
#cd /usr/local/src
#wget http://sphinxsearch.com/files/sphinx-0.9.9.tar.gz
#tar xzvf sphinx-0.9.9.tar.gz
#cd sphinx-0.9.9/api/libsphinxclient
#vim sphinxclient.c
找到
void sock_close ( int sock );
改为
static void sock_close ( int sock );
#./configure --prefix=/usr/local/sphinxclient
#make
#make install
2、安装sphinx扩展
#wget http://pecl.php.net/get/sphinx-1.0.4.tgz
#tar xvzf sphinx-1.0.4.tgz
#cd sphinx-1.0.4
#/usr/local/php/bin/phpize
#./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx=/usr/local/sphinxclient
#make
#make install
修改php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
[sphinx]
extension=sphinx.so
2、测试
1、安装sphinx
请参照文档http://linux008.blog.51cto.com/2837805/622088
2、编写测试文件
#vim sphinx.php
<?php
$s = new SphinxClient;
setServer("localhost", 9312);
$s->setMatchMode(SPH_MATCH_ANY);
$s->setMaxQueryTime(3);
$result = $s->query("demo");
var_dump($result);
?>
#/usr/local/php/bin/php sphinx.php 运行结果
array(9) {
["error"]=>
string(0) ""
["warning"]=>
string(0) ""
["status"]=>
int(0)
["fields"]=>
array(5) {
[0]=>
string(6) "cat_id"
[1]=>
string(13) "provider_name"
[2]=>
string(12) "goods_number"
[3]=>
string(18) "promote_start_date"
[4]=>
string(8) "keywords"
}
["attrs"]=>
array(8) {
["goods_sn"]=>
string(1) "3"
["goods_name"]=>
string(1) "3"
["brand_id"]=>
string(1) "1"
["goods_weight"]=>
string(1) "5"
["market_price"]=>
string(1) "5"
["shop_price"]=>
string(1) "5"
["promote_price"]=>
string(1) "5"
["gid"]=>
string(10) "1073741825"
}
["total"]=>
int(0)
["total_found"]=>
int(0)
["time"]=>
float(0)
["words"]=>
array(1) {
["demo"]=>
array(2) {
["docs"]=>
int(0)
["hits"]=>
int(0)
}
}
}
原文地址:
sphinx服务器安装及配置详解:http://linux008.blog.51cto.com/2837805/622088
http://linux008.blog.51cto.com/2837805/622171
sphinx安装记录 转的更多相关文章
- Linux Sphinx 安装与使用
一.什么是 Sphinx? Sphinx 是一个基于SQL的全文检索引擎,可以结合 MySQL,PostgreSQL 做全文搜索,它可以提供比数据库本身更专业的搜索功能,使得应用程序 更容易实现专业化 ...
- 分布式监控系统Zabbix-3.0.3-完整安装记录(7)-使用percona监控MySQL
前面已经介绍了分布式监控系统Zabbix-3.0.3-完整安装记录(2)-添加mysql监控,但是没有提供可以直接使用的Key,太过简陋,监控效果不佳.要想更加仔细的监控Mysql,业内同学们都会选择 ...
- 关于node.js和npm,cnpm的安装记录以及gulp自动构建工具的使用
关于node.js和npm,cnpm的安装记录以及gulp自动构建工具的使用 工作环境:window下 在一切的最开始,安装node.js (中文站,更新比较慢http://nodejs.cn/) ...
- sourceinsight安装记录
sourceinsight安装记录 此文章为本人使用sourceinsight一个星期之后的相关设置步骤记录和经验记录,以备以后查验,网上的相关资料都也较为完善,但是对于新手还是有一定困难的,所以在这 ...
- openerp安装记录及postgresql数据库问题解决
ubuntu-14.04下openerp安装记录1.安装PostgreSQL 数据库 a.安装 sudo apt-get install postgresql 安装后ubu ...
- Matlab安装记录 - LED Control Activex控件安装
Matlab安装记录-LED Control Activex控件安装 2013-12-01 22:06:36 最近在研究Matlab GUI技术,准备用于制作上位机程序:在Matlab GUI的技术 ...
- Arch Linux 安装记录
Arch Linux 安装记录 基本上参考wiki上的新手指南,使用arch 2014.6.1 iso安装 设置网络 有线网络 Arch Linux 默认开启DHCP. 静态ip 首先关闭DHCP:s ...
- 修改sphinx最大输出记录数
修改sphinx最大输出记录数 归纳如下: Sphinx的查询默认最大记录数是:1000,而我们想更改这个数值.就需要更改三个地方. 1是更改sphinx.conf配置文件的:max_matches ...
- redis5.0.3单实例简单安装记录
redis5.0.3单实例简单安装记录 日常需要测试使用,索性记录下来,免得临时又麻烦的找资料. yum -y install make gcc-c++ cmake bison-devel ncurs ...
随机推荐
- 三大范式与BCNF
引用:http://www.cnblogs.com/ybwang/archive/2010/06/04/1751279.html 参考: 1.范式间的区别 http://www.cnblogs.com ...
- css 导航,菜单对应页面切换效果实现方法
实现原理: 每个菜单有多个li标签,每个li标签含一个id,li标签的id用来标记:点击效果 每个页面有一个id,这个id的作用是对应每个li标签的点击链接对应的页面,它的作用是用来标记:li标签的h ...
- Eclipse自动调整格式
Eclipse 编写Java代码的时候,使用右键Source -> Format 后,将自动调整格式,若想要{ 单独占一行,则可以自己定义相关格式模板 新建 CodeFormatter.xml ...
- 常用免费的WebService列表
天气预报Web服务,数据来源于中国气象局 Endpoint : http://www.webxml.com.cn/WebServices/WeatherWebService.asmx Disc ...
- 在MAC上搭建tomcat,再使用servlet时遇到的问题。
说起来真是惭愧.在mac上配置tomcat环境时.tomcat6能正确运行.但是7,8都运行不了.具体表现是tomcat6访问127.0.0.1:8080可以显示那个界面,然而tomcat7和8都显示 ...
- matlab 获取鼠标位置
转载:http://hi.baidu.com/alec1228/item/68ea36ebe4046f3a86d9deab 第一种途径:ginput()函数 ginput提供了一个十字光标使我们能更精 ...
- JS实现打印功能
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ t ...
- target file里面的每个string字段的双引号怎么去掉
今天在做一个extract,把数据库里面的表经过一些过程,最终输入到flat file中. 但是最终的结果中,每个target file的string字段,含有双引号如下: NAME_ID NA ...
- macOS安装「oh my zsh」
目前常用的 Linux 系统和 OS X 系统的默认 Shell 都是 bash,但是真正强大的 Shell 是深藏不露的 zsh, 这货绝对是马车中的跑车,跑车中的飞行车,史称『终极 Shell』, ...
- macOS 安装 wget
适用于macOS Sierra Apple Store下载安装Xcode 安装Homebrew包管理,类似于Ubuntu下的apt-get: 终端下输入 ruby -e "$(curl -f ...