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
Situation Awareness
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

Show all

Help Center/ MapReduce Service/ Best Practices/ Interconnection with Ecosystem Components/ Interconnecting Hive with External Self-Built Relational Databases

Interconnecting Hive with External Self-Built Relational Databases

Updated on 2024-08-12 GMT+08:00
NOTE:
  • This section applies to MRS 3.x or later.
  • This section describes how to connect Hive with built-in relational databases open-source MySQL and Postgres.
  • After an external metadata database is deployed in a cluster with Hive data, the original metadata tables will not be automatically synchronized. Before installing Hive, determine whether to store metadata in an external database or DBService. For the former, deploy an external database when installing Hive or when there is no Hive data. After Hive installation, the metadata storage location cannot be changed. Otherwise, the original metadata will be lost.
  • After external metadata is imported to the MySQL database, Hive supports only table names, field names, and table description in Chinese.

Hive supports access to open source MySQL and Postgres metabases.

  1. Install the open source MySQL or Postgres database.

    NOTE:

    The node where the database is installed must be in the same network segment as the cluster, so that they can access each other.

  2. Upload the driver package.

    • PostgreSQL:

      Use the open source driver package to replace the cluster's existing one. Download the open source PostgreSQL driver package postgresql-42.2.5.jar at https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.5/ and upload it to the ${BIGDATA_HOME}/third_lib/Hive directory on all MetaStore nodes.

      Run the following commands on all MetaStore nodes to modify the permission on the driver package:

      cd ${BIGDATA_HOME}/third_lib/Hive

      chown omm:wheel postgresql-42.2.5.jar

      chmod 600 postgresql-42.2.5.jar

    • MySQL:

      Visit the MySQL official website at https://www.mysql.com/, choose DOWNLOADS > MySQL Community(GPL) DownLoads > Connector/J, and download the driver package of the required version.

      • For versions earlier than MRS 8.2.0, upload the MySQL driver package of the required version to the /opt/Bigdata/FusionInsight_HD_*/install/FusionInsight-Hive-*/hive-*/lib/ directory on all Metastore nodes.
      • For MRS 8.2.0 and later versions, upload the MySQL driver package of the required version to the ${BIGDATA_HOME}/third_lib/Hive directory on all Metastore nodes.

      Run the following commands on all MetaStore nodes to modify the permission on the driver package:

      cd /opt/Bigdata/FusionInsight_HD_*/install/FusionInsight-Hive-*/hive-*/lib/

      chown omm:wheel mysql-connector-java-*.jar

      chmod 600 mysql-connector-java-*.jar

  3. Create a user and metadata database in the self-built database and assign all permissions on the database to the user. For example:

    • Run the following commands as the database administrator in PostgreSQL to create database test and user testuser, and assign all permissions on test to testuser:

      create user testuser with password 'password';

      create database test owner testuser;

      grant all privileges on database test to testuser;

    • Run the following commands as the database administrator in MySQL to create database test and user testuser, and assign all permissions on test to testuser:

      create database test;

      create user 'testuser'@'%' identified by 'password';

      grant all privileges on test.* to 'testuser';

      flush privileges;

  4. Import the SQL statements for creating metadata tables.

    • SQL script path in the PostgreSQL database: ${BIGDATA_HOME}/FusionInsight_HD_*/install/FusionInsight-Hive-*/hive-*/scripts/metastore/upgrade/postgres/hive-schema-3.1.0.postgres.sql

      Run the following command to import the SQL file to Postgres:

      ./bin/psql -U username -d databasename -f hive-schema-3.1.0.postgres.sql

      ./bin/psql is in the Postgres installation directory.

      username indicates the username for logging in to Postgres.

      databasename indicates the database name.

    • SQL script path in the MySQL database: ${BIGDATA_HOME}/FusionInsight_HD_*/install/FusionInsight-Hive-*/hive-*/scripts/metastore/upgrade/mysql/hive-schema-3.1.0.mysql.sql

      Run the following command to import the SQL file to the MySQL database:

      ./bin/mysql -u username -p -D databasename<hive-schema-3.1.0.mysql.sql

      ./bin/mysql is in the MySQL installation directory.

      username indicates the user name for logging in to MySQL.

      databasename indicates the database name.

  5. Log in to FusionInsight Manager, choose Cluster > Services, and click Hive. On the displayed page, click Configuration > All Configurations, and choose Hive (Service) > MetaDB. Modify the parameters described in Table1 Parameters, and save the modification so that the Hive configuration can be connected to the open-source database.

    Table 1 Parameters

    Parameter

    Default value

    Description

    javax.jdo.option.ConnectionDriverName

    org.postgresql.Driver

    Driver class for connecting metadata on MetaStore

    • If an external MySQL database is used, the value is:

      com.mysql.jdbc.Driver

    • If an external Postgres database is used, the value is:

      org.postgresql.Driver

    javax.jdo.option.ConnectionURL

    jdbc:postgresql://%{DBSERVICE_FLOAT_IP}%{DBServer}:%{DBSERVICE_CPORT}/hivemeta?socketTimeout=60

    URL of the JDBC link of the MetaStore metadata

    • If an external MySQL database is used, the value is:

      jdbc:mysql://IP address of the MySQL database:Port number of the MySQL database/test?characterEncoding=utf-8

    • If an external Postgres database is used, the value is:

      jdbc:postgresql://IP address of the PostgreSQL database:Port number of the PostgreSQL database/test

    NOTE:

    test is the name of the database created in MySQL or PostgreSQL in 3.

    javax.jdo.option.ConnectionUserName

    hive${SERVICE_INDEX}${SERVICE_INDEX}

    Username for connecting to the metadata database on Metastore

  6. Change the Postgres database password in MetaStore. Choose Cluster > Name of the desired cluster > Services > Hive. On the displayed page, click Configurations > All Configurations and choose MetaStore(Role) > MetaDB, modify the following parameters, and click Save.

    Table 2 Parameters

    Parameter

    Default value

    Description

    javax.jdo.option.extend.ConnectionPassword

    ******

    User password for connecting to the external metadata database on Metastore. The password is encrypted in the background.

  7. Log in to each MetaStore background node and check whether the local directory /opt/Bigdata/tmp exists.

    • If it exists, go to 8.
    • If it is not, run the following commands to create one:

      mkdir -p /opt/Bigdata/tmp

      chmod 755 /opt/Bigdata/tmp

  8. Save the configuration. Choose Dashboard > More > Restart Service, and enter the password to restart the Hive service.
  9. Log in to the MySQL or PostgreSQL database and view metadata tables generated in the metadata database created in 3.

  10. Check whether the metadata database is successfully deployed.

    1. Log in to the node where the Hive client is installed as the client installation user.

      cd Client installation directory

      source bigdata_env

      kinit Component service user (Skip this step for clusters with Kerberos authentication disabled.)

    2. Run the following command to log in to the Hive client CLI:

      beeline

    3. Run the following command to create the test table:

      create table test(id int,str1 string,str2 string);

    4. Run the following command in the test database of the MySQL or PostgreSQL database to check whether there is any information about the test table:

      select * from TBLS;

      If information about the test table is displayed, the external database is successfully deployed. For example:

      • The result in the MySQL database is as follows:

      • The result in the PostgreSQL database is as follows:

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