设为首页 收藏本站
查看: 962|回复: 0

[经验分享] solr 5.0.0 bin/start脚本详细解析

[复制链接]

尚未签到

发表于 2015-11-12 08:32:49 | 显示全部楼层 |阅读模式
参考文档: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 &quot;<string>&quot;   


  启动Solr时,添加额外的JVM参数                    



bin/solr start -a
&quot;-Xdebug -Xrunjdwp:transport=dt_socket,
server=y,suspend=n,address=1044&quot;



  -cloud
  以SolrCloud模式启动Solr
  简短写法:-c
  



./bin/solr start -c
-d <dir>  定义server目录,默认是server ( $SOLR_HOME/server),
  一般不会重置这个目录



./bin/solr start -d newServerDir
-e <name>  以样例配置启动Solr
  可选项为:


  • cloud
  • techproducts
  • dih
  • schemaless

./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端口&#43;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&#26684;式显示本系统上所有在运行的Solr服务实例, 通过SOLR_PID_DIR环境变量定位Solr服务进程PID的存储文件,进而发现Solr服务实例。 默认SOLR_PID_DIR在bin目录下。
  以下是在单机集群上运行status的样例:
  Found 2 Solr nodes:

Solr process 39920 running on port 7574
{
&quot;solr_home&quot;:&quot;/Applications/Solr/solr-5.0.0/example/cloud/node2/solr/&quot;,
&quot;version&quot;:&quot;5.0.0 1658469 - anshumgupta - 2015-02-09 09:54:36&quot;,
&quot;startTime&quot;:&quot;2015-02-10T17:19:54.739Z&quot;,
&quot;uptime&quot;:&quot;1 days, 23 hours, 55 minutes, 48 seconds&quot;,
&quot;memory&quot;:&quot;77.2 MB (%15.7) of 490.7 MB&quot;,
&quot;cloud&quot;:{
&quot;ZooKeeper&quot;:&quot;localhost:9865&quot;,
&quot;liveNodes&quot;:&quot;2&quot;,
&quot;collections&quot;:&quot;2&quot;}}

Solr process 39827 running on port 8865
{
&quot;solr_home&quot;:&quot;/Applications/Solr/solr-5.0.0/example/cloud/node1/solr/&quot;,
&quot;version&quot;:&quot;5.0.0 1658469 - anshumgupta - 2015-02-09 09:54:36&quot;,
&quot;startTime&quot;:&quot;2015-02-10T17:19:49.057Z&quot;,
&quot;uptime&quot;:&quot;1 days, 23 hours, 55 minutes, 54 seconds&quot;,
&quot;memory&quot;:&quot;94.2 MB (%19.2) of 490.7 MB&quot;,
&quot;cloud&quot;:{
&quot;ZooKeeper&quot;:&quot;localhost:9865&quot;,
&quot;liveNodes&quot;:&quot;2&quot;,
&quot;collections&quot;:&quot;2&quot;}}



  
  

3. 停止
  stop命令会发送一个STOP请求到一个运行的Solr节点,请求节点优雅的停止;该命令会等待节点优雅停止,5秒后未停止,则执行强制杀死服务进程(kill -9).
  ./bin/solr stop [options]



./bin/solr stop -help


  
  

3.1 命令可选项

参数
描述  样例


  -p
  <port>                                          



停止运行在指定端口的服务                                       
<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr stop -p 8983

  -k <key>
  



停止KEY, 用于防止Solr意外停止,默认是“solrrocks”
<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr stop -k solrrocks

  -all
  



停止所有有效PID的Solr服务进程
<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr stop -all


4. 健康检查
  在SolrCloud模式下,healthcheck会为指定的collection生成一份JSON&#26684;式的体检报告;内容为该集合中所有shard的每个replica的状态信息,包括提交的文档数和当前的状态信息。
  ./bin/solr healthcheck [options]



./bin/solr healthcheck -help


  
  

4.1 命令可选项
  参数


  描述


  样例


  -c <collection>                  
  



希望体检的collection名称(必须)                                             
./bin/solr healthcheck -c gettingstarted
  -z <zkhost>
  



ZooKeeper连接串,默认为Solr端口&#43;1000
<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr healthcheck -z localhost:2181

  


  以下是一份2个节点,并且使用内嵌ZooKeeper的体检请求和响应:
  $ ./bin/solr healthcheck -c gettingstarted -z localhost:9865

