MySQL Metadata Store

To use this Apache Druid extension, make sure to include mysql-metadata-storage as an extension.

The MySQL extension requires the MySQL Connector/J library which is not included in the Druid distribution. Refer to the following section for instructions on how to install this library.

Installing the MySQL connector library

This extension uses Oracle’s MySQL JDBC driver which is not included in the Druid distribution and must be installed separately. There are a few ways to obtain this library:

This should fetch a JAR file named similar to ‘mysql-connector-java-x.x.xx.jar’.

Copy or symlink this file to extensions/mysql-metadata-storage under the distribution root directory.

Setting up MySQL

  1. Install MySQL

Use your favorite package manager to install mysql, e.g.:

  • on Ubuntu/Debian using apt apt-get install mysql-server
  • on OS X, using Homebrew brew install mysql

Alternatively, download and follow installation instructions for MySQL Community Server here: http://dev.mysql.com/downloads/mysql/

  1. Create a druid database and user

Connect to MySQL from the machine where it is installed.

  1. > mysql -u root

Paste the following snippet into the mysql prompt:

  1. -- create a druid database, make sure to use utf8mb4 as encoding
  2. CREATE DATABASE druid DEFAULT CHARACTER SET utf8mb4;
  3. -- create a druid user
  4. CREATE USER 'druid'@'localhost' IDENTIFIED BY 'diurd';
  5. -- grant the user all the permissions on the database we just created
  6. GRANT ALL PRIVILEGES ON druid.* TO 'druid'@'localhost';
  1. Configure your Druid metadata storage extension:

Add the following parameters to your Druid configuration, replacing <host> with the location (host name and port) of the database.

  1. druid.extensions.loadList=["mysql-metadata-storage"]
  2. druid.metadata.storage.type=mysql
  3. druid.metadata.storage.connector.connectURI=jdbc:mysql://<host>/druid
  4. druid.metadata.storage.connector.user=druid
  5. druid.metadata.storage.connector.password=diurd

Encrypting MySQL connections

This extension provides support for encrypting MySQL connections. To get more information about encrypting MySQL connections using TLS/SSL in general, please refer to this guide.

Configuration

PropertyDescriptionDefaultRequired
druid.metadata.mysql.ssl.useSSLEnable SSLfalseno
druid.metadata.mysql.ssl.clientCertificateKeyStoreUrlThe file path URL to the client certificate key store.noneno
druid.metadata.mysql.ssl.clientCertificateKeyStoreTypeThe type of the key store where the client certificate is stored.noneno
druid.metadata.mysql.ssl.clientCertificateKeyStorePasswordThe Password Provider or String password for the client key store.noneno
druid.metadata.mysql.ssl.verifyServerCertificateEnables server certificate verification.falseno
druid.metadata.mysql.ssl.trustCertificateKeyStoreUrlThe file path to the trusted root certificate key store.Default trust store provided by MySQLyes if verifyServerCertificate is set to true and a custom trust store is used
druid.metadata.mysql.ssl.trustCertificateKeyStoreTypeThe type of the key store where trusted root certificates are stored.JKSyes if verifyServerCertificate is set to true and keystore type is not JKS
druid.metadata.mysql.ssl.trustCertificateKeyStorePasswordThe Password Provider or String password for the trust store.noneyes if verifyServerCertificate is set to true and password is not null
druid.metadata.mysql.ssl.enabledSSLCipherSuitesOverrides the existing cipher suites with these cipher suites.noneno
druid.metadata.mysql.ssl.enabledTLSProtocolsOverrides the TLS protocols with these protocols.noneno

MySQL Firehose

The MySQL extension provides an implementation of an SqlFirehose which can be used to ingest data into Druid from a MySQL database.

  1. {
  2. "type": "index_parallel",
  3. "spec": {
  4. "dataSchema": {
  5. "dataSource": "some_datasource",
  6. "parser": {
  7. "parseSpec": {
  8. "format": "timeAndDims",
  9. "dimensionsSpec": {
  10. "dimensionExclusions": [],
  11. "dimensions": [
  12. "dim1",
  13. "dim2",
  14. "dim3"
  15. ]
  16. },
  17. "timestampSpec": {
  18. "format": "auto",
  19. "column": "ts"
  20. }
  21. }
  22. },
  23. "metricsSpec": [],
  24. "granularitySpec": {
  25. "type": "uniform",
  26. "segmentGranularity": "DAY",
  27. "queryGranularity": {
  28. "type": "none"
  29. },
  30. "rollup": false,
  31. "intervals": null
  32. },
  33. "transformSpec": {
  34. "filter": null,
  35. "transforms": []
  36. }
  37. },
  38. "ioConfig": {
  39. "type": "index_parallel",
  40. "firehose": {
  41. "type": "sql",
  42. "database": {
  43. "type": "mysql",
  44. "connectorConfig": {
  45. "connectURI": "jdbc:mysql://some-rds-host.us-west-1.rds.amazonaws.com:3306/druid",
  46. "user": "admin",
  47. "password": "secret"
  48. }
  49. },
  50. "sqls": [
  51. "SELECT * FROM some_table"
  52. ]
  53. }
  54. },
  55. "tuningconfig": {
  56. "type": "index_parallel"
  57. }
  58. }
  59. }