solr4.7.2集群搭建(2)

前文概述

上篇介绍solr集群的搭建,本文将介绍如何创建,删除,更新集群索引配置

创建索引

1)查看集群索引配置文件,发现solrconf

2)如果使用集群默认的索引配置文件solrconf,设置collection.configName=solrconf

http://127.0.0.1:8891/solr/admin/collections?
action=CREATE  (操作)
&name=testcore   (core名称)
&numShards=3      (分片数)
&replicationFactor=2  (副本数)
&maxShardsPerNode=2  (每个节点分片数)
&collection.configName=solrconf  (配置文件路径)

3) 发送请求

http://127.0.0.1:8891/solr/admin/collections?action=CREATE&name=testcore&numShards=3&replicationFactor=2&maxShardsPerNode=2&collection.configName=solrconf

4)请求结果

5) solr admin

上传配置

利用solr自带zkcli.bat实现上传

目录:solr-4.7.2\example\scripts\cloud-scripts\zkcli.bat

1) 本地文件路径

最好配置文件路径和zkcli.bat在同一个磁盘,这样可以用是linux目录形式

 D:\Soft\solr-cloud\solrhome1\solr\collection1\conf

2)执行上传命令

D:\Soft\solr-4.7.2\example\scripts\cloud-scripts>zkcli.bat -zkhost 127.0.0.1:2181 -cmd upconfig -confdir /Soft/solr-cloud/solrhome1/solr/collection1/conf -confname democore

发现报错

D:\Soft\solr-4.7.2\example\scripts\cloud-scripts>"java" -Dlog4j.configuration="file:D:\Soft\solr-4.7.2\example\scripts\cloud-scripts\log4j.properties" -classpath "D:\Soft\solr-4.7.2\example\scripts\cloud-scripts\..\..\solr-webapp\webapp\WEB-INF\lib\*;D:\Soft\solr-4.7.2\example\scripts\cloud-scripts\..\..\lib\ext\*" org.apache.solr.cloud.ZkCLI -zkhost 127.0.0.1:2181 -cmd upconfig -confdir /Soft/solr-cloud/solrhome1/solr/collection1/conf -confname democore
错误: 找不到或无法加载主类 org.apache.solr.cloud.ZkCLI

3)查看zkcli.bat源码

REM  Find location of this script

set SDIR=%~dp0
if "%SDIR:~-1%"=="\" set SDIR=%SDIR:~0,-1%

"%JVM%" -Dlog4j.configuration="file:%SDIR%\log4j.properties" -classpath "%SDIR%\..\..\solr-webapp\webapp\WEB-INF\lib\*;%SDIR%\..\..\lib\ext\*" org.apache.solr.cloud.ZkCLI %*

发现solr-4.7.2\example\solr-webapp中是空白目录,缺少依赖jar包,导致org.apache.solr.cloud.ZkCLI类不存在
将apache-tomcat-7.0.69-1\webapps\solr\WEB-INF\lib中的jar包(solr.war)全部拷贝到solr-4.7.2\example\solr-webapp\webapp\WEB-INF\lib目录中

4)执行上传命令

D:\Soft\solr-4.7.2\example\scripts\cloud-scripts>zkcli.bat -zkhost 127.0.0.1:2181 -cmd upconfig -confdir /Soft/solr-cloud/solrhome1/solr/collection1/conf -confname democore

5) 执行成功

删除索引

http://127.0.0.1:8891/solr/admin/collections?action=DELETE&name=testcore

重新加载索引

http://127.0.0.1:8891/solr/admin/collections?action=RELOAD&name=collection1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值