solr 安装 使用 单机启动 solr云启动 编入索引 搜索索引 规则搜索

目录

1.下载

2.solr单机启动

3.solr云启动

索引Techproducts数据

基本搜索


1.下载

2.solr单机启动

  • 下载下来的zip或tar解压
  • 在解压目录下bin下执行 solr start -p 8983
 solr start -p 8983

3.solr云启动

  • 1.命令:cd 到解压目录中
  • 2命令:bin/solr start -e cloud

不显示描述输入(-noprompt)  

solr-8.0.0:$ ./bin/solr start -e cloud

Welcome to the SolrCloud example!

This interactive session will help you launch a SolrCloud cluster on your local workstation.
To begin, how many Solr nodes would you like to run in your local cluster? (specify 1-4 nodes) [2]:

第一个提示询问我们要运行多少个节点。注意[2]最后一行的末尾; 这是默认的节点数。这是我们想要的这个例子

  • enter回车
Ok, let's start up 2 Solr nodes for your example SolrCloud cluster.
Please enter the port for node1 [8983]:

这将是第一个节点运行的端口。除非您知道机器上的端口8983上还有其他东西在运行,否则也请按下此默认选项enter,如果占用会提示改改

  • enter回车
Please enter the port for node2 [7574]:

这是第二个节点将运行的端口。同样,除非您知道机器上的端口8983上还有其他东西在运行,否则也请按下此默认选项enter。

  • enter回车

Solr现在将初始化自己并开始在这两个节点上运行。

Starting up 2 Solr nodes for your example SolrCloud cluster.

Creating Solr home directory /solr-8.0.0/example/cloud/node1/solr
Cloning /solr-8.0.0/example/cloud/node1 into
   /solr-8.0.0/example/cloud/node2

Starting up Solr on port 8983 using command:
"bin/solr" start -cloud -p 8983 -s "example/cloud/node1/solr"

Waiting up to 180 seconds to see Solr running on port 8983 [\]
Started Solr server on port 8983 (pid=34942). Happy searching!


Starting up Solr on port 7574 using command:
"bin/solr" start -cloud -p 7574 -s "example/cloud/node2/solr" -z localhost:9983

Waiting up to 180 seconds to see Solr running on port 7574 [\]
Started Solr server on port 7574 (pid=35036). Happy searching!

INFO  - 2017-07-27 12:28:02.835; org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider; Cluster at localhost:9983 ready

请注意,Solr的两个实例已在两个节点上启动。因为我们从SolrCloud模式开始,并且没有定义有关外部ZooKeeper集群的任何细节,所以Solr启动它自己的ZooKeeper并将两个节点连接到它。

启动完成后,系统将提示您创建用于索引数据的集合。

Now let's create a new collection for indexing documents in your 2-node cluster.
Please provide a name for your new collection: [gettingstarted]

这是我们偏离默认选项的第一个地方。本教程将要求您索引Solr中包含的一些示例数据,称为“techproducts”数据。让我们将我们的产品命名为“techproducts”,这样就可以轻松区分我们稍后将创建的其他系列。techproducts在提示符处输入并点击enter。

  • 输入techproducts 按enter 回车
How many shards would you like to split techproducts into? [2]

这是询问您希望在两个节点之间拆分索引的分片数。选择“2”(默认值)意味着我们将在两个节点之间相对均匀地拆分索引

回车

How many replicas per shard would you like to create? [2]

副本是用于故障转移的索引的副本。同样,默认值“2”也可以从这里开始

回车

Please choose a configuration for the techproducts collection, available options are:
_default or sample_techproducts_configs [_default]

 Solr有两个配置文件样本集(称为configSet) 

集合必须具有configSet,其至少包括Solr的两个主要配置文件:模式文件(名为managed-schema或者schema.xml),以及solrconfig.xml。这里的问题是您想要从哪个configSet开始。这_default是一个简单的选项,但请注意,其中一个名称包含“techproducts”,与我们命名为我们的集合相同。此configSet专门用于支持我们要使用的示例数据,因此请sample_techproducts_configs在提示符下输入并点击enter。

此时,Solr将创建集合并再次向屏幕输出它发出的命令。

  • 输入sample_techproducts_configs回车 or 直接回车
<span style="color:rgba(0, 0, 0, 0.8)"><span style="color:rgba(0, 0, 0, 0.9)"><code>Uploading /solr-8.0.0/server/solr/configsets/_default/conf for config techproducts to ZooKeeper at localhost:9983

Connecting to ZooKeeper at localhost:9983 ...
INFO  - 2017-07-27 12:48:59.289; org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider; Cluster at localhost:9983 ready
Uploading /solr-8.0.0/server/solr/configsets/sample_techproducts_configs/conf for config techproducts to ZooKeeper at localhost:9983

Creating new collection 'techproducts' using command:
http://localhost:8983/solr/admin/collections?action=CREATE&name=techproducts&numShards=2&replicationFactor=2&maxShardsPerNode=2&collection.configName=techproducts

