# Integration with Hive Metastore
In this section, you will learn how to configure Kyuubi to interact with Hive Metastore.
- A common Hive metastore server could be set at Kyuubi server side
- Individual Hive metastore servers could be used for end users to set
## Requirements
- A running Hive metastore server
- [Hive Metastore Administration](https://cwiki.apache.org/confluence/display/Hive/AdminManual+Metastore+Administration)
- [Configuring the Hive Metastore for CDH](https://docs.cloudera.com/documentation/enterprise/latest/topics/cdh_ig_hive_metastore_configure.html)
- A Spark binary distribution built with `-Phive` support
- Use the built-in one in the Kyuubi distribution
- Download from [Spark official website](https://spark.apache.org/downloads.html)
- Build from Spark source, [Building With Hive and JDBC Support](https://spark.apache.org/docs/latest/building-spark.html#building-with-hive-and-jdbc-support)
- A copy of Hive client configuration
So the whole thing here is to let Spark applications use this copy of Hive configuration to start a Hive metastore client for their own to talk to the Hive metastore server.
## Default Behavior
By default, Kyuubi launches Spark SQL engines pointing to a dummy embedded [Apache Derby](https://db.apache.org/derby/)-based metastore for each application,
and this metadata can only be seen by one user at a time, e.g.
```shell script
bin/beeline -u 'jdbc:hive2://localhost:10009/' -n kentyao
Connecting to jdbc:hive2://localhost:10009/
Connected to: Spark SQL (version 1.0.0-SNAPSHOT)
Driver: Hive JDBC (version 2.3.7)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 2.3.7 by Apache Hive
0: jdbc:hive2://localhost:10009/> show databases;
2020-11-16 23:50:50.388 INFO operation.ExecuteStatement:
Spark application name: kyuubi_kentyao_spark_2020-11-16T15:50:08.968Z
application ID: local-1605541809797
application web UI: http://192.168.1.14:60165
master: local[*]
deploy mode: client
version: 3.0.1
Start time: 2020-11-16T15:50:09.123Z
User: kentyao
2020-11-16 23:50:50.404 INFO metastore.HiveMetaStore: 2: get_databases: *
2020-11-16 23:50:50.404 INFO HiveMetaStore.audit: ugi=kentyao ip=unknown-ip-addr cmd=get_databases: *
2020-11-16 23:50:50.423 INFO operation.ExecuteStatement: Processing kentyao's query[8453e657-c1c4-4391-8406-ab4747a66c45]: RUNNING_STATE -> FINISHED_STATE, statement: show databases, time taken: 0.035 seconds
+------------+
| namespace |
+------------+
| default |
+------------+
1 row selected (0.122 seconds)
0: jdbc:hive2://localhost:10009/> show tables;
2020-11-16 23:50:52.957 INFO operation.ExecuteStatement:
Spark application name: kyuubi_kentyao_spark_2020-11-16T15:50:08.968Z
application ID: local-1605541809797
application web UI: http://192.168.1.14:60165
master: local[*]
deploy mode: client
version: 3.0.1
Start time: 2020-11-16T15:50:09.123Z
User: kentyao
2020-11-16 23:50:52.968 INFO metastore.HiveMetaStore: 2: get_database: default
2020-11-16 23:50:52.968 INFO HiveMetaStore.audit: ugi=kentyao ip=unknown-ip-addr cmd=get_database: default
2020-11-16 23:50:52.970 INFO metastore.HiveMetaStore: 2: get_database: default
2020-11-16 23:50:52.970 INFO HiveMetaStore.audit: ugi=kentyao ip=unknown-ip-addr cmd=get_database: default
2020-11-16 23:50:52.972 INFO metastore.HiveMetaStore: 2: get_tables: db=default pat=*
2020-11-16 23:50:52.972 INFO HiveMetaStore.audit: ugi=kentyao ip=unknown-ip-addr cmd=get_tables: db=default pat=*
2020-11-16 23:50:52.986 INFO operation.ExecuteStatement: Processing kentyao's query[ff902582-ba29-433b-b70a-c25ead1353a8]: RUNNING_STATE -> FINISHED_STATE, statement: show tables, time taken: 0.03 seconds
+-----------+------------+--------------+
| database | tableName | isTemporary |
+-----------+------------+--------------+
+-----------+------------+--------------+
No rows selected (0.04 seconds)
```
Using this mode for experimental purposes only.
In a real production environment, we always have a communal standalone metadata store,
to manage the metadata of persistent relational entities, e.g. databases, tables, columns, partitions, for fast access.
Usually, Hive metastore as the de facto.
## Related Configurations
These are the basic needs for a Hive metastore client to communicate with the remote Hive Metastore server.
Use remote metastore database or server mode depends on the server-side configuration.
### Remote Metastore Database
| Name | Value | Meaning |
|---------------------------------------|--------------------------------------------------------------------------------------|------------------------------------------|
| javax.jdo.option.ConnectionURL | jdbc:mysql://<hostname>/<databaseName>?
createDatabaseIfNotExist=true | metadata is stored in a MySQL server |
| javax.jdo.option.ConnectionDriverName | com.mysql.jdbc.Driver | MySQL JDBC driver class |
| javax.jdo.option.ConnectionUserName | <username> | user name for connecting to MySQL server |
| javax.jdo.option.ConnectionPassword | <password> | password for connecting to MySQL server |
### Remote Metastore Server
| Name | Value | Meaning |
|---------------------|-------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
| hive.metastore.uris | thrift://<host>:<port>,thrift://<host1>:<port1> |