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
Help Center/ MapReduce Service/ Developer Guide (Normal_3.x)/ HBase Development Guide (Security Mode)/ Environment Preparation/ Preparing for Security Authentication/ HBase Service Data Read/Write Example Security Authentication (Multi-Cluster Mutual Trust Scenario)

HBase Service Data Read/Write Example Security Authentication (Multi-Cluster Mutual Trust Scenario)

Updated on 2023-08-31 GMT+08:00

Description

When multiple clusters in different security modes need to access each other's resources, the administrator can set up a mutual trust system so that users of external systems can use the system. The usage range of users in each system is called a domain. Each Manager system must have a unique domain name. Cross-Manager access means users to be used across domains. For details about how to configure mutual trust between clusters, see Managing Mutual Trust Relationships Between Managers.

As a user that meets the cross-domain access requirements, you can use the keytab and principal files for Kerberos security authentication obtained from one Manager system and the client configuration files of multiple Manager systems to access and invoke the HBase service of multiple clusters after one authentication login in the multi-cluster mutual trust scenario.

The following code snippets belong to the TestMultipleLogin class in the com.huawei.bigdata.hbase.examples package of the hbase-example sample project.

  • Code authentication
    List<String> confDirectorys = new ArrayList<>(); 
             List<Configuration> confs = new LinkedList<>(); 
             try { 
                 // conf directory 
                 confDirectorys.add("hadoopDomain");[1] 
                 confDirectorys.add("hadoop1Domain");[2] 
       
                 for (String confDir : confDirectorys) { 
                     confs.add(init(confDir));[3] 
                 } 
       
                 login(confs.get(0), confDirectorys.get(0));[4] 
             } catch (IOException e) { 
                 LOG.error("Failed to login because ", e); 
                 return; 
             }

    [1] hadoopDomain indicates the name of the directory for storing user credentials and the configuration file of a cluster. The relative path of the directory is hbase-example/src/main/resources/hadoopDomain, which can be changed as required.

    [2] hadoop1Domain is the name of the directory for storing the configuration file of the other cluster. The relative path of the directory is hbase-example/src/main/resources/hadoop1Domain, which can be changed as required.

    [3] Initialize the conf objects in sequence.

    [4] Perform login authentication.

  • Initialization configuration
    private static Configuration init(String confDirectoryName) throws IOException {
            // Default load from conf directory
            Configuration conf = HBaseConfiguration.create();
            //In Windows environment
            String userdir = TestMain.class.getClassLoader().getResource(confDirectoryName).getPath() + File.separator;
            //In Linux environment
            //String userdir = System.getProperty("user.dir") + File.separator + confDirectoryName + File.separator;
            conf.addResource(new Path(userdir + "core-site.xml"), false);
            conf.addResource(new Path(userdir + "hdfs-site.xml"), false);
            conf.addResource(new Path(userdir + "hbase-site.xml"), false);
            return conf;
    }

Prerequisites

You have obtained the configuration file and authentication file required for running the sample project. For details, see Preparing the Configuration Files of the Running Environment.

Configuring Secure Login

Change userName in the TestMultipleLogin class in the com.huawei.bigdata.hbase.examples package of the hbase-example sample project to the actual user name, for example, developuser.
private static void login(Configuration conf, String confDir) throwsIOException {      

        if (User.isHBaseSecurityEnabled(conf)) {
           userName = " developuser ";

           //In Windows environment
           String userdir = TestMain.class.getClassLoader().getResource(confDir).getPath() + File.separator;
           //In Linux environment
           //String userdir = System.getProperty("user.dir") + File.separator + confDir + File.separator;

           userKeytabFile = userdir + "user.keytab";
           krb5File = userdir + "krb5.conf";

           /*  

            * if need to connect zk, please provide jaas info about zk. of course,
            * you can do it as below:
            * System.setProperty("java.security.auth.login.config",confDirPath +
            * "jaas.conf"); but the demo can help you more : Note: if this process
            * will connect more than one zk cluster, the demo may be not proper. you
            * can contact us for more help
            */

            LoginUtil.setJaasConf(ZOOKEEPER_DEFAULT_LOGIN_CONTEXT_NAME, userName,userKeytabFile);
            LoginUtil.login(userName, userKeytabFile, krb5File, conf);
        }
}

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