Help us understand the problem. What is going on with this article?

redashのdockerにoracleのデータソースを追加する

More than 1 year has passed since last update.

概要

redashのdockerがそのままではoracle使用できなかったので追加しました

環境情報

  • Docker 17.05.0-ce
  • docker-compose 1.18.0
  • redash 4.0.0

oracleを取得する

  • ダウンロードページ にアクセスしてoracleを取得します

    • instantclient-basic-linux.x64-12.2.0.1.0.zip
    • instantclient-sdk-linux.x64-12.2.0.1.0.zip
    • instantclient-sqlplus-linux.x64-12.2.0.1.0.zip
  • 取得したファイルは使用するサーバに配置しておきます

下準備

  • oracle下にダウンロードしたzipファイルを置きます
mkdir -p redash/oracle/
cd redash

Dockerfileの作成

  • redashのDockerfileを修正してoracleを認識するのに必要な設定をします
Dockerfile
FROM redash/redash:latest

USER root

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 mkdir -p /opt/oracle/
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 /opt/oracle/
RUN unzip /tmp/instantclient-sdk-linux.x64-12.2.0.1.0.zip -d /opt/oracle/
RUN unzip /tmp/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip -d /opt/oracle/

RUN ln -s /opt/oracle/instantclient_12_2 /opt/oracle/instantclient
RUN ln -s /opt/oracle/instantclient/libclntsh.so.12.1 /opt/oracle/instantclient/libclntsh.so
RUN ln -s /opt/oracle/instantclient/sqlplus /usr/local/bin/sqlplus

RUN apt-get install libaio-dev -y
RUN apt-get clean -y

ENV ORACLE_HOME=/opt/oracle/instantclient
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/oracle/instantclient

RUN pip install cx_Oracle==5.2.1

#Add REDASH ENV to add Oracle Query Runner
ENV REDASH_ADDITIONAL_QUERY_RUNNERS=redash.query_runner.oracle

USER redash

docker imageの作成

  • buildしてイメージを作成します
docker build -f Dockerfile -t redash_oracle

docker-composeの作成

  • docker-compose.production.yml のserverとworkerのimageを上記で作成したものに修正します
  • 文字コードの部分は環境に合わせて修正してください
  • メールサーバも設定します
docker-compose.yml
version: '2'
services:
  server:
    image: redash_oracle
    command: server
    depends_on:
      - postgres
      - redis
    ports:
      - "5000:5000"
    environment:
      PYTHONUNBUFFERED: 0
      REDASH_LOG_LEVEL: "INFO"
      REDASH_REDIS_URL: "redis://redis:6379/0"
      REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
      REDASH_COOKIE_SECRET: veryverysecret
      REDASH_WEB_WORKERS: 4
      # mail関連の設定
      REDASH_MAIL_SERVER: "xxx.xxx"
      REDASH_MAIL_PORT: 25 
      REDASH_MAIL_DEFAULT_SENDER: "redash@xxxx.xxx"
      REDASH_HOST: ""
      # oracleの文字コード
      NLS_LANG: "JAPANESE_JAPAN.JA16SJISTILDE"
      NLS_DATE_FORMAT: "YYYY-MM-DD"
    restart: always
  worker:
    image: redash_oracle
    command: scheduler
    environment:
      PYTHONUNBUFFERED: 0
      REDASH_LOG_LEVEL: "INFO"
      REDASH_REDIS_URL: "redis://redis:6379/0"
      REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
      QUEUES: "queries,scheduled_queries,celery"
      WORKERS_COUNT: 2
      # mail関連の設定
      REDASH_MAIL_SERVER: "xxx.xxx"
      REDASH_MAIL_PORT: 25 
      REDASH_MAIL_DEFAULT_SENDER: "redash@xxxx.xxx"
      REDASH_HOST: ""
      # oracleの文字コード
      NLS_LANG: "JAPANESE_JAPAN.JA16SJISTILDE"
      NLS_DATE_FORMAT: "YYYY-MM-DD"
    restart: always
  redis:
    image: redis:3.0-alpine
    restart: always
  postgres:
    image: postgres:9.5.6-alpine
    # volumes:
    #   - /opt/postgres-data:/var/lib/postgresql/data
    restart: always
  nginx:
    image: redash/nginx:latest
    ports:
      - "80:80"
    depends_on:
      - server
    links:
      - server:redash
    restart: always

起動

docker-compose -f docker-compose.yml run --rm server create_db
docker-compose -f docker-compose.yml up -d
  • デフォルトでは80番ポートになっているので、アクセスすればユーザ作成画面になっています

参考

https://hub.docker.com/r/joaoleite/redash_oracle/~/dockerfile/
https://blog.bulkus.net/post/redash_oracle/

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした