centos7部署sphinx3.1.1

3.1.1版本安装

参考:http://sphinxsearch.com/docs/sphinx3.html

我安装的3.1.1版本

启动报错:no config file, using 'sphinxdata' folder...

参考:https://www.jianshu.com/p/f12c7301a0fd

解决:没有配置文件启动,自动在bin目录下创建sphinxdata目录启动

 

移动到/usr/local/sphinx

mv sphinx-3.1.1 /usr/local/sphinx

复制一个简单版配置文件:

cp /usr/local/sphinx/etc/sphinx-min.conf.dist /usr/local/sphinx/etc/sphinx.conf

 

 

 

配置数据目录

mkdir /usr/local/sphinx/data

连接数据库使用示例/usr/local/sphinx/etc/example.sql文件到test数据库下创建两个表

mysql>use test

mysql>source /usr/local/sphinx/etc/example.sql

 

创建索引,--rotate 参数进行 无缝更新,无需重启服务

全部:/usr/local/sphinx/bin/indexer -c /usr/local/sphinx/etc/sphinx.conf  --all --rotate

单个(test1为索引名称):/usr/local/sphinx/bin/indexer -c /usr/local/sphinx/etc/sphinx.conf test1

创建单个test1索引报错:ERROR: index 'test1': sql_connect: failed to load libmysqlclient

参考:http://sphinxsearch.com/docs/sphinx3.html

 

解决:yum install mariadb-devel

 

再次创建索引又报错:ERROR: index 'test1': sql_connect: Can't connect to local MySQL server through socket

解决:修改mysql配置项用sock连接

 

创建索引成功,data目录下生成很多索引文件:

 

用配置文件启动

/usr/local/sphinx/bin/searchd -c /usr/local/sphinx/etc/sphinx.conf

 

phpdemo测试:

主查询,查询出所有在检索范围的数据,以关键词为 'test' 做测试

 

php实例代码,官方sphinxapi.php文件在目录api下面有:

命中的搜索数据:

 

 

 

 

 

 

 

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值