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