Extracting metadata from Apache Hive for migration
You can use the Google Cloud CLI to extract the necessary metadata before running an Apache Hive data or permissions migration.
This document covers metadata extraction from the following data sources:
- Apache Hive
- Apache Hadoop Distributed File System (HDFS)
- Apache Ranger
- Cloudera Manager
- Apache Hive query logs
Before you begin
Before you extract metadata, do the following:
Install Java
To run extraction commands on your local machine (--run-mode=local), install
Java 11 or later and add it to your PATH. We recommend that you use the
latest version of Java, which you can download and install from
Java downloads.
Required roles
The user account that you specify for connecting to the source system must have
permissions to read metadata from that system. Confirm that this account has
appropriate role membership to query the metadata resources available for your
platform. For example, INFORMATION_SCHEMA is a metadata resource that's
common across several platforms.
When writing output to a Cloud Storage bucket
(gs://BUCKET/PATH) in local mode
(--run-mode=local), the bucket must belong to your project (or the
--expected-owner project, if specified) and must prohibit public access. Grant
your account the following Cloud Storage roles:
- Storage Bucket Viewer
(
roles/storage.bucketViewer) on the project (or--expected-ownerproject) - Storage Object User
(
roles/storage.objectUser) on the bucket (or Storage Object Creator,roles/storage.objectCreator, when writing only to a new object path) - Storage Admin
(
roles/storage.admin) on the bucket unless public access prevention is enforced on the bucket
Set up metadata extraction
To set up the Google Cloud CLI for metadata and query log extraction, do the following:
Install and initialize the gcloud CLI.
When running in local mode (
--run-mode=local), the gcloud CLI automatically prompts you to install thebqmscomponent on first use if it isn't already installed. To pre-install the component—which is required if you run extraction commands in an automated environment—rungcloud components install bqms. If you installed the gcloud CLI using an OS package manager such asapt,dnf, oryum, install thegoogle-cloud-cli-bqmspackage instead.To write output directly to Cloud Storage (
--output=gs://BUCKET/PATH) when running in local mode (--run-mode=local), configure Application Default Credentials:gcloud auth application-default login
Extracting metadata for migration
Select one of the following options to learn how to extract metadata for your data source:
Apache Hive
In the Apache Hive tab, follow the steps in Extract metadata and query logs to extract and write your Apache Hive metadata to the Cloud Storage bucket containing your migration files.
HDFS
Run the following command to extract metadata from HDFS using the migration extractor tool.
gcloud alpha bq migration metadata extract \
--connector=hdfs \
--output=gs://MIGRATION_BUCKET/hdfs-dumper-output.zip \
-- \
--host HDFS_HOST \
--port HDFS_PORT \
--assessment
Replace the following:
MIGRATION_BUCKET: the Cloud Storage bucket that you're using to store the migration files.HDFS_HOST: the HDFS NameNode hostname.HDFS_PORT: the HDFS NameNode port number. You can skip this argument if you're using the default8020port.
This command extracts metadata from HDFS to a file named
hdfs-dumper-output.zip in the MIGRATION_BUCKET
bucket.
There are several known limitations when extracting metadata from HDFS:
- Some tasks in this connector are optional and can fail, logging a full
stack trace in the output. As long as the required tasks have
succeeded and
hdfs-dumper-output.zipis generated, you can proceed with the HDFS migration. - The extraction process might fail or run slower than expected if the
configured thread pool size is too large. If you are encountering these
issues, we recommend decreasing the thread pool size using the command
line argument
--thread-pool-size.
Apache Ranger
Run the following command to extract metadata from Apache Ranger using the migration extractor tool.
gcloud alpha bq migration metadata extract \
--connector=ranger \
--output=gs://MIGRATION_BUCKET/ranger-dumper-output.zip \
-- \
--host RANGER_HOST \
--port 6080 \
--user RANGER_USER \
--password RANGER_PASSWORD \
--ranger-scheme RANGER_SCHEME \
--assessment
Replace the following:
MIGRATION_BUCKET: the Cloud Storage bucket that you're using to store the migration files.RANGER_HOST: the hostname of the Apache Ranger instance.RANGER_USER: the username of the Apache Ranger user.RANGER_PASSWORD: the password of the Apache Ranger user.RANGER_SCHEME: specify whether Apache Ranger useshttporhttps. Default value ishttp.
You can also include the following optional flags:
--kerberos-auth-for-hadoop: replaces--userand--password, if Apache Ranger is protected by kerberos instead of basic authentication. You must run thekinitcommand before the migration extractor tool to use this flag.--ranger-disable-tls-validation: include this flag if the https certificate used by the API is self signed. For example, when using Cloudera.
This command extracts metadata from Apache Ranger to a file named
ranger-dumper-output.zip in the
MIGRATION_BUCKET bucket.
Cloudera
Run the following command to extract metadata from Cloudera using the migration extractor tool.
gcloud alpha bq migration metadata extract \
--connector=cloudera-manager \
--output=gs://MIGRATION_BUCKET/cloudera-metadata.zip \
-- \
--url CLOUDERA_URL \
--user CLOUDERA_USER \
--password CLOUDERA_PASSWORD \
--yarn-application-types APPLICATION_TYPES \
--pagination-page-size PAGE_SIZE \
--assessment
Replace the following:
MIGRATION_BUCKET: the Cloud Storage bucket that you're using to store the migration files.CLOUDERA_URL: the URL for Cloudera Manager.CLOUDERA_USER: the username of the Cloudera user.CLOUDERA_PASSWORD: the password of the Cloudera user.APPLICATION_TYPES: (Optional) list of all existing application types from Hadoop YARN. For example,SPARK, MAPREDUCE.PAGE_SIZE: (Optional) specify how much data is fetched from third-party services, like the Hadoop YARN API. The default value is1000, which represents 1000 entities per request.
This command extracts metadata from Cloudera to a file named
cloudera-metadata.zip in the MIGRATION_BUCKET
bucket.
Apache Hive query logs
In the Apache Hive tab, follow the steps in
Extract query logs with the hadoop-migration-assessment logging hook
to extract your Apache Hive query logs. You can then upload the logs
to your Cloud Storage bucket containing your migration files.
What's next
With your extracted metadata from Hadoop, you can use these metadata files to do the following: