天天看點

centos7部署sphinx3.1.1

3.1.1版本安裝

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

centos7部署sphinx3.1.1

我安裝的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

centos7部署sphinx3.1.1
centos7部署sphinx3.1.1

配置資料目錄

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

centos7部署sphinx3.1.1

解決:yum install mariadb-devel

再次建立索引又報錯:ERROR: index 'test1': sql_connect: Can't connect to local MySQL server through socket

解決:修改mysql配置項用sock連接配接

centos7部署sphinx3.1.1

建立索引成功,data目錄下生成很多索引檔案:

centos7部署sphinx3.1.1

用配置檔案啟動

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

centos7部署sphinx3.1.1

phpdemo測試:

主查詢,查詢出所有在檢索範圍的資料,以關鍵詞為 'test' 做測試

centos7部署sphinx3.1.1
centos7部署sphinx3.1.1

php執行個體代碼,官方sphinxapi.php檔案在目錄api下面有:

centos7部署sphinx3.1.1

命中的搜尋資料:

centos7部署sphinx3.1.1