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

Importing and Exporting Hive Databases

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

Scenario

In big data application scenarios, Hive databases and all tables in these databases are usually migrated to another cluster. You can run the Hive database export and import commands to migrate a complete database.

NOTE:

The Hive database import and export function does not support encrypted tables, HBase external tables, Hudi tables, view tables, or materialized view tables.

Prerequisites

  • If Hive databases are imported or exported across clusters and Kerberos authentication is enabled for both the source and destination clusters, configure cross-cluster mutual trust.
  • If you want to run the dump or load command to import or export databases created by other users, grant the corresponding database permission to the users.
    • If Ranger authentication is not enabled for the cluster, log in to FusionInsight Manager to grant the administrator rights of the role to which the user belongs. For details, see section Creating a Hive Role.
    • If Ranger authentication is enabled for the cluster, grant users the permission to dump and load databases. For details, see Adding a Ranger Access Permission Policy for Hive.
  • Enable the inter-cluster copy function in the source cluster and destination cluster.
  • Configure the HDFS service address parameter for the source cluster to access the destination cluster.

    Log in to FusionInsight Manager of the source cluster, choose Cluster > Services > Hive, and click Configurations. On the page that is displayed, search for hdfs.site.customized.configs, add custom parameter dfs.namenode.rpc-address.haclusterX, and set it to Service IP address of the active NameNode node in the target cluster:RPC port. Add custom parameter dfs.namenode.rpc-address.haclusterX1 and set it to Service IP address of the standby NameNode node in the target cluster:RPC port. The RPC port of NameNode is 25000 by default. After saving the configuration, roll-restart the Hive service.

Procedure

  1. Log in to the node where the client is installed in the source cluster as the Hive client installation user.
  2. Run the following command to switch to the client installation directory, for example, /opt/client:

    cd /opt/client

  3. Run the following command to configure environment variables:

    source bigdata_env

  4. If Kerberos authentication is enabled for the cluster, run the following command to authenticate the user. Otherwise, skip this step.

    kinit Hive service user

  5. Run the following command to log in to the Hive client:

    beeline

  6. Run the following command to create the dump_db database:

    create database dump_db;

  7. Run the following command to switch to the dump_db database:

    use dump_db;

  8. Run the following command to create the test table in the dump_db database:

    create table test(id int);

  9. Run the following command to insert data to the test table:

    insert into test values(123);

  10. Run the following command to set the dump_db database as the source of the replication policy:

    alter database dump_db set dbproperties ('repl.source.for'='replpolicy1');

    NOTE:
    • You must have related permissions on the database when running the alter command to modify database attributes. To configure permissions, perform the following operations:
      • If Ranger authentication is not enabled for the cluster, log in to FusionInsight Manager to grant the administrator rights of the role to which the user belongs. For details, see section Creating a Hive Role.
      • If Ranger authentication is enabled for the cluster, grant users the permission to dump and load databases. For details, see Adding a Ranger Access Permission Policy for Hive.
    • Databases with replication policy sources configured can be deleted only after their replication policy sources are set to null. To do so, run the following command:

      alter database dump_db set dbproperties ('repl.source.for'='');

  11. Run the following command to export the dump_db database to the /user/hive/test directory of the destination cluster:

    repl dump dump_db with ('hive.repl.rootdir'='hdfs://haclusterX/user/hive/test');

    The following is an example.

    NOTE:
    • hacluster X is the value of haclusterX in new custom parameterdfs.namenode.rpc-address.haclusterX.
    • Ensure that the current user has the read and write permissions on the export directory to be specified.

  12. Log in to the node where the client is installed in the destination cluster as the Hive client installation user, and perform 2 to 5.
  13. Run the following command to import data from the dump_db database in the /user/hive/test directory to the load_db database:

    repl load load_db from 'hdfs://haclusterX/user/hive/test/XXX';

    NOTE:
    • Replace hdfs://haclusterX/user/hive/test/XXX with the specific path in the dump_dir column in 11.
    • When the repl load command is used to import a database, pay attention to the following points when specifying the database name:
      • If the specified database does not exist, the database will be created during the import.
      • If the specified database exists and the value of hive.repl.ckpt.key of the database is the same as the imported path, skip the import operation.
      • If the specified database already exists and no table or function exists in this database, only the tables in the source database are imported to the current database during the import. Otherwise, the import fails.

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