solr 5.0.0 bin/start脚本详细解析
参考文档:https://cwiki.apache.org/confluence/display/solr/Solr+Start+Script+Reference#SolrStartScriptReference-SolrCloudMode
环境:
CentOS 6.5, JRE 1.7, Solr 5.0.0, ZooKeeper 3.6
一、启动、停止操作
1. 启动、重启
./bin/solr start [options]
./bin/solr start -help
./bin/solr restart [options]
./bin/solr restart -help
1.1 命令可选项
|
参数 |
描述 |
样例 |
|---|---|---|
|
-a "<string>" |
启动Solr时,添加额外的JVM参数 |
|
|
-cloud |
以SolrCloud模式启动Solr 简短写法:-c |
./bin/solr start -c |
| -d <dir> |
定义server目录,默认是server ( 一般不会重置这个目录 |
./bin/solr start -d newServerDir |
| -e <name> |
以样例配置启动Solr 可选项为:
|
./bin/solr start -e schemaless |
| -f |
前端方式启动Solr服务, 运行样例时不可以此方式启动 |
./bin/solr start -f |
| -h <hostname> |
启动时, 为Solr服务指定hostname, 默认为'localhost' |
./bin/solr start -h search.mysolr.com |
| -m <memory> |
启动时, 为JVM指定最小(-Xms)和最大(-Xmx)堆大小 |
./bin/solr start -m 1g |
| -noprompt |
启动时,接受一切默认设置,不需要交互确认 |
./bin/solr start -e cloud -noprompt |
| -p <port> |
在指定的端口启动Solr服务,默认为'8983' |
./bin/solr start -p 8655 |
| -s <dir> |
设置solr.solr.home系统属性,默认server/solr. |
./bin/solr start -s newHome |
| -V |
启动Solr服务时, 显示冗余信息 |
./bin/solr start -V |
| -z <zkHost> |
以ZooKeeper连接串启动Solr服务,本选项只在SolrCloud运行模型下使用; 如果不指定本选项,则启动Solr内嵌的ZooKeeper 实例 |
./bin/solr start -c -z server1:2181,server2:2181 |
启动时,默认设置如何,以下两个启动命令效果一样:
./bin/solr start
./bin/solr start -h localhost -p 8983 -d server -s solr -m 512m
1.2 设置JAVA系统属性
bin/solr脚本可以传递任何以'-D'开始的参数到JVM
eg.
./bin/solr start -Dsolr.autoSoftCommit.maxTime=3000
1.3 SolrCloud模式
'-c'和'-cloud'两个选项是等价的:
./bin/solr start -c
./bin/solr start -cloud
以SolrCloud模式启动Solr服务时,如果指定了ZooKeeper连接串,(如,-z 192.168.1.4:2181),Solr则会连接到指定的ZooKeeper实例,并加入到集群;如果没有指定'-z', Solr则会启动内嵌的一个ZooKeeper实例,监听在端口——Solr端口+1000,(如,如果Solr端口为8983, 则内嵌ZooKeeper端口为9933)
注意:
如果ZooKeeper连接串使用了chroot, (如,localhost:2181/solr), 那么在加入到SolrCloud之前,你需要引导 /solr ZooKeeper节点, 使用Solr包自带的zkcli.sh脚本,例如:
- server/scripts/cloud-scripts/zkcli.sh -zkhost localhost:2181/solr -cmd bootstrap -solrhome server/solr
1.4 运行样例配置
./bin/solr start -e <name>
样例配置方便你快速学习Solr,主要提供提供了以下几种样例:
cloud 本样例在单机上启动了1到4个节点的SolrCloud集群,当你选择以交互式会话的方式启动服务时,它将引导你选择集群的节点数,端口,创建的collection名称
techproducts 本样例在单机上以独立模式启动了Solr服务,使用了为$SOLR_HOME/example/exampledocs 目录中文档设计好的scheme.xml, 配置目录(configset)为$SOLR_HOME/server/solr/configsets/sample_techproducts_configs
dih 本样例在单机上以独立模式启动Solr服务,并且开启了 DataImportHandler (DIH) , 另外,为多种数据类型(如, database contents, email, RSS feeds, 等)提供了预配置好的样例dataconfig.xml
schemaless 本样例在单机上以独立模式启动Solr服务,并且使用了managed schema, 提供了一个最小化的预定义的Scheme. 在索引文档时,Solr会根据提交的文档自动判断字段类型并动态的添加字段到Schem, 对应的配置目录为$SOLR_HOME/server/solr/configsets/data_driven_schema_configs.
2. 状态检查
status命令会以JSON格式显示本系统上所有在运行的Solr服务实例, 通过SOLR_PID_DIR环境变量定位Solr服务进程PID的存储文件,进而发现Solr服务实例。 默认SOLR_PID_DIR在bin目录下。
以下是在单机集群上运行status的样例:
- Found 2 Solr nodes:
- Solr process 39920 running on port 7574
- {
- "solr_home":"/Applications/Solr/solr-5.0.0/example/cloud/node2/solr/",
- "version":"5.0.0 1658469 - anshumgupta - 2015-02-09 09:54:36",
- "startTime":"2015-02-10T17:19:54.739Z",
- "uptime":"1 days, 23 hours, 55 minutes, 48 seconds",
- "memory":"77.2 MB (%15.7) of 490.7 MB",
- "cloud":{
- "ZooKeeper":"localhost:9865",
- "liveNodes":"2",
- "collections":"2"}}
- Solr process 39827 running on port 8865
- {
- "solr_home":"/Applications/Solr/solr-5.0.0/example/cloud/node1/solr/",
- "version":"5.0.0 1658469 - anshumgupta - 2015-02-09 09:54:36",
- "startTime":"2015-02-10T17:19:49.057Z",
- "uptime":"1 days, 23 hours, 55 minutes, 54 seconds",
- "memory":"94.2 MB (%19.2) of 490.7 MB",
- "cloud":{
- "ZooKeeper":"localhost:9865",
- "liveNodes":"2",
- "collections":"2"}}
3. 停止
stop命令会发送一个STOP请求到一个运行的Solr节点,请求节点优雅的停止;该命令会等待节点优雅停止,5秒后未停止,则执行强制杀死服务进程(kill -9).
./bin/solr stop [options]
./bin/solr stop -help
3.1 命令可选项
| 参数 | 描述 |
样例 |
|
-p <port> |
停止运行在指定端口的服务 |
|
|
-k <key> |
停止KEY, 用于防止Solr意外停止,默认是“solrrocks” |
|
|
-all |
停止所有有效PID的Solr服务进程 |
|
4. 健康检查
在SolrCloud模式下,healthcheck会为指定的collection生成一份JSON格式的体检报告;内容为该集合中所有shard的每个replica的状态信息,包括提交的文档数和当前的状态信息。
./bin/solr healthcheck [options]
./bin/solr healthcheck -help
4.1 命令可选项
|
参数 |
描述 |
样例 |
|
-c <collection> |
希望体检的collection名称(必须) |
|
|
-z <zkhost> |
ZooKeeper连接串,默认为Solr端口+1000 |
|
以下是一份2个节点,并且使用内嵌ZooKeeper的体检请求和响应:
- $ ./bin/solr healthcheck -c gettingstarted -z localhost:9865
- {
- "collection":"gettingstarted",
- "status":"healthy",
- "numDocs":0,
- "numShards":2,
- "shards":[
- {
- "shard":"shard1",
- "status":"healthy",
- "replicas":[
- {
- "name":"core_node1",
- "url":"http://10.0.1.10:8865/solr/gettingstarted_shard1_replica2/",
- "numDocs":0,
- "status":"active",
- "uptime":"2 days, 1 hours, 18 minutes, 48 seconds",
- "memory":"25.6 MB (%5.2) of 490.7 MB",
- "leader":true},
- {
- "name":"core_node4",
- "url":"http://10.0.1.10:7574/solr/gettingstarted_shard1_replica1/",
- "numDocs":0,
- "status":"active",
- "uptime":"2 days, 1 hours, 18 minutes, 42 seconds",
- "memory":"95.3 MB (%19.4) of 490.7 MB"}]},
- {
- "shard":"shard2",
- "status":"healthy",
- "replicas":[
- {
- "name":"core_node2",
- "url":"http://10.0.1.10:8865/solr/gettingstarted_shard2_replica2/",
- "numDocs":0,
- "status":"active",
- "uptime":"2 days, 1 hours, 18 minutes, 48 seconds",
- "memory":"25.8 MB (%5.3) of 490.7 MB"},
- {
- "name":"core_node3",
- "url":"http://10.0.1.10:7574/solr/gettingstarted_shard2_replica1/",
- "numDocs":0,
- "status":"active",
- "uptime":"2 days, 1 hours, 18 minutes, 42 seconds",
- "memory":"95.4 MB (%19.4) of 490.7 MB",
- "leader":true}]}]}
二、Collection、Core操作
bin/solr脚本也能够帮助你创建collections(运行在SolrCloud模式)或者cores(运行在独立模式), 或者删除collections。
1. 创建
bin/solr create命令自动检测运行模式(SolrCloud或standalone),然后根据模式执行创建collection还是core.
./bin/solr create options
./bin/solr create -help
1.1 命令可选项
| 参数 | 描述 | 样例 |
|
-c <name> |
创建的collection或core的名称(必须) |
|
|
-d <confdir> |
配置文件目录,默认为data_driven_schema_configs |
|
|
-n <configName> |
配置名称,默认与collection或core相同 |
|
|
-p <port> |
命令发送到的运行实例的端口,默认脚本会根据运行实例自动检测端口 |
|
|
-s <shards> -shards |
collection被切割的shard数,默认为1;此参数只在solrCloud模式下有效 |
|
|
-rf <replicas> -replicationFactor |
collection中每篇文档的备份数,默认为1(没有备份) |
|
1.2 配置目录和SolrCloud
在SolrCloud中创建collection之前,我们必须把collection用到的配置目录上传到ZooKeeper实例;create命令提供了几种collction与配置目录的工作方案,你最主要考虑是否决定让配置目录在多个collection之间共享。以下讲解几个样例,说明collection与配置目录如何工作的:
首先,如果你不指定-d或者-n选项,则默认的配置($SOLR_HOME/server/solr/configsets/data_driven_schema_configs/conf)会以collection相同的名称上传到ZooKeeper。例如,./bin/solr create -c contacts, 此命令将data_driven_schema_configs配置上传到ZooKeeper的/configs/contacts目录下。
如果你通过命令./bin/solr create -c contacts2,创建另外一个集合contacts2, 则data_driven_schema_configs的另一份拷贝被上传到ZooKeeper的/configs/contacts2目录下;对contacts配置的任何修改都不会影响到contacts2;简言之,创建collection时,默认会为每个新的collection创建一个独立的配置副本。
你可以使用-n选项,为上传到ZooKeeper中的配置命名。例如,命令./bin/solr create -c logs -d basic_configs -n basic会将 server/solr/configsets/basic_configs/conf配置目录上传到ZooKeeper的/configs/basic下。
我们可以使用-d选项指定非默认的配置, solr在server/solr/configsets下提供了一些内建的配置,你也可以通过-d选项指定自己的配置。例如,命令./bin/solr create -c mycoll -d /tmp/myconfigs会上传本地/tmp/myconfigs目录到ZooKeeper的/configs/mycoll,另外,ZooKeeper中的配置名称与collection相同,除非你使用了-n选项重新命名。
别的collections可以通过-n选项指定共享的配置,例如,命令./bin/solr create -c logs2 -n basic将创建logs2集合,并共享basic配置。
1.3 数据驱动的Scheme和共享配置
数据驱动的Scheme(data_driven_schema_configs)会随着索引的数据动态变化,因此,我们不建议你在collection之间共享数据驱动的Scheme,除非你确定各个collection继承共享配置集合中任何一个collection的变化。
2. 删除
delete命令自动检测服务运行模式(SolrCloud或Standalone),并执行相应的删除collection(SolrCloud模式)或者core(Standalone模式)操作。
./bin/solr delete [options]
./bin/solr delete -help
- </pre><pre class="html" name="code">如果运行在SolrCloud模式,delete命令会检查待删除collection使用的配置是否被其他collection共享,如果有,则不删除ZooKeeper中对应的配置,否则,直接删除ZooKeeper的配置。
2.1 命令可选项
| 参数 | 描述 | 样例 |
|
-c <name> |
删除的core或collection名称(必须) |
|
|
-deleteConfig <true|false> |
是否从ZooKeeper中删除配置,默认为true. 如果配置被其它collection共享,则即使true,也不会删除 |
|
|
-p <port> |
命令发送到的本地运行Solr实例端口,默认脚本会根据运行实例检查端口 |
|
solr 5.0.0 bin/start脚本详细解析的更多相关文章
- solr 5.1.0安装-Windows(亦可用于5.4.1)
以前4.10的时候写过一个安装教程,是安装在tomcat的,在来安装5.1的时候,看了下简介,发现从5.x后solr集成了jetty,安装变得简单了不少. 现在只需要三步就能搞定,下载solr包解压, ...
- redis3.0.0 集群安装详细步骤
Redis集群部署文档(centos6系统) Redis集群部署文档(centos6系统) (要让集群正常工作至少需要3个主节点,在这里我们要创建6个redis节点,其中三个为主节点,三个为从节点,对 ...
- Tomcat7.0.22在Windows下详细配置过程
Tomcat7.0.22在Windows下详细配置过程 一.JDK1.7安装 1.下载jdk,下载地址:http://www.oracle.com/technetwork/java/javase/do ...
- Solr 5.5.0 + tomcat 7.0.69 + zookeeper-3.4.6 Cloud部署
Solr介绍:Solr是一个独立的企业级搜索应用服务器,Solr基于Lucene的全文搜索服务器,同时对其进行了扩展,提供了比Lucene更为丰富的查询语言,同时实现了可配置.可扩展并对查询性能进行了 ...
- 超详细!CentOS 7 + Hadoop3.0.0 搭建伪分布式集群
超详细!CentOS 7 + Hadoop3.0.0 搭建伪分布式集群 ps:本文的步骤已自实现过一遍,在正文部分避开了旧版教程在新版使用导致出错的内容,因此版本一致的情况下照搬执行基本不会有大错误. ...
- solr&lucene3.6.0源码解析(一)
本文作为系列的第一篇,主要描述的是solr3.6.0开发环境的搭建 首先我们需要从官方网站下载solr的相关文件,下载地址为http://archive.apache.org/dist/luc ...
- Solr 6.6.0 ERROR: Port 8983 is already being used by another process.
在目录D:\work\Solr\solr-6.6.0\bin下打开命令框: 输入:solr -e dih报错:ERROR: Port 8983 is already being used by ano ...
- Solr 4.4.0安装
软件包准备 JDK http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin Solr https://archi ...
- Apache solr 6.6.0安装
Apache solr 6.6.0安装 最近使用了Apache solr搜索引擎框架,solr是基于lucene的一个搜索服务器,lucene也是Apache的一个开源项目:对于学习搜索引擎来说,这个 ...
随机推荐
- 泛型算法,排序的相关操作,lower_bound、upper_bound、equal_range
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...
- iPhoneX && iOS11 适配
最近实在是蛮闲的,这都得益于苹果爸爸给力的审核,已经半个月了(委屈) 这个问题已经很久了,但是还是希望分享给各位,当然网上的教程的确很多: 1.automaticallyAdjustsScrollVi ...
- form 表单模板
<div class="modal-dialog modal-lg"> //大布局modal-lg <div class="modal-content& ...
- nginx统计模块——ngx_http_stub_status_module
今天呢给大家分享一个nginx的统计模块的使用,这个模快我们是经常的使用呢,在我们对nginx最优化,调优的时候我们就需要借助这个模块去分析nginx的性能. 下面我们来看看这个模块的语法格式, 这个 ...
- chromium ⑤
我们都知道chromium是用webkit完成页面显示的, 那么chromium是怎样集成和封装webkit的呢? 是怎样将webkit整合到自己的框架中,并将一个页面渲染出来的? 这篇我 ...
- 复习回顾(String,StringBuffer,Arrays方法总结)
String: String类的对象是一经创建就无法变动内容的字符串常量,创建String类的对象可以使用直接赋值和利用构造方法赋值 String str=“hello”; String str=n ...
- 2017ICPC南宁赛区网络赛 Overlapping Rectangles(重叠矩阵面积和=离散化模板)
There are nnn rectangles on the plane. The problem is to find the area of the union of these rectang ...
- Golang游戏服务器与skynet的个人直观比较
我对和GOLANG写MMO服务器的一些遐想: 1.沙盒(隔离性) SKYNET:原生LUA STATE作为沙盒, 进行服务器间隔离安全性高: 服务可以很容易的配置到不同节点之上. GO:估计用RECO ...
- C++ STL 数据结构与算法 —— 排序
1. Top k 大的数 排序后直接索引输出:O(nlogn)" role="presentation">O(nlogn)O(nlogn) std::sort( ...
- JAVA基础部分复习(一、8中基础类型,以及String相关内容)
以下是关于java中8种基本类型的介绍说明: package cn.review.day01; /** * java基础复习,8种数据类型 * (byte,short,long,int,double, ...