{
&quot;collection&quot;:&quot;gettingstarted&quot;,
&quot;status&quot;:&quot;healthy&quot;,
&quot;numDocs&quot;:0,
&quot;numShards&quot;:2,
&quot;shards&quot;:[
{
&quot;shard&quot;:&quot;shard1&quot;,
&quot;status&quot;:&quot;healthy&quot;,
&quot;replicas&quot;:[
{
&quot;name&quot;:&quot;core_node1&quot;,
&quot;url&quot;:&quot;http://10.0.1.10:8865/solr/gettingstarted_shard1_replica2/&quot;,
&quot;numDocs&quot;:0,
&quot;status&quot;:&quot;active&quot;,
&quot;uptime&quot;:&quot;2 days, 1 hours, 18 minutes, 48 seconds&quot;,
&quot;memory&quot;:&quot;25.6 MB (%5.2) of 490.7 MB&quot;,
&quot;leader&quot;:true},
{
&quot;name&quot;:&quot;core_node4&quot;,
&quot;url&quot;:&quot;http://10.0.1.10:7574/solr/gettingstarted_shard1_replica1/&quot;,
&quot;numDocs&quot;:0,
&quot;status&quot;:&quot;active&quot;,
&quot;uptime&quot;:&quot;2 days, 1 hours, 18 minutes, 42 seconds&quot;,
&quot;memory&quot;:&quot;95.3 MB (%19.4) of 490.7 MB&quot;}]},
{
&quot;shard&quot;:&quot;shard2&quot;,
&quot;status&quot;:&quot;healthy&quot;,
&quot;replicas&quot;:[
{
&quot;name&quot;:&quot;core_node2&quot;,
&quot;url&quot;:&quot;http://10.0.1.10:8865/solr/gettingstarted_shard2_replica2/&quot;,
&quot;numDocs&quot;:0,
&quot;status&quot;:&quot;active&quot;,
&quot;uptime&quot;:&quot;2 days, 1 hours, 18 minutes, 48 seconds&quot;,
&quot;memory&quot;:&quot;25.8 MB (%5.3) of 490.7 MB&quot;},
{
&quot;name&quot;:&quot;core_node3&quot;,
&quot;url&quot;:&quot;http://10.0.1.10:7574/solr/gettingstarted_shard2_replica1/&quot;,
&quot;numDocs&quot;:0,
&quot;status&quot;:&quot;active&quot;,
&quot;uptime&quot;:&quot;2 days, 1 hours, 18 minutes, 42 seconds&quot;,
&quot;memory&quot;:&quot;95.4 MB (%19.4) of 490.7 MB&quot;,
&quot;leader&quot;: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的名称(必须)                                             
<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr create -c mycollection

  -d <confdir>

配置文件目录,默认为data_driven_schema_configs   
<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr create -d basic_configs

  -n <configName>
  



配置名称,默认与collection或core相同
<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr create -n basic

  -p <port>
  



命令发送到的运行实例的端口,默认脚本会根据运行实例自动检测端口
<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr create -p 8983

  -s <shards>
  -shards

collection被切割的shard数,默认为1;此参数只在solrCloud模式下有效
<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr create -s 2

  -rf <replicas>
  -replicationFactor

collection中每篇文档的备份数,默认为1(没有备份)
<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr -rf 2


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=&quot;html&quot; name=&quot;code&quot;>如果运行在SolrCloud模式,delete命令会检查待删除collection使用的配置是否被其他collection共享,如果有,则不删除ZooKeeper中对应的配置,否则,直接删除ZooKeeper的配置。



  
  

2.1 命令可选项

参数
描述
样例  -c <name>
  



删除的core或collection名称(必须)                                                     
<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr delete -c mycoll

  -deleteConfig <true|false>
  是否从ZooKeeper中删除配置,默认为true.
  如果配置被其它collection共享,则即使true,也不会删除



<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr delete -deleteConfig false

  -p <port>
  



命令发送到的本地运行Solr实例端口,默认脚本会根据运行实例检查端口
<pre class=&quot;html&quot; name=&quot;code&quot;>./bin/solr delete -p 8983

  


  



&#65279;&#65279;
&#65279;&#65279;
&#65279;&#65279;
&#65279;&#65279;

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-138108-1-1.html 上篇帖子: solr学习之九:MoreLikeThis相似查询 下篇帖子: solr读取word,pdf
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表