Solr 启动一个SolrCloud实例所需要的所有配置和相关参数

本文详细介绍了如何安装、配置并启动SolrCloud,包括使用ZooKeeper进行管理,配置和启动collection的过程。重点包括Solr的Service方式安装、ZooKeeper配置与启动、collection的创建与配置,以及通过CollectionsAPI进行管理和操作。此外,提供了Solr配置文件的配置方法,以及如何通过API进行collection的创建、修改和删除等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

终于搭建好了一个SolrCloud并可以正常运行了。下面总结一下其中的过程。。。SolrCloud使用ZooKeeper来管理配置文件,所以需要安装、配置、并启动ZooKeeper。

主要步骤:
  1. 安装和启动Solr(Service方式)
  2. 配置和启动ZooKeeper
  3. 配置和启动一个collection:
    1. 为新的collection创建配置文件目录、准备好配置文件
    2. 把配置文件上传到ZooKeeper
    3. 创建新的collection(使用Collections API)

1、安装和启动Solr(Service方式)
参考:Solr在Linux系统中的产品化安装

确保Solr是在solrCloud模式下运行(查询solr service状态,看看是否有“clound”字样):
# service solr status    

Found 1 Solr nodes: 

Solr process 2394 running on port 8983
{
  "solr_home":"/var/solr/data/",
  "version":"5.2.1 1684708 - shalin - 2015-06-10 23:20:13",
  "startTime":"2015-09-01T02:41:12.845Z",
  "uptime":"0 days, 0 hours, 0 minutes, 23 seconds",
  "memory":"26.4 MB (%5.4) of 490.7 MB",
  " cloud":{
    "ZooKeeper":"localhost:2181,localhost:2182,localhost:2183",
    "liveNodes":"1",
    "collections":"0"}}

2、配置和启动ZooKeeper
参考:Zookeeper及其安装配置和启动

3、配置和启动一个collection

3.1、为新的collection创建配置文件目录、准备好配置文件
从模板拷贝一份配置文件后自己修改:
cd /opt/app/solr/server/solr/configsets
cp -r basic_configs/conf course_video
cd course_video

以DIH为例,修改配置文件:
参考:Solr DataImportHandler 配置

其他相关配置文件的配置方法:


3.2、把配置文件上传到ZooKeeper(使用zkcli.sh)
zkcli.sh位于<solr_home>/server/scripts/cloud-scripts/目录下面。

# cd <solr_home>
# ./server/scripts/cloud-scripts/zkcli.sh -z localhost:2181  -cmd upconfig -confname <config_name> -confdir  server/solr/configsets/<conf_dir>

例如:
cd /opt/app/solr
./server/scripts/cloud-scripts/zkcli.sh -z localhost:2181  -cmd upconfig -confname course_video -confdir server/solr/configsets/course_video

查看配置文件列表:
/opt/app/solr/server/scripts/cloud-scripts/zkcli.sh -cmd list -z localhost:2181

注:修改配置文件后,需要使它生效:
  • 管理界面方法:Core Admin -> 选择修改过的core -> reload
  • Collections API方法:curl 'http://localhost:8983/solr/admin/collections?action=RELOAD&name=course_video'

3.3、创建新的collection(使用Collections API)
curl 'http://<hostname>:<port>/solr/admin/collections?action=CREATE&name=<name>&numShards=1' (其他都是非必填参数)

例如:
curl 'http://localhost:8983/solr/admin/collections?action=CREATE&name=course_video&numShards=1'

如果需要修改配置:
  1. 修改配置文件
  2. 上传到ZooKeeper
  3. Reload Collection:curl 'http://localhost:8983/solr/admin/collections?action=RELOAD&name=course_video'
  4. 重建索引:curl 'http://localhost:8983/solr/course_video/dataimport?command=full-import&wt=json'


:监看solr的log:
tail -f /var/solr/logs/solr.log

:Collections API列表:
Base URL:http://<hostname>:<port>/solr
/admin/collections?action=CREATE: create a collection
/admin/collections?action=RELOAD: reload a collection
/admin/collections?action=SPLITSHARD: split a shard into two new shards
/admin/collections?action=CREATESHARD: create a new shard
/admin/collections?action=DELETESHARD: delete an inactive shard
/admin/collections?action=CREATEALIAS: create or modify an alias for a collection
/admin/collections?action=DELETEALIAS: delete an alias for a collection
/admin/collections?action=DELETE: delete a collection
/admin/collections?action=DELETEREPLICA: delete a replica of a shard
/admin/collections?action=ADDREPLICA: add a replica of a shard
/admin/collections?action=CLUSTERPROP: Add/edit/delete a cluster-wide property
/admin/collections?action=MIGRATE: Migrate documents to another collection
/admin/collections?action=ADDROLE: Add a specific role to a node in the cluster
/admin/collections?action=REMOVEROLE: Remove an assigned role
/admin/collections?action=OVERSEERSTATUS: Get status and statistics of the overseer
/admin/collections?action=CLUSTERSTATUS: Get cluster status
/admin/collections?action=REQUESTSTATUS: Get the status of a previous asynchronous request
/admin/collections?action=LIST: List all collections
/admin/collections?action=ADDREPLICAPROP: Add an arbitrary property to a replica specified by   collection/shard/replica 
/admin/collections?action=DELETEREPLICAPROP: Delete an arbitrary property from a replica specified   by collection/shard/replica 
/admin/collections?action=BALANCESHARDUNIQUE: Distribute an arbitrary property, one per shard,   across the nodes in a collection 
/admin/collections?action=REBALANCELEADERS: Distribute leader role based on the "preferredLeader"   assignments

zkcli.sh命令参数列表:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值