redash oracle 数据源docker 镜像
redash 官方的docker 镜像是没有包含oracle的,需要我们自己添加,参考了一个docker 镜像进行了简单的修改
Dockerfile
FROM redash/redash:7.0.0.b18042
USER root
# Oracle instantclient
ADD oracle/instantclient-basic-linux.x64-12.2.0.1.0.zip /tmp/instantclient-basic-linux.x64-12.2.0.1.0.zip
ADD oracle/instantclient-sdk-linux.x64-12.2.0.1.0.zip /tmp/instantclient-sdk-linux.x64-12.2.0.1.0.zip
ADD oracle/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip /tmp/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip
RUN apt-get update -y
RUN apt-get install -y unzip
RUN unzip /tmp/instantclient-basic-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN unzip /tmp/instantclient-sdk-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN unzip /tmp/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN ln -s /usr/local/instantclient_12_2 /usr/local/instantclient
RUN ln -s /usr/local/instantclient/libclntsh.so.12.1 /usr/local/instantclient/libclntsh.so
RUN ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus
RUN apt-get install libaio-dev -y
RUN apt-get clean -y
ENV ORACLE_HOME=/usr/local/instantclient
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/instantclient
COPY oracle.py /app/redash/query_runner/oracle.py
RUN pip install cx_Oracle==5.3
USER redash
#Add REDASH ENV to add Oracle Query Runner
ENV REDASH_ADDITIONAL_QUERY_RUNNERS=redash.query_runner.oracle
说明
实际上官方文档提供了一些简单的说明在 oracle
内容如下:
# Requires installation of, or similar versions of:
# oracle-instantclient12.2-basic_12.2.0.1.0-1_x86_64.rpm
# oracle-instantclient12.2-devel_12.2.0.1.0-1_x64_64.rpm
cx_Oracle==5.3
上边的镜像参考了https://github.com/joaoleite/redash_oracle,同时指定新oracle client 以及python 包
同时如果需要启用oracle,需要添加REDASH_ADDITIONAL_QUERY_RUNNERS
环境变量,内容为
ENV REDASH_ADDITIONAL_QUERY_RUNNERS=redash.query_runner.oracle
以上同时包含了一个对于中文乱码的问题oracle.py, 需要添加的代码
import os
os.environ['NLS_LANG'] = 'AMERICAN_CHINA.ZHS16GBK'
docker-compose 运行
- docker-compose 文件
version: '3'
services:
server:
image: dalongrong/redash-oracle:7.0.0.b18042
command: server
env_file: ./opt/redash/env
ports:
- "5000:5000"
environment:
REDASH_WEB_WORKERS: 4
scheduler:
image: dalongrong/redash-oracle:7.0.0.b18042
command: scheduler
env_file: ./opt/redash/env
environment:
QUEUES: "celery"
WORKERS_COUNT: 1
scheduled_worker:
image: dalongrong/redash-oracle:7.0.0.b18042
command: worker
env_file: ./opt/redash/env
environment:
QUEUES: "scheduled_queries,schemas"
WORKERS_COUNT: 1
adhoc_worker:
image: dalongrong/redash-oracle:7.0.0.b18042
command: worker
env_file: ./opt/redash/env
environment:
QUEUES: "queries"
WORKERS_COUNT: 2
redis:
image: redis:5.0-alpine
restart: always
postgres:
image: postgres:9.5-alpine
env_file: ./opt/redash/env
volumes:
- ./opt/redash/postgres-data:/var/lib/postgresql/data
restart: always
nginx:
image: redash/nginx:latest
ports:
- "80:80"
depends_on:
- server
links:
- server:redash
restart: always
- 环境变量说明
详细的环境变量可以参考opt/redash/env - 启动
docker-compose up -d
docker-compose run --rm server create_db
效果
说明
docker 镜像我已经push dockerhub 了dalongrong/redash-oracle
参考资料
https://github.com/joaoleite/redash_oracle
https://github.com/rongfengliang/redash_oracle
https://github.com/getredash/redash/blob/master/requirements_oracle_ds.txt