OceanBase Database V4.4.1 and later allow you to connect to Hive Metastore (HMS) and create an HMS Catalog. This feature enables you to access tables managed by HMS, including traditional Hive tables and Iceberg tables whose metadata is registered in HMS.
Notice
The syntax for CREATE EXTERNAL CATALOG ... TYPE = 'HMS' in HMS Catalog is described in this topic. For complete SQL reference, see CREATE EXTERNAL CATALOG. Ensure the current version includes the required statement. You must be using V4.4.1 or later in MySQL-compatible mode.
- Centralized metadata: table definitions are synchronized from Hive Metastore automatically.
- Federated analysis: external Hive data can be joined with tables inside OceanBase Database.
- Read-only protection: source data cannot be altered by accident.
The HMS Catalog capability is generally available since OceanBase Database V4.4.1. So that users can evaluate and plan AP workloads in advance, this topic is also published in the V4.3.5 documentation set.
Supported features
Read-only access: every object exposed through an HMS catalog is read-only. Statements such as
INSERT,UPDATE, andDROP TABLEare not supported yet.Supported table types: Hive tables, which are the native table types of HMS Catalog.
Hive version compatibility
Supported versions: Hive 1.2.x, Hive 2.3.x, Hive 3.1.x, and Hive 4.x.
HMS Catalog name: Hive Metastore 3.x and later can hold several catalogs inside one HMS for resource management. When you connect to such an HMS, set
HMS_CATALOG_NAMEto pick the catalog to use. If the parameter is omitted, no catalog is selected explicitly and HMS applies its default behavior; for Hive Metastore 3.x and later that default catalog is usually named "hive".Iceberg compatibility
- Hive 4.x and later: Iceberg tables are supported natively by Hive itself, so table creation and metadata updates can be done in Hive, and OceanBase Database reaches those tables directly through the HMS catalog.
- Hive 1.2.x, 2.3.x, and 3.1.x: Hive has no Iceberg support. In these versions, Iceberg tables are typically created and written by engines such as Spark or Flink and then registered in Hive Metastore. OceanBase Database locates and reads them by using the metadata recorded in HMS.
Prerequisites
Privilege requirements
- The current user must have Catalog-related privileges such as
CREATE CATALOGandUSE CATALOG(MySQL-compatible mode). Catalog capabilities are currently supported only in MySQL-compatible mode.
- The current user must have Catalog-related privileges such as
Environment dependencies: If the underlying storage is HDFS, you must deploy a Java SDK environment. For more information, see Deploy the OceanBase Database Java SDK environment.
External access
- HMS service: The OceanBase cluster must be able to access Hive Metastore (Thrift protocol). The address and port of the HMS service must be provided by the customer's O&M team. By default, open-source Hive uses port 9083, but this may vary in actual deployment. Please refer to the on-site configuration.
- Storage system: All OBServer nodes must have read permission for HDFS, S3, and OSS. If path permissions are restricted or Kerberos is enabled, you need to configure the corresponding authentication credentials via the Location. For details, see the Authentication mechanism between HMS Catalog and HDFS storage section below.
Syntax for creating an HMS Catalog
CREATE EXTERNAL CATALOG [IF NOT EXISTS] catalog_name
PROPERTIES (
TYPE = 'HMS',
URI = 'thrift://host:port',
[PRINCIPAL = '...'],
[KEYTAB = '...'],
[KRB5CONF = '...'],
[MAX_CLIENT_POOL_SIZE = 20],
[SOCKET_TIMEOUT = 10000000],
[HMS_CATALOG_NAME = '...']
);
Parameters
Parameter |
Required |
Description |
|---|---|---|
| TYPE | Yes | Must be set to 'HMS'. |
| URI | Yes | Thrift endpoint of HMS, in the thrift://$host:$port format.
"thrift://<HMS IP address 1>:<HMS port 1>,thrift://<HMS IP address 2>:<HMS port 2>,thrift://<HMS IP address 3>:<HMS port 3>". |
| PRINCIPAL | No | Kerberos principal, normally written as service/HOST@REGION.com, for example hive/hadoop@QA.COM. |
| KEYTAB | No | Path of the keytab file that is needed to reach an HMS service protected by Kerberos. For a distributed OceanBase cluster, the file must exist on every OBServer node at the same path. Notice: set this parameter only when Kerberos authentication is enabled for HMS. |
| KRB5CONF | No | Path of the Kerberos configuration file, such as /etc/krb5.conf. For a distributed OceanBase cluster, the file must exist on every OBServer node at the same path. |
| MAX_CLIENT_POOL_SIZE | No | Size of the HMS client connection pool. The default value is 20, which means this HMS catalog can open at most 20 clients to the HMS service. |
| SOCKET_TIMEOUT | No | Timeout for connecting to Hive Metastore, in microseconds. Default value: 10000000 (10s). |
| HMS_CATALOG_NAME | No | Hive Metastore 3.x and later can hold several catalogs inside one HMS for resource management. When you connect to such an HMS, set HMS_CATALOG_NAME to pick the catalog to use. If the parameter is omitted, no catalog is selected explicitly and HMS applies its default behavior; for Hive Metastore 3.x and later that default catalog is usually named 'hive'. |
Create an HMS Catalog with SIMPLE authentication
SIMPLE authentication requires no Location credentials.
obclient> CREATE EXTERNAL CATALOG test_hms_catalog
PROPERTIES = (
TYPE = 'HMS',
URI = "thrift://xxx.xxx.xxx.xxx:xxxx",
HMS_CATALOG_NAME = 'hive'
);
Note
If the HMS version is 3.1.3 or later, and a table is registered in a non-default catalog, you must specify the target catalog name using HMS_CATALOG_NAME. When accessing the default catalog, you can set it to hive, or omit this parameter (which defaults to empty and is determined by the default behavior of HMS).
For more information about Hadoop authentication modes, see the "Authentication mechanism of HMS Catalog and HDFS storage" section below.
Create an HMS Catalog with Kerberos authentication
For more information about Hadoop authentication modes, see the "Authentication mechanism of HMS Catalog and HDFS storage" section below.
Step 1: Create an HMS Catalog with Kerberos authentication (metadata layer)
CREATE EXTERNAL CATALOG hms_kerberos
PROPERTIES (
TYPE = 'HMS',
URI = 'thrift://hms.example.com:9083',
PRINCIPAL = 'hive/hms.example.com@EXAMPLE.COM',
KEYTAB = '/etc/ob/hive.keytab',
KRB5CONF = '/etc/krb5.conf',
HMS_CATALOG_NAME = 'hive'
);
Step 2: Create an HDFS location with Kerberos authentication (data layer)
CREATE LOCATION hdfs_kerberos_ha
URL = 'hdfs://namenode:8020/'
CREDENTIAL (
PRINCIPAL = "ob_hdfs@EXAMPLE.COM",
KEYTAB = "/etc/ob/hdfs.keytab",
KRB5CONF = "/etc/krb5.conf",
CONFIGS = '...' -- HA configurations as described above
);
The HMS catalog discovers the table structure, while the Location reads the HDFS data files securely.
Switch Catalog
SET CATALOG hms_catalog;
Query external data sources through Catalog
-- Hive table
SELECT city, COUNT(*) FROM hive_db.customer WHERE dt >= '2025-04-01' GROUP BY city;
-- Iceberg table
SELECT product_id, SUM(sales) FROM iceberg_db.sales_iceberg WHERE event_time >= '2025-04-01' GROUP BY product_id;
-- Federated Query
SELECT o.order_id, h.city
FROM internal.test_db.orders o
JOIN hms_catalog.hive_db.customer h ON o.user_id = h.id;
Authentication mechanism of HMS Catalog and HDFS storage
Accessing Hive Metastore (HMS) from OceanBase Database involves two independent authentication layers:
Catalog layer: connects to Hive Metastore, for example to fetch table structures, partitions, and other metadata.
Location layer: reads the data files that are stored in file systems such as HDFS.
You configure authentication for the two layers separately, and both must match the security policy of the Hadoop cluster.
The Hadoop authentication mode is determined by the server
The Hadoop cluster defines its security mode through the hadoop.security.authentication configuration item in hdfs-site.xml:
<property>
<name>hadoop.security.authentication</name>
<value>kerberos</value> <!-- or simple -->
</property>
kerberos: Kerberos authentication is enabled. Every client, the HMS Client and the HDFS Client included, must pass Kerberos authentication.simple: The Hadoop server trusts the operating system username declared by the client and does not verify passwords or credentials. Permission control is based only on the owner, group, and POSIX permission bits (for example,drwxr-xr-x (755)) of HDFS files and directories, without Kerberos authentication.
Notice
This setting lives on the Hadoop server ($HADOOP_HOME/etc/hadoop/hdfs-site.xml). OceanBase Database does not read the file itself; it follows the setting through its own Catalog and Location configurations.
Authentication configuration of OceanBase Database
Hadoop mode |
HMS Catalog configuration |
HDFS Location configuration |
|---|---|---|
| SIMPLE | No authentication method is specified when creating a catalog (default is SIMPLE). |
|
| KERBEROS | Specify AUTHENTICATION = 'KERBEROS' when creating a catalog, and provide PRINCIPAL, KEYTAB, and KRB5CONF. |
You must create an HDFS location with Kerberos authentication, and provide the Principal, Keytab, and krb5.conf. |
Key configuration rules: when Kerberos is enabled for either HMS or HDFS, verify that the deployment is correct.
Overview of two authentication modes
SIMPLE mode (common in development and testing environments)
Applicable scenarios:
Kerberos is not enabled for HDFS, and access control relies only on Linux file permissions.
Tables may be written by a particular user. For example, an HDFS path written by Impala is owned by impala, while a path written by Hive on Tez is owned by the user who submitted the job, such as hive.
Configuration requirements:
Anonymous read path: HDFS directory permissions are open (for example,
drwxr-xr-x (755)), and any user can read without creating a location.- Meaning: The owner has read, write, and execute permissions (rwx = 4+2+1 = 7); the group and other users have only read and execute permissions (r-x = 4+0+1 = 5).
- For such paths, OceanBase Database does not need to create a location and can directly access the path.
Restricted path: if the user that runs the OceanBase Database observer process, such as admin, is not listed as an authorized user or group of the directory, you must:
If the user of the OceanBase Database observer process (such as admin) does not belong to the user or user group that is allowed access to the HDFS path, you need to create a location and specify a user who has the corresponding access permissions on the HDFS side.
CREATE LOCATION my_loc
URL = 'hdfs://mycluster/'
CREDENTIAL (USERNAME = 'username');
Scenario 1: No Kerberos authentication and no need to specify an HDFS user (default anonymous access)
Applicable to: Development or testing environments where Kerberos authentication is not enabled for the HDFS cluster (that is, hadoop.security.authentication=simple).
Operation: No Location needs to be created.
Scenario 2: No Kerberos authentication is required, but an HDFS user must be specified
Applicable to: development or test environments where Kerberos is not enabled for the HDFS cluster (that is,
hadoop.security.authentication=simple), but the data files of the target Hive table sit in a restricted HDFS path, for example a path written by Impala, Hive, or another engine whose owner is a specific user and which has no global read permission.Typical cases:
- The path owner is impala when Impala writes to the HDFS path.
- The path owner is hive or etl_user when a Hive job writes to the HDFS path.
- By default, the OceanBase Database observer process uses the operating system user (such as admin) to access HDFS. If the user does not have read permissions, the query fails.
Example: Assume that a Hive table is written by Impala, and the HDFS path is
hdfs://namenode:8020/warehouse/sales.db/click_log.
CREATE LOCATION hdfs_impala_data
URL = 'hdfs://namenode:8020/' -- URL, see the description below
CREDENTIAL (
USERNAME = 'username'
);
How to determine the correct URL:
Execute the following command in Hive CLI or Beeline:
SHOW CREATE TABLE your_db.your_table;View the LOCATION field in the output, for example:
LOCATION 'hdfs://namenode:8020/warehouse/your_db.db/your_table'Take the protocol, service name or host name, and service port as the URL. In the CREATE LOCATION statement, set the URL to
hdfs://namenode:8020/.
Scenario 3: Kerberos is not enabled, and HDFS is highly available (HA)
Operation: No need to set the PRINCIPAL, KEYTAB, or KRB5CONF parameters.
CREATE LOCATION hdfs_location_ha
URL = 'hdfs://${nameservice_id}' -- It is recommended to use the logical service name.
CREDENTIAL (
CONFIGS = 'dfs.nameservices=${nameservice id}#dfs.ha.namenodes.${nameservice id}=${namenode1}, ${namenode2}#dfs.namenode.rpc-address.${nameservice id}.${namenode1}=${namenode 1 address}#dfs.namenode.rpc-address.${nameservice id}.${namenode2}=${namenode 2 address}#dfs.ha.automatic-failover.enabled.${nameservice id}=true#dfs.client.failover.proxy.provider.${nameservice id}=org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider'
);
Kerberos mode (standard for production environments)
Applicable scenarios:
- Enterprise-level Hadoop clusters where Kerberos authentication is enabled for Hive Metastore Service (HMS) or Hadoop Distributed File System (HDFS).
Configuration requirements:
HMS Catalog: Specify
PRINCIPAL,KEYTAB, andKRB5CONFin thePROPERTIESclause of theCREATE EXTERNAL CATALOGstatement.HDFS Location: For details, see Step 2: Create an HDFS location with Kerberos authentication above and Scenarios 4 and 5 below. The syntax for
CREATE LOCATIONis based on the SQL reference.
Scenario 4: Kerberos authentication is enabled, and HDFS is a single NameNode (non-HA mode)
-- Create a LOCATION: Kerberos authentication + single-node HDFS
CREATE LOCATION hdfs_kerberos_single
URL = 'hdfs://namenode.example.com:8020/' -- Obtain the complete HDFS path of the table by executing SHOW CREATE TABLE, and extract the root URL.
CREDENTIAL (
PRINCIPAL = "hdfs/TEST@EXAMPLE.COM",
KEYTAB = "/data/hdfs.keytab",
KRB5CONF = "/data/krb5.conf",
CONFIGS = 'dfs.data.transfer.protection=integrity'
);
Note
- The
dfs.data.transfer.protectionparameter that you pass inCONFIGSsets the security level of the HDFS data transfer channel, for exampleauthentication,integrity,privacy, ornull.
- The value must match the
dfs.data.transfer.protectionsetting in thehdfs-site.xmlfile of the Hadoop cluster. A mismatch in security policy may cause data read operations to fail.
- Confirm the actual value with the Hadoop administrator, or read the
hdfs-site.xmlfile of the HDFS cluster directly.
Scenario 5: Kerberos authentication is enabled, and HDFS is highly available (HA)
CREATE LOCATION hdfs_kerberos_ha
URL = 'hdfs://${nameservice id}' -- We recommend that you use the logical service name.
CREDENTIAL (
PRINCIPAL = "ob_hdfs@EXAMPLE.COM",
KEYTAB = "/etc/ob/hdfs.keytab",
KRB5CONF = "/etc/krb5.conf",
CONFIGS = 'dfs.data.transfer.protection=integrity#dfs.nameservices=mycluster#dfs.ha.namenodes.mycluster=nn1,nn2#dfs.namenode.rpc-address.mycluster.nn1=nn1:8020#dfs.namenode.rpc-address.mycluster.nn2=nn2:8020#dfs.client.failover.proxy.provider.mycluster=org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider'
);
Note
- Deploy the same keytab and krb5.conf files on all OBServer nodes.
- If the "Unknown Host" error occurs, add the HDFS node mapping to the /etc/hosts file.
For more information about the Location parameters, see the LOCATION section in CREATE EXTERNAL TABLE and Catalogs and external tables.
Configuration notes
- Authentication separation: The authentication for Catalog (metadata) and Location (data) are configured separately.
- Mode alignment: The authentication mode of OceanBase Database must be consistent with the
hadoop.security.authenticationsetting of the Hadoop cluster. - Kerberos consistency: If Kerberos is enabled for either HMS or HDFS, Kerberos credentials must be configured for both.
- SIMPLE mode requires permission checks: Ensure that the Observer user or specified USER has read permissions for the HDFS path.
- HMS Catalog name: If multiple Catalogs exist in HMS 3.1.3 or later, ensure that the
HMS_CATALOG_NAMEmatches the actual name of the Catalog being created.