ZooKeeper Operations

bin/solr脚本允许某些操作影响ZooKeeper。这些操作仅适用于Solrcloud模式。这些操作可以作为子命令使用,每个子命令都有自己的选项集。

 

bin/solr zk [sub-command] [options]

bin/solr zk -help

在发出这些命令以使用znodes所期望的初始化zookeeper之前,应该至少启动一次solr。初始化ZooKeeper后,solr不需要在任何节点上运行就可以使用这些命令。

  • 上传配置集

使用zk upconfig命令将预先配置的配置集或自定义配置集之一上传到zookeeper。

ZK Upload Parameters

以下所有参数都是必需的。

-n <name>

在ZooKeeper中设置的配置的名称。此命令将配置集上到“configs”zookeeper节点,并给出指定的名称。

您可以通过云屏幕在管理用户界面中看到所有上传的配置集。选择cloud->tree->configs查看它们。

如果指定了预先存在的配置集,它将在ZooKeeper中被覆盖。

Example: -n myconfig

-d <configset dir>

要上传的配置集的路径。它的下面应该有一个conf目录,该目录依次包含solrconfig.xml等。

如果只提供了一个名称,那么将检$solr_home/server/solr/configsets路径下以获取该名称。也可以提供绝对路径替换

Examples:

  • -d directory_under_configsets
  • -d /path/to/configset/source

-z <zkHost>

zoomkeepr连接字符串。如果zk_主机在solr.in.sh或solr.in.cmd中定义,则不需要。

Example: -z 123.321.23.43:2181

包含所有参数的此命令示例如下:

bin/solr zk upconfig -z 111.222.333.444:2181 -n mynewconfig -d /path/to/configset

更改配置时重新加载集合

此命令不会自动使更改生效!它只是将配置集上传到ZooKeeper。可以使用集合API的reload命令重新加载使用此配置集的任何集合。

  • 下载配置集合

使用zk downconfig命令将配置集从zookeeper下载到本地文件系统。

ZK Download Parameters

下面列出的所有参数都是必需的。

-n <name>

要下载的ZooKeeper中设置的配置名称。admin ui cloud->tree->configs节点列出了所有可用的配置集。

Example: -n myconfig

-d <configset dir>

将下载的配置集写入的路径。如果只提供一个名称,$solr_home/server/solr/configsets将是父级。也可以提供绝对路径。在这两种情况下,目标上预先存在的配置都将被覆盖!

Examples:

  • -d directory_under_configsets
  • -d /path/to/configset/destination

-z <zkHost>

zoomkeepr连接字符串。如果zk_主机在solr.in.sh或solr.in.cmd中定义,则不需要。

Example: -z 123.321.23.43:2181

An example of this command with all parameters is:

bin/solr zk downconfig -z 111.222.333.444:2181 -n mynewconfig -d /path/to/configset

“最佳实践”是将配置集以某种形式的版本控制保存为记录系统。在这种情况下,不应该使用downconfig。

  • 在本地文件和zoom keeper znodes之间复制

使用zk cp命令在ZooKeeper znodes和本地驱动器之间传输文件和目录。此命令将从本地驱动器复制到ZooKeeper ,从ZooKeeper 到本地驱动器,或从ZooKeeper 复制到ZooKeeper 。

ZK Copy Parameters

-r

可选的。执行递归复制。除非指定了“-r”,否则如果<src>具有子级,则该命令将失败。

Example: -r

<src>

要从中复制的文件或路径。如果前缀为zk:则假定源为zookeeper。如果没有前缀或前缀是'file:'这是本地驱动器。必须至少在<src>或<dest>前面加上'zk'前缀,否则命令将失败。

Examples:

  • zk:/configs/myconfigs/solrconfig.xml
  • file:/Users/apache/configs/src

<dest>

要复制到的文件或路径。如果前缀为zk:则假定源为zookeeper。如果没有前缀或前缀是文件:这是本地驱动器。

必须在<src>或<dest>中至少有一个前面加上zk:否则命令将失败。如果<dest>以Examples:

  • zk:/configs/myconfigs/solrconfig.xml
  • file:/Users/apache/configs/src

斜杠字符结尾,则命名目录。

-z <zkHost>

zoomkeepr连接字符串。如果zk_主机在solr.in.sh或solr.in.cmd中定义,则不需要。

Example: -z 123.321.23.43:2181

An example of this command with the parameters is:

Recursively copy a directory from local to ZooKeeper.

bin/solr zk cp -r file:/apache/confgs/whatever/conf zk:/configs/myconf -z 111.222.333.444:2181

Copy a single file from ZooKeeper to local.

bin/solr zk cp zk:/configs/myconf/managed_schema /configs/myconf/managed_schema -z 111.222.333.444:2181

  • Remove a znode from ZooKeeper

Use the zk rm command to remove a znode (and optionally all child nodes) from ZooKeeper.

ZK Remove Parameters

-r

Optional. Do a recursive removal. The command will fail if the <path> has children unless '-r' is specified.

Example: -r

<path>

The path to remove from ZooKeeper, either a parent or leaf node.

There are limited safety checks, you cannot remove '/' or '/zookeeper' nodes.

The path is assumed to be a ZooKeeper node, no zk: prefix is necessary.

Examples:

  • /configs
  • /configs/myconfigset
  • /configs/myconfigset/solrconfig.xml

-z <zkHost>

zoomkeepr连接字符串。如果zk_主机在solr.in.sh或solr.in.cmd中定义,则不需要。

Example: -z 123.321.23.43:2181

Examples of this command with the parameters are:

bin/solr zk rm -r /configs

bin/solr zk rm /configs/myconfigset/schema.xml

  • Move One ZooKeeper znode to Another (Rename)

使用zk mv命令移动(重命名)ZooKeeper znode。

ZK Move Parameters

<src>

The znode to rename. The zk: prefix is assumed.

Example: /configs/oldconfigset

<dest>

The new name of the znode. The zk: prefix is assumed.

Example: /configs/newconfigset

-z <zkHost>

The ZooKeeper connection string. Unnecessary if ZK_HOST is defined in solr.in.sh or solr.in.cmd.

Example: -z 123.321.23.43:2181

An example of this command is:

bin/solr zk mv /configs/oldconfigset /configs/newconfigset

  • List a ZooKeeper znode’s Children

Use the zk ls command to see the children of a znode.

ZK List Parameters

-r Optional. Recursively list all descendants of a znode.

Example: -r

<path>

The path on ZooKeeper to list.

Example: /collections/mycollection

-z <zkHost>

The ZooKeeper connection string. Unnecessary if ZK_HOST is defined in solr.in.sh or solr.in.cmd.

Example: -z 123.321.23.43:2181

An example of this command with the parameters is:

bin/solr zk ls -r /collections/mycollection

bin/solr zk ls /collections

  • Create a znode (supports chroot)

使用zk mkroot命令创建znode。这个命令的主要用例支持ZooKeeper的“chroot”概念。但是,它也可以用于创建任意路径

Create znode Parameters

<path>

The path on ZooKeeper to create. Intermediate znodes will be created if necessary. A leading slash is assumed even if not specified.

Example: /solr

-z <zkHost>

The ZooKeeper connection string. Unnecessary if ZK_HOST is defined in solr.in.sh or solr.in.cmd.

Example: -z 123.321.23.43:2181

Examples of this command:

bin/solr zk mkroot /solr -z 123.321.23.43:2181

bin/solr zk mkroot /solr/production

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章