SolrCloud应用简介

1、windows下启动实例工程

官网下载solr后解压到本地硬盘,在sol/bin目录下打开命令行窗口,然后测试以下命令:

solr -e cloud 启动例子中的solrcould,进入交互界面,会让你输入创建的node数(默认2个),要绑定的端口,以及创建collection名称等,基本都默认即可。若想直接用默认的值创建这个工程实例直接输入命令:solr -e cloud -noprompt;
solr start -cloud -s example/cloud/node1/solr -p 8983 通过-s命令指定要启动的实例名
solr status 显示实例状态
solr healthcheck -c gettingstarted 检查solrcould实例gettingstarted 的健康状态;
solr stop -all 停止所有的solr实例
solr restart -c -p 8983 -s example/cloud/node1/solr 重启实例node1;

solr restart -c -p 7574 -z localhost:9983 -s example/cloud/node2/solr 重启实例node2,增加-z选项,是为了和node1绑定在一个集群上,否则若没有-z选项默认该node会绑定solr端口+1000即8574上;

https://cwiki.apache.org/confluence/display/solr/Getting+Started+with+SolrCloud

2、更新配置文件

在使用DIH时需要自己配置solrconfig.xml,data-config.xml,schema.xml几个配置文件,solr自带的实例是独立模式运行下的,其中的配置文件默认是在core里的conf文件夹下;而solrcould的配置文件是保存在zookeeper中的,要使用DIH导入数据必须要更新配置文件。

上面命令solr -e cloud执行时,会自动把默认配置集下的data_driven_schema_configs目录上传到zookeeper中并关联到默认的collection中。

solr create -c mycollection -d data_driven_schema_configs 命令会创建一个名字为mycollection的collection,并且上传-d指定的data_driven_schema_configs文件到zookeeper中并与mycollection关联;

对于已经有配置文件的collection可以通过zkcli or SolrJ更新配置文件;以zkcli为例:zkcli.bat -cmd upconfig -zkhost  <host:port> -confname <name for configset> -solrhome <solrhome> -confdir <path to directory with configset>

https://cwiki.apache.org/confluence/display/solr/Using+ZooKeeper+to+Manage+Configuration+Files

https://cwiki.apache.org/confluence/display/solr/Command+Line+Utilities

原文地址:https://www.cnblogs.com/doit8791/p/4896243.html