Linux Configuration Sphinx

Source: Internet
Author: User

1. Configure the Index

cd/usr/local/sphinx/etc/

CP sphinx.conf.dist sphinx.conf//backup configuration file to prevent error modification

Vim sphinx.conf

configuration file Structure: # Main data source, (main name can change) source main{type = mysql #数据库类型 sql_host = localhost #MySQL主机IP sql_user = Test #MySQL用户名 Sql_pass = #MySQL密码 sql_db = Test #MySQL数据库 sql_port = 3306 #MySQL端口 Sql_sock =/tmp/my Sql.sock #Linux下需要开启, specifying sock file Sql_query_pre = set NAMES UTF8 #MySQL检索编码 sql_query_pre = set SESSION Query_cache_typ E=off #关闭缓存 sql_query = \ #获取数据的SQL语句 SELECT ID, title, content from Post # Here are the properties for filtering or conditional queries, the fields listed here will be The full-text Search #sql_attr_uint = group_id #sql_attr_timestamp = date_added}# Incremental Data Source (inherited source), inheriting the primary data source src1t hrottled:main{}# Primary index (local index), (main name can be changed) index main{Source = main # Specify primary data source path =/usr/local/sphinx/var/data/ Main # Index Path}# Incremental Index (inherited index) index test1stemmed:test1{}# Distributed Index (distributed index) index dist1{}# real-time indexing (Realtime ind EX) Index rt{}# set, (adjust minimum memory to best) indexer{Mem_limit = 256M #内存大小限制, default 128M, recommended 256M #其它用默认即可}# service process settings, (listening port number) SE arched{#全部默认即可, the default port number is9312}# Public Configuration common{} 

  

2. Create an index

CREATE INDEX command: Indexer

-C Specify configuration file

--all to reindex all indexes

--rotate is used to rotate the index, increasing the index when the service is not stopped (Searchd runtime), and the SEARCHD runtime does not add an error.

--merge Merge Index, when the incremental index is merged into the primary index

Build all indexes:/usr/local/sphinx/bin/indexer-c/usr/local/sphinx/etc/sphinx.conf--all

or specify an index (for example, main):/usr/local/sphinx/bin/indexer-c/usr/local/sphinx/etc/sphinx.conf Main

(1) If an error occurs here:

"Error:index ' main ': Sql_connect:can ' t connect to local MySQL server through socket '/tmp/mysql.sock '"

Failed to find the/tmp/mysql.sock, find the location via the Find/-name mysql.sock-print, and change it correctly in the configuration sphinx.conf.

such as: Mysql_sock =/var/lib/mysql/mysql.sock Save exit.

(2) Continue to create INDEX, warning:

"Warning:attribute count is 0:switching to none DocInfo"

Change sphinx.conf in the DocInfo = none there is no warning. (Http://sphinxsearch.com/docs/current.html#conf-docinfo)

Create index The following prompt indicates that the build succeeded:

3. Start Sphinx

Rebuild index:./searchd-c/usr/local/sphinx/etc/sphinx.conf

Rotate index:./searchd-c/usr/local/sphinx/etc/sphinx.conf goods_list--rotate

./searchd-c/usr/local/sphinx/etc/sphinx.conf Store_list--rotate

Stop service:./searchd-c/usr/local/sphinx/etc/sphinx.conf--stop

Linux Configuration Sphinx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.