环境说明
一、Solr's zkcli.sh
Solr官方提供了一个Zookeeper插件 – zkcli.sh,使用该工具,可以实现将本地文件上传到zookeeper的Znode上。
文件所在位置: /usr/lib/ambari-infra-solr/server/scripts/cloud-scripts/zkcli.sh
1. 使用语法:
2. 使用案例:
查看zookeeper上的某文件:
-
/usr/lib/ambari-infra-solr/server/scripts/cloud-scripts/zkcli.sh -zkhost node96.xdata:2181,node97.xdata:2181,node98.xdata:2181 -cmd get /infra-solr/configs/collection5
下载zookeeper上的某文件:
-
/usr/lib/ambari-infra-solr/server/scripts/cloud-scripts/zkcli.sh -zkhost node96.xdata:2181,node97.xdata:2181,node98.xdata:2181 -cmd getfile /infra-solr/configs/collection5/solrconfig.xml /root/solrconfig.xml
上传及修改zookeeper上的znode
-
/usr/lib/ambari-infra-solr/server/scripts/cloud-scripts/zkcli.sh -zkhost node96.xdata:2181,node97.xdata:2181,node98.xdata:2181 -cmd putfile /infra-solr/configs/ranger_audits/solr-data-config.xml /usr/lib/ambari-infra-solr/example/example-DIH/solr/solr/conf/solr-data-config.xml
创建zookeeper的znode
-
/usr/lib/ambari-infra-solr/server/scripts/cloud-scripts/zkcli.sh -zkhost node96.xdata:2181,node97.xdata:2181,node98.xdata:2181 -cmd makepath /infra-solr/configs/collection1
修改zookeeper的znode信息
-
/usr/lib/ambari-infra-solr/server/scripts/cloud-scripts/zkcli.sh -zkhost node96.xdata:2181,node97.xdata:2181,node98.xdata:2181 -cmd put /infra-solr/configs/collection10 "123"
删除zookeeper的znode
-
/usr/lib/ambari-infra-solr/server/scripts/cloud-scripts/zkcli.sh -zkhost node96.xdata:2181,node97.xdata:2181,node98.xdata:2181 -cmd clear /infra-solr/configs/collection1
与ambari-infra-solr不适配的命令
将本地文件夹上传到zookeeper
-
/usr/lib/ambari-infra-solr/server/scripts/cloud-scripts/zkcli.sh -zkhost node96.xdata:2181,node97.xdata:2181,node98.xdata:2181 -cmd upconfig -confdir solrConfigs -confname myconf
这样是将本地目录 solrConfigs上传到了 zookeeper上的 /configs/myconf,这与ambari-infra-solr的zookeeper的路径不符,不符合我的需求。
像 linkconfig, downconfig也是不建议使用的。