Sign inSign up

yandex/clickhouse-jdbc-bridge

By yandex

Updated over 4 years ago

Image
1

10K+

yandex/clickhouse-jdbc-bridge repository overview

ClickHouse JDBC Bridge Docker Image

What is ClickHouse JDBC Bridge?

It's a stateless proxy passing queries from ClickHouse to external datasources. With this extension, you can use JDBC table function and/or corresponding table engine on ClickHouse server to query arbitrary datasources in real time.

Versions

The latest tag points to the latest release from master branch. Branch tags like 2.0 point to the latest release of the corresponding branch. Full version tags like 2.0.0 point to the corresponding release.

How to use this image

Start JDBC bridge
docker run -d --name ch-jdbc-bridge -p9019:9019 \
    -e MAVEN_REPO_URL="https://repo1.maven.org/maven2" \
    -e JDBC_DRIVERS="org/mariadb/jdbc/mariadb-java-client/2.7.1/mariadb-java-client-2.7.1.jar,org/postgresql/postgresql/42.2.18/postgresql-42.2.18.jar" yandex/clickhouse-jdbc-bridge

If you prefer to use JDBC drivers and named datasources on host, you can use the following commands:

wget -P drivers \
    https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.1/mariadb-java-client-2.7.1.jar \
    https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.18/postgresql-42.2.18.jar
wget -P datasources \
    https://raw.githubusercontent.com/ClickHouse/clickhouse-jdbc-bridge/master/misc/quick-start/jdbc-bridge/config/datasources/mariadb10.json \
    https://raw.githubusercontent.com/ClickHouse/clickhouse-jdbc-bridge/master/misc/quick-start/jdbc-bridge/config/datasources/postgres13.json
# please edit datasources/*.json to connect to your database servers
docker run -d --name ch-jdbc-bridge -p9019:9019 -v `pwd`/drivers:/app/drivers \
    -v `pwd`/datasources:/app/config/datasources yandex/clickhouse-jdbc-bridge
Configure ClickHouse server

By default, ClickHouse assumes JDBC bridge is available at localhost:9019. You can customize the host and port in /etc/clickhouse-server/config.xml like below:

<yandex>
    ...
    <jdbc_bridge>
        <host>localhost</host>
        <port>9019</port>
    </jdbc_bridge>
    ...
</yandex>
Issue query on ClickHouse

Once you started JDBC bridge and configured ClickHouse server accordingly, you should be able to run queries like below on ClickHouse:

-- show all named datasources
select * from jdbc('', 'show datasources')
-- query against adhoc datasource, NOT recommended for security reason
select * from jdbc('jdbc:mariadb://localhost:3306/test?useSSL=false&user=root&password=root', 'select 1')
-- query against named datasource with inline schema and adhoc query
select * from jdbc('mariadb10', 'num UInt8', 'select 1 as num')
-- scripting
select * from jdbc('script', '[1,2,3]')

Configuration

Container exposes 9019 port for ClickHouse integration and monitoring.

In order to customize the container, please refer to directory structure and supported environment variables shown below.

/app                        # work directory
  |
  |-- drivers               # JDBC drivers
  |-- config                
  |     |
  |     |-- datasources     # named datasources
  |     |-- schemas         # named schemas
  |     |-- queries         # named queries
  |
  |-- logs                  # application logs
  |-- scripts               # saved queries/scripts
Environment VariableJava System PropertyDefault ValueRemark
CONFIG_DIRjdbc-bridge.config.dirconfigConfiguration directory
CUSTOM_DRIVER_LOADERjdbc-bridge.driver.loadertrueWhether use custom driver class loader or not
DATASOURCE_CONFIG_DIRjdbc-bridge.datasource.config.dirdatasourcesDirectory for named datasources
DEFAULT_VALUEjdbc-bridge.type.defaultfalseWhether support default expression in column definition or not
DRIVER_DIRjdbc-bridge.driver.dirdriversDirectory for drivers needed to connect to datasources
HTTPD_CONFIG_FILEjdbc-bridge.httpd.config.filehttpd.jsonHTTP server configuration file
JDBC_BRIDGE_JVM_OPTS--JVM arguments
JDBC_DRIVERS--Comma separated JDBC driver download path on Maven repository
MAVEN_REPO_URL-https://repo1.maven.org/maven2Base URL of Maven repository
QUERY_CONFIG_DIRjdbc-bridge.query.config.dirqueriesDirectory for named queries
SCHEMA_CONFIG_DIRjdbc-bridge.schema.config.dirschemasDirectory for named schemas
SERVER_CONFIG_FILEjdbc-bridge.server.config.fileserver.jsonJDBC bridge server configuration file
VERTX_CONFIG_FILEjdbc-bridge.vertx.config.filevertx.jsonVert.x configuration file

License

View license information for the software contained in this image.

Tag summary

Content type

Image

Digest

Size

109.4 MB

Last updated

over 4 years ago

docker pull yandex/clickhouse-jdbc-bridge