CentOs7.3 搭建 Solr单机服务

时间:2022-04-28
本文章向大家介绍CentOs7.3 搭建 Solr单机服务,主要内容包括CentOs7.3 搭建 Solr单机服务、环境、注意事项、Solr 安装、Solr 操作、2.访问管理UI、3.服务状态、4.创建Solr库、5.停止服务、Contact、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。

CentOs7.3 搭建 Solr单机服务

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

注意事项

关闭防火墙

$ systemctl stop firewalld.service 

Solr 安装

提取tar文件

$ cd /opt/
$ wget https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr/6.6.0/solr-6.6.0.tgz
$ tar -zxf solr-6.6.0.tgz 
$ cd solr-6.6.0

Solr 操作

1.启动服务

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

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

响应

Warning: Available entropy is low. As a result, use of the UUIDField, SSL, or any other features that require
RNG might not work properly. To check for the amount of available entropy, use 'cat /proc/sys/kernel/random/entropy_avail'.

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

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

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

例如:

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

2.访问管理UI

浏览器输入 ip:port

http://192.168.252.121:8983/solr/

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

3.服务状态

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

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

响应

Found 1 Solr nodes: 

Solr process 4177 running on port 8983
{
  "solr_home":"/opt/solr-6.6.0/server/solr",
  "version":"6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:32:53",
  "startTime":"2017-08-23T16:18:24.088Z",
  "uptime":"0 days, 0 hours, 0 minutes, 18 seconds",
  "memory":"32.9 MB (%6.7) of 490.7 MB"}

4.创建Solr库

bin/solr create -c <name>

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

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

响应

Copying configuration to new core instance directory:
/opt/solr-6.6.0/server/solr/ymq

Creating new core 'ymq' using command:
http://localhost:8983/solr/admin/cores?action=CREATE&name=ymq&instanceDir=ymq

{
  "responseHeader":{
    "status":0,
    "QTime":2665},
  "core":"ymq"}

浏览器输入 ip:port

http://192.168.252.121:8983/solr/

5.停止服务

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

响应

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

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

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

响应

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

Contact