The default installation of metering configures Hive to use an embedded Java database called Derby. This is unsuited for larger environments and can be replaced with either a MySQL or PostgreSQL database. Use the following example configuration files if your deployment requires a MySQL or PostgreSQL database for Hive.
There are three configuration options you can use to control the database used by Hive metastore: url
, driver
, and secretName
.
Create your MySQL or Postgres instance with a username and password. Then create a secret by using the OpenShift CLI or a YAML file. The secretName you create for this secret must map to the spec.hive.spec.config.db.secretName field in the MeteringConfig resource.
To create a secret in OpenShift CLI you can use the following command:
$ oc --namespace openshift-metering create secret generic <YOUR_SECRETNAME> --from-literal=username=<YOUR_DATABASE_USERNAME> --from-literal=password=<YOUR_DATABASE_PASSWORD>
To create a secret by using a YAML file, use the following example file:
apiVersion: v1
kind: Secret
metadata:
name: <YOUR_SECRETNAME> (1)
data:
username: <BASE64_ENCODED_DATABASE_USERNAME> (2)
password: <BASE64_ENCODED_DATABASE_PASSWORD> (3)
1 |
The name of the secret. |
2 |
Base64 encoded database username. |
3 |
Base64 encoded database password. |
Use the example configuration file below to use a MySQL database for Hive:
spec:
hive:
spec:
metastore:
storage:
create: false
config:
db:
url: "jdbc:mysql://mysql.example.com:3306/hive_metastore"
driver: "com.mysql.jdbc.Driver"
secretName: "REPLACEME" (1)
1 |
The name of the secret containing the base64-encrypted username and password database credentials. |
Use the example configuration file below to use a PostgreSQL database for Hive:
spec:
hive:
spec:
metastore:
storage:
create: false
config:
db:
url: "jdbc:postgresql://postgresql.example.com:5432/hive_metastore"
driver: "org.postgresql.Driver"
username: "REPLACEME"
password: "REPLACEME"