查看原文
其他

搭建 Solr 单机服务

搜云库 搜云库技术团队 2019-04-07

Solr 概述

Solr是一款优秀的基于Lucene的全文检索服务器,它对Lucene进行了扩展,提供了非常丰富的查询语言,并对查询进行了性能优化。Solr和Lucene都由Apache Software Foundation(www.apache.org)管理。

Apache Solr 参考指南

http://lucene.apache.org/solr/guide/6_6/about-this-guide.html

环境

VMware版本号:12.0.0
CentOS版本:CentOS 7.3.1611
Solr 版本:solr-6.6.0
JDK环境:jdk-8u144-linux-x64.tar.gz 具体参考《CentOs7.3 安装 JDK1.8》 

https://segmentfault.com/a/1190000010716919

注意事项

关闭防火墙

  1. $ systemctl stop firewalld.service

Solr 安装

下载 Solr

下载最新版本的Solr ,我在北京我就选择,清华镜像比较快 , 文件大概140M

清华镜像:https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr/6.6.0/

阿里镜像:https://mirrors.aliyun.com/apache/lucene/solr/6.6.0/

提取tar文件

  1. $ cd /opt/

  2. $ wget https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr/6.6.0/solr-6.6.0.tgz

  3. $ tar -zxf solr-6.6.0.tgz

  4. $ cd solr-6.6.0

Solr 操作

1.启动服务

说明:加 -force 是因为solr不允许使用 root 进行操作的,其他账户可不加

  1. $ /opt/solr-6.6.0/bin/solr start -force

响应

  1. Warning: Available entropy is low. As a result, use of the UUIDField, SSL, or any other features that require

  2. RNG might not work properly. To check for the amount of available entropy, use 'cat /proc/sys/kernel/random/entropy_avail'.

  3. NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.

  4. Started Solr server on port 8983 (pid=3020). Happy searching!

启动Solr与不同的端口,要更改Solr监听端口,可以-p在启动时使用参数

例如:

  1. $ /opt/solr-6.6.0/bin/solr start -p 8984

2.访问管理UI

浏览器输入 ip:port

http://192.168.252.121:8983/solr/

如果Solr没有运行,您的浏览器会抱怨说它无法连接到服务器。检查您的端口号,然后重试。

3.服务状态

如果您不确定Solr是否在本地运行

  1. $ /opt/solr-6.6.0/bin/solr status

响应

  1. Found 1 Solr nodes:

  2. Solr process 4177 running on port 8983

  3. {

  4.  "solr_home":"/opt/solr-6.6.0/server/solr",

  5.  "version":"6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:32:53",

  6.  "startTime":"2017-08-23T16:18:24.088Z",

  7.  "uptime":"0 days, 0 hours, 0 minutes, 18 seconds",

  8.  "memory":"32.9 MB (%6.7) of 490.7 MB"}

4.创建Solr库

  1. bin/solr create -c <name>

说明:加 -force 是因为solr不允许使用 root 进行操作的,其他账户可不加

  1. $ /opt/solr-6.6.0/bin/solr create -c ymq -force

响应

  1. Copying configuration to new core instance directory:

  2. /opt/solr-6.6.0/server/solr/ymq

  3. Creating new core 'ymq' using command:

  4. http://localhost:8983/solr/admin/cores?action=CREATE&name=ymq&instanceDir=ymq

  5. {

  6.  "responseHeader":{

  7.    "status":0,

  8.    "QTime":2665},

  9.  "core":"ymq"}

浏览器输入 ip:port

http://192.168.252.121:8983/solr/

5.停止服务

  1. $ /opt/solr-6.6.0/bin/solr stop -p 8983

响应

  1. Sending stop command to Solr running on port 8983 ... waiting up to 180 seconds to allow Jetty process 3554 to stop gracefully.

可以使用该 -all参数来停止所有运行的Solr实例

  1. $ /opt/solr-6.6.0/bin/solr stop -all

响应

  1. Sending stop command to Solr running on port 8983 ... waiting up to 180 seconds to allow Jetty process 3249 to stop gracefully.

Contact

  • 作者:鹏磊

  • 出处:http://www.ymq.io/2017/08/23/Solr/

  • Email:admin@souyunku.com

  • 版权归作者所有,转载请注明出处

  • Wechat:关注公众号,搜云库,专注于开发技术的研究与知识分享


    您可能也对以下帖子感兴趣

    文章有问题?点此查看未经处理的缓存