You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Metastore 3.0 Administration

Version Note

This document applies only to the Metastore in Hive 3.0 and later releases.  For Hive 0, 1, and 2 releases please see the Metastore Administration document.

Introduction

The definition of Hive objects such as databases, tables,  and functions are stored in the Metastore.  Depending on how the system is configured, statistics and authorization records may also be stored there.  Hive, and other execution engines, can then use this data at runtime to determine how to efficiently execute user queries.  

The Metastore persists the object definitions to a relational database (RDBMS) via DataNucleus, a Java JDO based Object Relational Mapping (ORM) layer. See Supported RDBMSs below for a list of supported RDBMSs that can be used.

The Metastore can be configured to embed the Apache Derby RDBMS or connect to a external RDBMS.  The Metastore itself can be embedded entirely in a user process or run as a service for other processes to connect to.  Each of these options will be discussed in turn below.

Changes From Hive 2 to Hive 3

Beginning in Hive 3.0, the Metastore can be run without the rest of Hive being installed.  It is provided as a separate release in order to allow non-Hive systems to easily integrate with it.  (It is, however, still included in the Hive release for convenience.)  Making the Metastore a standalone service involved changing a number of configuration parameter names and tool names.  All of the old configuration parameters and tools still work  in order to maximize backwards compatibility.  This document will cover both the old and new names.  As new functionality is added it will only be added to the new names.

For details on using the Metastore without Hive, see Running the Metastore Without Hive below.

General Configuration

The metastore reads its configuration from the file metastore-site.xml.  It expects to find this file in $METASTORE_HOME/conf where $METASTORE_HOME is an environment variable.  For backwards compatibility it will also read any hive-site.xml or hive-metastoresite.xml files found in HIVE_HOME/conf.  Configuration options can also be defined on the command line (see Starting and Stopping the Service below).

Configuration values specific to running the Metastore with various RDBMSs, embedded or as a service, and without Hive are discussed in the relevant sections.  The following configuration values apply to the Metastore regardless of how it is being run.  This table covers only commonly customized configuration values.  For less commonly changed configuration values see Less Commonly Changed Configuration Parameters.

 

ParameterHive 2.0 ParameterDefault ValueDescription
metastore.warehouse.dirhive.metastore.warehouse.dir URI of the default location for tables in the default catalog and database.
datanucleus.schema.autoCreateAlldatanucleus.schema.autoCreateAllfalse

Auto creates the necessary schema in the RDBMS at startup if one does not exist. Set this to false after creating it once. To enable auto create also set hive.metastore.schema.verification=false. Auto creation is not recommended in production; run schematool instead.

metastore.schema.verificationhive.metastore.schema.verificationtrue

Enforce metastore schema version consistency. When set to true: verify that version information stored in is compatible with the version of the Metastore jar. Also disable automatic schema migration. Users are required to manually migrate the schema after upgrade, which ensures proper schema migration.
When set to false: warn if the version information stored in Metastore doesn't match the version of the Metastore jar.

metastore.hmshandler.retry.attemptshive.hmshandler.retry.attempts10The number of times to retry a call to the meastore when there is a connection error.
metastore.hmshandler.retry.intervalhive.hmshandler.retry.interval2 secTime between retry attempts.
metastore.log4j.filehive.log4j.filenoneLog4j configuration file. If unset will look for metastore-log4j2.properties in $METASTORE_HOME/conf
metastore.stats.autogatherhive.stats.autogathertrueWhether to automatically gather basic statistics during insert commands.

RDBMS

Option 1: Embedding Derby

The metastore can be run with Apache Derby embedded.  This is the default configuration.  However, it is not intended for use beyond simple testing.  In this configuration only one client can use the Metastore and any changes are not durable beyond the life of the client (since it uses an in memory version of Derby).

Option 2: External RDBMS

For any durable, multi-user installation, an external RDBMS should be used to store Metastore objects.  The Metastore connects to an external RDBMS via JDBC.  Any jars required by the JDBC driver for your RDBMS should be placed in METASTORE_HOME/lib or explicilty passed on the command line.  The following values need to be configured to connect the Metastore to an RDBMS.  (Note:  these configuration parameters did not change between Hive 2 and 3.)

Configuration ParameterComment

javax.jdo.option.ConnectionURL

