El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

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
On this page

Kafka Encryption and Decryption

Updated on 2024-11-29 GMT+08:00

Scenario

After a RangerKMS instance is installed for Ranger in an MRS cluster, the encryption and decryption feature is available for Kafka. You can create encrypted Kafka topics. The client automatically encrypts data and transmits it to the Kafka service. The encrypted data is stored on a local disk. The client application reads the encrypted data from the server and automatically decrypts the data on the client.

Prerequisites

  • The Ranger service and RangerKMS instance have been installed in the cluster.
  • To use this function, the Kafka client JAR package of MRS is required. The open-source client is not available for this function.

Procedure

  1. Assign key permissions to users of different roles by referring to Using the RangerKMS Native UI to Manage Permissions and Keys. The following table lists the required permission.

    Table 1 Key permission

    Task

    Required Key Permission

    Creating a topic

    • Get Metadata: Get the metadata of a key.
    • Generate EEK: Generate an EEK.

    Producing data

    • Decrypt EEK: Decrypt an EEK.

    Consuming data

    • Decrypt EEK: Decrypt an EEK.

  2. Log in to the node where the Kafka client is installed as the client installation user and run the following commands to configure environment variables and pass user authentication:

    cd Kafka client installation path

    source bigdata_env

    kinit Component service user

  3. Add a configuration item to the Kafka client configuration file to enable the encryption and decryption feature.

    cd Kafka/kafka/config

    Add the following parameters to the client.properties, producer.properties, and consumer.properties files respectively and save the changes:
    encryption.keyprovider.class = org.apache.kafka.clients.encryption.RangerKeyProvider
    encryption.keymanager.class = org.apache.kafka.clients.encryption.RangerKeyManager
    encryption.keyprovider.rangerkms = https://IP address of the RangerKMS instance:Port number,https://IP address of the RangerKMS instance:Port number
    NOTICE:
    • With the preceding configurations, the producer writes encrypted data to the encrypted topic by default.
    • Without the preceding configurations, the producer writes plaintext data to the encrypted topic by default.
    • With the preceding configurations, the consumer decrypts the encrypted data in the encrypted topic by default.
    • If the preceding configurations are added for the consumer and a plaintext topic is subscribed, the plaintext data will be decrypted into garbled characters.
    • Without the preceding configurations, the consumer does not decrypt the encrypted data in the encrypted topic.
    • To obtain the IP address of the RangerKMS instance, log in to FusionInsight Manager, choose Cluster > Services > Ranger > Instances, and view and record the service IP address.
    • To obtain the port, log in to FusionInsight Manager, choose Cluster > Services > Ranger, and click Configurations > All Configurations. Search for ranger.service.https.port, and view and record the value for the RangerKMS instance.

  4. (Optional) Set the following parameters on the client as you need.

    Parameter

    Description

    Default Value

    kms.request.retries

    Number of retries allowed to access the RangerKMS instance

    2

    encryption.keyprovider.rangerkms.hostname

    IP address and host name of the RangerKMS instance, for example, ip|hostname,ip2|hostanme2

    null

    ranger.eek.cache.size

    Number of tables for caching keys

    1000

    ranger.eek.max.age.second

    Expiration time of cached keys, in seconds

    300

  5. Run the following command to switch to the client directory, for example, /opt/client/Kafka/kafka/bin.

    cd Kafka client installation directory/Kafka/kafka/bin

  6. Create a topic.

    When you run the client script to create a topic, use --bootstrap-server. The --zookeeper command is not supported.

    kafka-topics.sh --create --topic Topic name --partitions 1 --replication-factor 3 --bootstrap-server Broker IP address:port--command-config ../config/client.properties --config encryption.keyname=Key name

    NOTE:
    • To obtain the IP address of the Broker, log in to FusionInsight Manager, choose Cluster > Services > Kafka > Instances, and view and record the service IP address.
    • The port number of the Kafka cluster is defaulted to 21007 in security mode and 21005 in normal mode.
    • Key name: name of the key used in 1

  7. Write data to the encrypted topic.

    Run the client script command to write data to the encrypted topic:

    sh kafka-console-producer.sh --broker-list Broker IP address:Port --topic Topic name--producer.config ../config/producer.properties

  8. Read encrypted topic data.

    sh kafka-console-consumer.sh --topic Topic name--bootstrap-server Broker IP address:Port --consumer.config ../config/consumer.properties

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback