sphinx配置启动

vim  /usr/local/sphinx/etc/sphinx-min.conf

source main
{
    type            = mysql

    sql_host        = localhost
    sql_user        = root
    sql_pass        = root
    sql_db          = test
    sql_port        = 3306  # optional, default is 3306

    sql_query       = \
        SELECT id, title, content FROM post

}


index main
{
    source          = main
    path            = /usr/local/sphinx/data/main
}



indexer
{
    mem_limit       = 128M
}


searchd
{
    listen          = 9312
    listen          = 9306:mysql41
    log             = /usr/local/sphinx/sphinxdata/logs/searchd.log
    query_log       = /usr/local/sphinx/sphinxdata/logs/query.log
    read_timeout    = 5
    max_children    = 30
    pid_file        = /var/log/searchd.pid
    seamless_rotate = 1
    preopen_indexes = 1
    unlink_old      = 1
    workers         = threads # for RT to work
    binlog_path     = /usr/local/sphinx/sphinxdata
}

建立索引 indexer -c sphinx-min.conf --all

启动 searchd --config /usr/local/sphinx/etc/sphinx-min.conf

启动可能报错:WARNING: both 'sphinxdata' and config file 'sphinx-min.conf' exist; using 'sphinxdata' folder

no config file, using 'sphinxdata' folder...

解决方法:

将 /usr/local/sphinx/etc/sphinxdata重命名为sphinxdata_tmp即可

 

重建索引:indexer -c sphinx-min.conf --all --rotate

posted @ 2021-07-24 12:21  程序员小艺  阅读(248)  评论(0编辑  收藏  举报