Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Configuring the ZooKeeper Permissions

Updated on 2023-04-28 GMT+08:00

Scenario

Configure znode permission of ZooKeeper.

ZooKeeper uses an access control list (ACL) to implement znode access control. The ZooKeeper client specifies a znode ACL, and the ZooKeeper server determines whether a client that requests for a znode has related operation permission according to the ACL. ACL configuration involves the following four operations:

  • Check znode ACLs in ZooKeeper.
  • Add znode ACLs to ZooKeeper.
  • Modify znode ACLs in ZooKeeper.
  • Delete znode ACLs from ZooKeeper.

    The ZooKeeper ACL permission is described as follows:

    ZooKeeper supports five types of permission, create, delete, read, write, and admin. ZooKeeper permission control is of a znode level. That is, the permission configuration for a parent znode is not inherited by its child znodes. The ZooKeeper znode default permission is world:anyone: cdrwa. That is, any user has all permissions.

NOTE:

ACL has three parts:

The first part is the authentication type. For example, world indicates all authentication types and sasl indicates the kerberos authentication type.

The second part is the account. For example, anyone indicates any user.

The third part is permission. For example, cdrwa indicates all permissions.

In particular, because starting the client in common mode does not need authentication, ACL with sasl authentication type cannot be used in common mode. Authentications of sasl scheme in this document are performed in clusters that have the security mode enabled.

Table 1 Five types of ZooKeeper ACLs

Permission Description

Permission Name

Permission Details

Create permission

create(c)

Users with this permission can create child znodes in the current znode.

Delete permission

delete(d)

Users with this permission can delete the current znode.

Read permission

read(r)

Users with this permission can obtain data of the current znode and list all the child znodes of the current znode.

Write permission

write(w)

Users with this permission can write data to the current znode and its child znodes.

Administration permission

admin(a)

Users with this permission can set permission for the current znode.

Impact on the System

NOTICE:

Modifying ZooKeeper ACLs is a critical operation. If znode permission is modified in ZooKeeper, other users may have no permission to access the znode and some system functions are abnormal. In 3.5.6 and later versions, users must have the read permission for the getAcl operation.

Prerequisites

  • The ZooKeeper client has been installed in a directory, for example, /opt/client.
  • You have obtained the username and password of an MRS cluster administrator.

Procedure

Start the ZooKeeper client.

  1. Log in to the server where the ZooKeeper client is installed as user root.
  2. Run the following command to go to the client installation directory:

    cd /opt/client

  3. Run the following command to configure environment variables:

    source bigdata_env

  4. Run the following command and enter the user password to authenticate the user's identity (This step is required only for clusters in security mode, and user userA is provided as an example of an authorized user.):

    kinit userA

  5. On the ZooKeeper client, run the following command to go to the ZooKeeper command-line interface (CLI):

    sh zkCli.sh -server ZooKeeper plane IP address of any instance:clientPort

    The default clientPort is 2181.

    Example: sh zkCli.sh -server 192.168.0.151:2181

  6. Run the ls command to view the znode list in ZooKeeper. For example, you can view the list of znodes in the root directory.

    ls /

    [zk: 192.168.0.151:2181(CONNECTED) 1] ls /
    [hadoop-flag, hadoop-ha, test, test2, test3, test4, test5, test6, zookeeper]

View the ZooKeeper znode ACL.

  1. Start the ZooKeeper client.
  2. Run the getAcl command to view znodes. The following command can be used to view the created znode ACL named test:

    getAcl /znode name

    [zk: 192.168.0.151:2181(CONNECTED) 2] getAcl /test
    'world,'anyone
    : cdrwa

Add a ZooKeeper znode ACL.

  1. Start the ZooKeeper client.
  2. View the old ACL information to check whether the current account has the permission to modify the znode ACL information (a permission). If no, use kinit to switch to a user that has the permission and restart the ZooKeeper client.

    getAcl /znode name
     [zk: 192.168.0.151:2181(CONNECTED) 3] getAcl /test
    'world,'anyone
    : cdrwa

  3. Run the setAcl command to add an ACL. The command for adding an ACL is as follows:

    setAcl /test world:anyone:cdrwa,sasl: username@: <system domain name>:ACL value

    For example, to create the ACL of user admin to the test znode, run the following command:

    setAcl /test world:anyone:cdrwa,sasl:userA@HADOOP.COM:cdrwa

    NOTE:

    When adding a new ACL, reserve the existing ones. The new and old ACLs are separated by a comma. The newly added ACL has three parts:

    • The first part is the authentication type. For example, sasl indicates kerberos authentication.
    • The second part is the account. For example, userA@HADOOP.COM indicates user userA.
    • The third part is permission. For example, cdrwa indicates all permissions.

  4. After adding the ACL, run the getAcl command to check whether the permission is added successfully:

    getAcl /znode name

    [zk: 192.168.0.151:2181(CONNECTED) 4] getAcl /test 
    'world,'anyone
    : cdrwa
    'sasl,'userA@<System domain name>
    : cdrwa

Modify the ZooKeeper znode ACL.

  1. Start the ZooKeeper client.
  2. View the old ACL information to check whether the current account has the permission to modify the znode ACL information (a permission). If no, use kinit to switch to a user that has the permission and restart the ZooKeeper client.

    getAcl /znode name

    [zk: 192.168.0.151:2181(CONNECTED) 5] getAcl /test 
    'world,'anyone
    : cdrwa
    'sasl,'userA@<System domain name>
    : cdrwa

  3. Run the setAcl command to modify an ACL. The command for adding an ACL is as follows:

    setAcl /test sasl:Username@<System domain name>:ACL value

    For example, to reserve all permissions of user userA and delete the rw permission of user anyone, run the following command:

    setAcl /test sasl:userA@HADOOP.COM:cdrwa

  4. After modifying the ACL, run the getAcl command to check whether the permission is modified successfully:

    getAcl /znode name

    [zk: 192.168.0.151:2181(CONNECTED) 6] getAcl /test 
    'sasl,'userA@<System domain name>
    : cdrwa

Delete the ZooKeeper znode ACL.

  1. Start the ZooKeeper client.
  2. View the old ACL information to check whether the current account has the permission to modify the znode ACL information (a permission). If no, use kinit to switch to a user that has the permission and restart the ZooKeeper client.

    getAcl /znode name

    [zk: 192.168.0.151:2181(CONNECTED) 5] getAcl /test 
    'world,'anyone
    : rw
    'sasl,'userA@<System domain name>
    : cdrwa

  3. Run the setAcl command to add an ACL. The command for adding an ACL is as follows:

    setAcl /test sasl:Username@<System domain name>:ACL value

    For example, to reserve all permissions of user userA and delete the rw permission of user anyone, run the following command:

    setAcl /test sasl:userA@HADOOP.COM:cdrwa

  4. After modifying the ACL, run the getAcl command to check whether the permission is modified successfully:

    getAcl /znode name

    [zk: 192.168.0.151:2181(CONNECTED) 6] getAcl /test
    'sasl,'userA@<System domain name>
    : cdrwa

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback