Configuring a Quota for a Znode

Scenario

Set a quota for Znodes in ZooKeeper of a security cluster in O&M scenarios or service scenarios to restrict the quantity and byte space of Znodes and subnodes.

Two modes are available:

  • On Manager, enable the automatic quota setting function and set related configuration items to enable the ZooKeeper service to automatically set the Znode quota. For details, see 1 to 8.

  • On Manager, disable the automatic quota setting function and run commands on the client to manually set the Znode quota. For details, see 1 to 3.

Impact on the System

If the configured quantity or capacity quota is less than the quantity or capacity of directories required for normal service running, services may fail to run properly. Exercise cautions when setting the quota.

Prerequisites

The ZooKeeper client has been installed in a directory, for example, /opt/client.

Procedure

Use the automatic quota setting function.

  1. Go to the All Configurations page of ZooKeeper. Click the Quota tab and set quotas.auto.check.enable to true, and click Save. For details, see Modifying Cluster Service Configuration Parameters.

  2. Determine whether to set the quota of the top directory (for example, Yarn service) on ZooKeeper.

    • If yes, go to 3.

    • If no, go to 5.

  3. Go to the All Configurations page of Yarn by referring to Modifying Cluster Service Configuration Parameters and search for zk.quota.

  4. Set the following quotas properly and click Save. The ZooKeeper service periodically sets the quota of the Yarn service on the top directory of ZooKeeper.

    1. zk.quota.number indicates the directory quota of the service on ZooKeeper.

    2. zk.quota.bytes indicates the capacity quota of the service directory on ZooKeeper.

    Note

    If the configured quantity or capacity quota is less than the actual quantity or capacity quota of the current directory, the setting can be saved successfully. However, an alarm indicating that the setting is invalid is displayed on the page, prompting you to reset the quota.

    If the configured quantity or capacity quota is less than the quantity or capacity of directories required for normal service running, services may fail to run properly. Exercise cautions when setting the quota.

  5. Check whether quotas of other custom top directories except service directories need to be configured.

    • If yes, go to 6.

    • If no, no further action is required.

  6. Go to the All Configurations page of ZooKeeper and click the Quota tab.

  7. Enter the top directory (for example, /abc) of ZooKeeper in the Value text box of customized.quota.

  8. In the Value text box, enter the quantity quota and capacity quota separated by a comma (,). (You can also set only the quantity quota). If you need to set quotas for multiple top directories, click + to add quotas. Click Save. The ZooKeeper service automatically sets the quota of the top directory periodically. No further action is required.

    Note

    The entered quantity quota cannot be greater than the value of max.znode.count. The entered capacity quota cannot be greater than the value of max.data.size.

    If the top directory on ZooKeeper is not the top directory of a service, and its quota is not specified using customized.quota, the ZooKeeper service sets the quota to the value of defaultQuota.

Run commands on the client.

  1. Go to the All Configurations page of ZooKeeper. Click the Quota tab and set quotas.auto.check.enable to false, and click Save.

  2. Start the ZooKeeper client. For details, see Using a ZooKeeper Client.

    Note

    In security mode, user authentication is required to start the ZooKeeper client. The ZooKeeper user (system administrator of ZooKeeper) is used for authentication, and the kinit zookeeper command is executed.

  3. Run the setquota /znode -n number -b byte command.

    • znode indicates the node for which you want to set a quota.

    • number indicates the maximum number of nodes and subnodes.

    • byte indicates the maximum byte space for the node and subnodes.