Sphinx

sphinx安装:

 

1、下载sphinx源码包

 

   上面截图的这个网址   复制链接地址   在putty终端使用:wget http://sphinxsearch.com/files/sphinx-2.3.1-beta.tar.gz

 

   注:一般都下载到/usr/local/src目录下

 

     安装一般都安装到/usr/local/sphinx    (sphinx这个目录是自定义的)

 

  在此目录使用tar命令解压 :tar zxvf sphinx-2.3.1-beta.tar.gz

 

2、开始进行编译  注:源代码安装肯定得安装gcc,安装工具包

 

  安装工具包命令:yum -y install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel  注:(yum -y  就是不用确定进行安装,不能少装)安装完成不报错就可以进行编译

 

  安装命令:./configure   --prefix=/usr/local/sphinx  (--prefix=安装目录)

 

  安装完成后会告诉你可以进行编译,欢迎使用sphinx

 

3、make   生成编译文件不会进行编译

 

  make install 进行编译  //警告忽略

 

 也可以一起执行:make && make install //如果make报错后面make install不会执行 

 

 (开机自启命令:chconfig --level 345 httpd on //Apache开机自启   chconfig --level mysqld 345 on mysql开机自启)

 

4、测试   进入安装目录

 

  cd /usr/local/sphinx/etc

 

  先复制一份配置项 cp sphinx.conf.dist sphinx.conf

 

  进行配置:

 

      vi sphinx.conf

 

 

 

 

 

停止sphix服务:sudo systemctl stop searchd
查看sphix状态:sudo systemctl status searchd
进入sphix文件目录:cd /var/lib/sphinx/
删除已生成的文件: sudo rm *
进入配置文件目录:cd /etc/sphinx/
编辑配置文件:sudo vim sphinx.conf
重启sphix:sudo systemctl start searchd
进入文件目录:cd /var/lib/sphinx/
查看sphix状态:sudo systemctl status searchd
查看起的服务:netstat -lnt

 service searchd stop
 service searchd start

sphinx.conf

#
# Minimal Sphinx configuration sample (clean, simple, functional)
#

index merchant
{
        type                    = rt
        rt_mem_limit            = 128M
        dict                    = keywords
        min_infix_len           = 3
        expand_keywords         = 1

        path                    = /var/lib/sphinx/merchant

        rt_attr_string          = code
        rt_attr_string          = name
        rt_field                = code
        rt_field                = name
        rt_field                = pinyin
}

index user
{
        type                    = rt
        rt_mem_limit            = 128M
        dict                    = keywords
        min_infix_len           = 3
        expand_keywords         = 1

        path                    = /var/lib/sphinx/user

        rt_attr_string          = code
        rt_attr_string          = name
        rt_field                = code
        rt_field                = name
        rt_field                = pinyin
}

index car
{
        type                    = rt
        rt_mem_limit            = 512M
        dict                    = keywords
        min_infix_len           = 3
        expand_keywords         = 1

        path                    = /var/lib/sphinx/car

        rt_attr_string          = name
        rt_field                = brand
        rt_field                = manufacturer
        rt_field                = series
        rt_field                = model
        rt_field                = build
}

index parts
{
        type                    = rt
        rt_mem_limit            = 512M
        dict                    = keywords
        min_infix_len           = 3
        expand_keywords         = 1

        path                    = /var/lib/sphinx/parts

        rt_attr_string          = code
        rt_attr_string          = name
        rt_attr_string          = oe
        rt_attr_string          = brand
        rt_attr_string          = category
        rt_attr_string          = type


        rt_field                = code
        rt_field                = oe
        rt_field                = normalized
        rt_field                = name
        rt_field                = pinyin
}

index brand
{
        type                    = rt
        rt_mem_limit            = 128M
        dict                    = keywords
        min_infix_len           = 1
        expand_keywords         = 1

        path                    = /var/lib/sphinx/brand

        rt_attr_string          = name
        rt_field                = name
        rt_field                = pinyin

}
#source src1
#{
#       type                    = mysql
#
#       sql_host                = localhost
#       sql_user                = test
#       sql_pass                =
#       sql_db                  = test
#       sql_port                = 3306  # optional, default is 3306
#
#       sql_query               = \
#               SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content \
#               FROM documents
#
#       sql_attr_uint           = group_id
#       sql_attr_timestamp      = date_added
#}
#
#
#index test1
#{
#       source                  = src1
#       path                    = /var/lib/sphinx/test1
#}
#
#
#index testrt
#{
#       type                    = rt
#       rt_mem_limit            = 128M
#
#       path                    = /var/lib/sphinx/testrt
#
#       rt_field                = title
#       rt_field                = content
#       rt_attr_uint            = gid
#}
#
#
#indexer
#{
#       mem_limit               = 128M
#}


searchd
{
        #listen                 = 9312
        listen                  = 9306:mysql41
        mysql_version_string    = 5.0.0
        #mysql_version_string   = 5.5.54
        log                     = /var/log/sphinx/searchd.log
        query_log               = /var/log/sphinx/query.log
        read_timeout            = 5
        max_children            = 30
        pid_file                = /var/run/sphinx/searchd.pid
        seamless_rotate         = 1
        preopen_indexes         = 1
        unlink_old              = 1
        workers                 = threads # for RT to work
        binlog_path             = /var/lib/sphinx/
}
                                                                   

 

posted @ 2017-12-06 13:03  110528844  阅读(198)  评论(0编辑  收藏  举报