Connection URL for the JDBC driver
javax.jdo.option.ConnectionDriverNameJDBC driver class
javax.jdo.option.ConnectionUserNameUser name to connect to the RDBMS with, often 'hive' is used
javax.jdo.option.ConnectionPasswordPassword to connect to the RDBMS with. The Metastore uses Hadoop's CredentialProvider API so this does not have to be stored in clear text in your configuration file.

Supported RDBMSs

As the Metastore uses DataNucleus to communicate with the RDBMS, theoretically any storage option supported by DataNucleus would work with the Metastore.  However, we only test and recommend the following:

RDBMSMinimum Versionjavax.jdo.option.ConnectionURLjavax.jdo.option.ConnectionDriverName
MS SQL Server2008 R2jdbc:sqlserver://<HOST>:<PORT>;DatabaseName=<SCHEMA>
com.microsoft.sqlserver.jdbc.SQLServerDriver
MySQL5.6.17jdbc:mysql://<HOST>:<PORT>/<SCHEMA>
com.mysql.jdbc.Driver
MariaDB5.5jdbc:mysql://<HOST>:<PORT>/<SCHEMA>
org.mariadb.jdbc.Driver
Oracle*11g

jdbc:oracle:thin:@//<HOST>:<PORT>/xe

oracle.jdbc.OracleDriver
Postgres9.1.13

jdbc:postgresql://<HOST>:<PORT>/<SCHEMA>

org.postgresql.Driver

<HOST> = The host the RDBMS is on.

<PORT> = Port the RDBMS is listening for JDBC connections on

<SCHEMA> = The schema (or database) that the Metastore stores its tables in.

*The Oracle values shown are for Oracle's thin JDBC client.  If you are using a different client the ConnectionURL and ConnectionDriverName values will differ.

Special Note:  When using Postgres you should set the configuration parameter metastore.try.direct.sql.ddl (previously hive.metastore.try.direct.sql.ddl) to false, to avoid failures in certain operations.

Installing and Upgrading the Metastore Schema

The Metastore provides the schematool utility to work with the Metastore schema in the RDBMS.  For a full list of options see the -help option of the tool.  The following summarizes what the tool can do.  In most cases schematool can read the configuration from the metastore-site.xml file, though the configuration can also be passed as options on the command line.

  • -initSchema: install a new schema.  This should be used when first setting up a Metastore.
  • -upgradeSchema: upgrade to the newly installed version.  For 3.0, upgrades can be done from 1.2, 2.0, 2.1, 2.2, and 2.3 to 3.0.  If you need to upgrade from before 1.2, use an older version of Hive's schematool to first upgrade your schema to 1.2, then use the current Metastore version to upgrade to 3.0.
  • -createUser: create the Metastore user and schema.  This does not install the tables, it just creates the database user and schema.  This likely will not work in a production environment because you likely will not have permissions to create users and schemas.  You will likely need your DBA to do this for you.  
  • -validate: check that your Metastore schema is correct for its recorded version

Running the Metastore

Embedded Mode

The Metastore can be embedded directly into a process as a library.  This is often done with HiveServer2 to avoid an additional network hop for metadata operations.  It can also be done when using the Hive CLI or any other process.  This mode is the default and will be used anytime the configuration parameter metastore.uris is not set.

Except in the case of HiveServer2, using this mode does raise a few concerns.  First, having many clients will put a burden on the backing RDBMS since each client will have its own set of connections.  

Security Considerations

 

Metastore Server

javax.jdo.option.ConnectionURL

JDBC connection string for the data store which contains metadata

javax.jdo.option.ConnectionDriverName

JDBC Driver class name for the data store which contains metadata

hive.metastore.uris

THRIFT_URI_SELECTION

Starting and Stopping the Service

Remember to discuss command line options like defining a configuration value

High Availability

Securing the Service

CLIENT_KERBEROS_PRINCIPAL, KERBEROS_*, SSL*, USE_SSL, USE_THRIFT_SASL

 

 

Running the Metastore Without Hive

Less Commonly Changed Configuration Parameters

BATCHED_RETRIEVE_*, CLIENT_CONNECT_RETRY_DELAY, FILTER_HOOK, SERDES_USING_METASTORE_FOR_SCHEMA, SERVER_*_THREADS, 

THREAD_POOL_SIZE

Security: EXECUTE_SET_UGI, metastore.authorization.storage.checks

Setting up Caching: CACHED*, CATALOGS_TO_CACHE & AGGREGATE_STATS_CACHE*

Transactions: MAX_OPEN_TXNS, TXNS_*

 

 

  • No labels