windows下solr6的solrcloud使用

solr版本:solr-6.0.1

本地启动solr的集群,根据官方手册指导执行以下命令

D:\solr-6.0.1\bin>solr.cmd -e cloud

该命令将默认启动两个端口的solr实例,8983,7574,同时启动内置的zookeeper服务,默认端口为9983.

控制台输出信息:

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? (spec

ify 1-4 nodes) [2]:        

Ok, let's start up 2 Solr nodes for your example SolrCloud cluster.

Please enter the port for node1 [8983]:

Please enter the port for node2 [7574]:

接着自动创建两个节点,其路径为:

Creating Solr home directory D:\solr-6.0.1\example\cloud\node1\solr

Cloning D:\solr-6.0.1\example\cloud\node1 into  D:\solr-6.0.1\example\cloud\node2

节点启动命令为:

    Starting up Solr on port 8983 using command:

D:\solr-6.0.1\bin\solr.cmd start -cloud -p 8983 -s "D:\solr-6.0.1\example\cloud\node1\solr"

Waiting up to 30 to see Solr running on port 8983 

Starting up Solr on port 7574 using command:

D:\solr-6.0.1\bin\solr.cmd start -cloud -p 7574 -s "D:\solr-6.0.1\example\cloud\

node2\solr" -z localhost:9983

默认的分片值为2,每个分片2个节点

How many shards would you like to split gettingstarted into? [2]

2

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

2

创建solr配置,默认名称为:gettingstarted,配置文件可以从

basic_configs, data_driven_schema_configs, or sample_techproducts_configs [data_

driven_schema_configs]中选择,默认为data_driven_schema_configs

上传配置到zookeeper,其路径为:/configs/gettingstarted

可通过zk客户端脚本连接查看:

D:\zookeeper-3.4.8\bin>zkCli.cmd -server localhost:9983

[zk: localhost:9983(CONNECTED) 1] ls /configs/gettingstarted/

 

currency.xml         managed-schema       protwords.txt

solrconfig.xml       synonyms.txt         elevate.xml

configoverlay.json   stopwords.txt        lang

params.json

等待创建名为gettingstartedcollection

Creating new collection 'gettingstarted' using command:

http://localhost:8983/solr/admin/collections?action=CREATE&name=gettingstarted&n

umShards=2&replicationFactor=2&maxShardsPerNode=2&collection.configName=gettings

tarted

 

{

  "responseHeader":{

    "status":0,

    "QTime":17386},

  "success":{

    "127.0.0.1:8983_solr":{

      "responseHeader":{

        "status":0,

        "QTime":7119},

      "core":"gettingstarted_shard1_replica2"},

    "127.0.0.1:7574_solr":{

      "responseHeader":{

        "status":0,

        "QTime":7400},

      "core":"gettingstarted_shard1_replica1"}}}

完成后可以在浏览器输入http://localhost:8983/solr查看结果




 
 

为分片增加节点

D:\solr-6.0.1\example\cloud路径下创建node3\solr文件夹,复制D:\solr-6.0.1\server\solr下的solr.xml文件到node3\solr下,启动该节点实例:

D:\solr-6.0.1>bin\solr.cmd -cloud -s example\cloud\node3\solr -p 8987 -z localhost:9983

Waiting up to 30 to see Solr running on port 8987

Started Solr server on port 8987. Happy searching!

collection菜单中即可对分片添加活动节点,如图所示




 
 

添加后的结果为:




 
 

另外一个分片操作相同。

创建新的配置

上传配置文件到zookeeper,可以使用solrzkcli脚本,windows操作如下:新建名为test的配置,使用D:\solr-6.0.1\server\solr\configsets\basic_configs下的配置文件

D:\solr-6.0.1\server\scripts\cloud-scripts>zkcli.bat -cmd upconfig -zkhost local

host:9983 -confname test -confdir ..\..\solr\configsets\basic_configs\conf

执行命令后,新建名为test的配置

[zk: localhost:9983(CONNECTED) 3] ls /configs/test

[currency.xml, managed-schema, protwords.txt, solrconfig.xml, synonyms.txt, stop

words.txt, _rest_managed.json, lang]

新建collection,如图




 
 

         创建成功后如下:

 




 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值