{
  "responseHeader":{
    "status":0,
    "QTime":5460},
  "success":{
    "192.168.0.110:7574_solr":{
      "responseHeader":{
        "status":0,
        "QTime":4056},
      "core":"techproducts_shard1_replica_n1"},
    "192.168.0.110:8983_solr":{
      "responseHeader":{
        "status":0,
        "QTime":4056},
      "core":"techproducts_shard2_replica_n2"}}}

Enabling auto soft-commits with maxTime 3 secs using the Config API

POSTing request to Config API: http://localhost:8983/solr/techproducts/config
{"set-property":{"updateHandler.autoSoftCommit.maxTime":"3000"}}
Successfully set-property updateHandler.autoSoftCommit.maxTime to 3000

SolrCloud example running, please visit: http://localhost:8983/solr</code></span></span>

恭喜!Solr准备好了数据!

 

在页面输入http://localhost:8983/solr/

查看效果,右显示就说明ok了

 

索引Techproducts数据

编入索引

您的Solr服务器已启动并正在运行,但它尚未包含任何数据,因此我们无法进行任何查询。

Solr包含该bin/post工具,以便于轻松索引各种类型的文档。我们将使用此工具作为下面的索引示例。

您需要一个命令shell来运行以下一些示例,这些示例以Solr安装目录为根; 你发起Solr的shell工作得很好。

  • 目前该bin/post工具没有类似的Windows脚本,但可以使用调用的基础Java程序

Linux/苹果机我们将索引的数据位于example/exampledocs目录中。文档采用多种文档格式(JSON,CSV等),幸运的是我们可以将它们全部编入索引:

solr-8.0.0:$ bin/post -c techproducts example/exampledocs/*

windows

C:\solr-8.0.0> java -jar -Dc=techproducts -Dauto example\exampledocs\post.jar example\exampledocs\*

您应该看到类似于以下内容的输出:

SimplePostTool version 5.0.0
Posting files to [base] url http://localhost:8983/solr/techproducts/update...
Entering auto mode. File endings considered are xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log
POSTing file books.csv (text/csv) to [base]
POSTing file books.json (application/json) to [base]/json/docs
POSTing file gb18030-example.xml (application/xml) to [base]
POSTing file hd.xml (application/xml) to [base]
POSTing file ipod_other.xml (application/xml) to [base]
POSTing file ipod_video.xml (application/xml) to [base]
POSTing file manufacturers.xml (application/xml) to [base]
POSTing file mem.xml (application/xml) to [base]
POSTing file money.xml (application/xml) to [base]
POSTing file monitor.xml (application/xml) to [base]
POSTing file monitor2.xml (application/xml) to [base]
POSTing file more_books.jsonl (application/json) to [base]/json/docs
POSTing file mp500.xml (application/xml) to [base]
POSTing file post.jar (application/octet-stream) to [base]/extract
POSTing file sample.html (text/html) to [base]/extract
POSTing file sd500.xml (application/xml) to [base]
POSTing file solr-word.pdf (application/pdf) to [base]/extract
POSTing file solr.xml (application/xml) to [base]
POSTing file test_utf8.sh (application/octet-stream) to [base]/extract
POSTing file utf8-example.xml (application/xml) to [base]
POSTing file vidcard.xml (application/xml) to [base]
21 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/techproducts/update...
Time spent: 0:00:00.822

ok

现在我们准备开始搜索了。

 

基本搜索

可以通过REST客户端,curl,wget,Chrome POSTMAN等以及可用于许多编程语言的本机客户端查询Solr。

Solr Adminui 搜索界面

http://localhost:7574/solr/#/techproducts/query

点击查询

获取信息

 

ok   到这里就ok了

 

jvm配置

-DSTOP.KEY=solrrocks
-DSTOP.PORT=7983
-Djava.io.tmpdir=F:\solr\solr-8.1.1\server\tmp
-Djetty.home=F:\solr\solr-8.1.1\server
-Djetty.host=0.0.0.0
-Djetty.port=8983
-Dlog4j.configurationFile=file:///F:\solr\solr-8.1.1\server\resources\log4j2.xml
-Dsolr.default.confdir=F:\solr\solr-8.1.1\server\solr\configsets\_default\conf
-Dsolr.install.dir=F:\solr\solr-8.1.1
-Dsolr.log.dir=F:\solr\solr-8.1.1\server\logs-Dsolr.log.muteconsole
-Dsolr.solr.home=F:\solr\solr-8.1.1\server\solr
-Duser.timezone=UTC
-XX:+AlwaysPreTouch
-XX:+ParallelRefProcEnabled
-XX:+PerfDisableSharedMem
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintHeapAtGC
-XX:+PrintTenuringDistribution
-XX:+UseG1GC
-XX:+UseGCLogFileRotation
-XX:+UseLargePages
-XX:GCLogFileSize=20M
-XX:MaxGCPauseMillis=250
-XX:NumberOfGCLogFiles=9
-Xloggc:F:\solr\solr-8.1.1\server\logs\solr_gc.log
-Xms512m
-Xmx512m
-Xss256k
-verbose:gc

 

 

持续更新

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值