sphinx安装记录 转
安装 记录 sphinx
2023-09-14 09:12:16 时间
【转】sphinx服务器安装及配置详解 安装PHP sphinx扩展
1、架构:ip192.168.0.200 redhat5.4(64位)
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
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
相关文章
- linux安装pycharm详细步骤[通俗易懂]
- pycharm的python环境配置_怎么安装pycharm及环境变量配置
- python和pycharm以及anaconda的安装顺序_简述信息消息信号三者的区别与联系
- 最详细AMD Ryzen CPU,VMware 15安装macOS 10.15.x Catalina 记录(第一篇)[通俗易懂]
- Ubuntu20.04安装cuda cudnn pytorch pycharm记录
- 记录:关闭win10一些广告通知、防止C盘爆满、垃圾软件安装警告!
- apache的安装教程详解_怎么安装apache
- 常用linux软件安装过程记录
- docker安装redis注意事项
- Fiddler/Charles - 夜神模拟器证书安装App抓包
- 「 记录一次拯救者r7000 2021H安装黑苹果 」
- 【错误记录】Ubuntu 安装 Linux 内核后需要重新安装 VMware Tools 软件进行兼容操作
- 【错误记录】Visual Studio 2019 中运行 Unity C# 脚本时报错 ( 根据解决方案, 可能需要安装额外的组件才能获得 | .NET 桌面开发 | 使用 Unity 的游戏开发 )
- 2023最新Lr下载:Adobe Lightroom Classic 各版本安装激活教程
- Hadoop 2.8集群安装及配置记录详解大数据
- 出错Ubuntu安装Linux失败记录(ubuntu装linux)
- Ubuntu 安装 xiami air 电台
- 安装Linux邮件服务器:简易指南(linux安装邮件服务器)
- 斐讯N1:安装Linux系统的快乐之旅(斐讯n1刷linux)
- MySQL驱动安装记录——Mac篇(macmysql驱动)
- 快速学会如何在电脑上安装MySQL数据库(电脑安装mysql数据库)
- Linux安装启动引导器教程,让你轻松完成系统安装!(linux安装启动引导器)
- Linux下中文包安装指南(linux中文包安装)
- MySQL 32位安装指南一步一步搭建轻松上手(32位安装mysql)
- Oracle 12安装记录成功实施进程(oracle12安装日志)
- Oracle 11安装记录尝试重启数据库的发现(oracle11安装日志)