Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
11
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

@sutoh

Redash で Oracle 接続の Docker を作ってみた

Oracle だらけの環境の皆さんへ

Docker Compose Install

※ docker はInstall済み

$ uname -r
3.10.0-327.el7.x86_64
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ sudo curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
$ docker-compose --version
docker-compose version 1.9.0, build 2585387
$ sudo usermod -aG docker ${USER}
# コンソール再起動

Redash Install

$ git clone https://github.com/getredash/redash
$ cd redash
$ mkdir oracle
# Oracle Instance Download
# Oracle でログインしたCookieを持ってくる
$ curl --location --cookie ./cookies.txt --insecure "http://download.oracle.com/otn/linux/instantclient/11204/instantclient-basic-linux.x64-11.2.0.4.0.zip" -o instantclient-basic-linux.x64-11.2.0.4.0.zip
$ curl --location --cookie ./cookies.txt --insecure "http://download.oracle.com/otn/linux/instantclient/11204/instantclient-jdbc-linux.x64-11.2.0.4.0.zip" -o instantclient-jdbc-linux.x64-11.2.0.4.0.zip
$ curl --location --cookie ./cookies.txt --insecure "http://download.oracle.com/otn/linux/instantclient/11204/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip" -o instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
$ curl --location --cookie ./cookies.txt --insecure "http://download.oracle.com/otn/linux/instantclient/11204/instantclient-sdk-linux.x64-11.2.0.4.0.zip" -o instantclient-sdk-linux.x64-11.2.0.4.0.zip
$ curl --location --cookie ./cookies.txt --insecure "http://download.oracle.com/otn/linux/instantclient/11204/instantclient-odbc-linux.x64-11.2.0.4.0.zip" -o instantclient-odbc-linux.x64-11.2.0.4.0.zip
$ cd ../
$ vi Dockerfile-redash
Dockerfile-redash
FROM redash/redash:latest

# Oracle instantclient
ADD oracle/instantclient-basic-linux.x64-11.2.0.4.0.zip /tmp/instantclient-basic-linux.x64-11.2.0.4.0.zip
ADD oracle/instantclient-sdk-linux.x64-11.2.0.4.0.zip /tmp/instantclient-sdk-linux.x64-11.2.0.4.0.zip
ADD oracle/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip /tmp/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
ADD oracle/instantclient-odbc-linux.x64-11.2.0.4.0.zip /tmp/instantclient-odbc-linux.x64-11.2.0.4.0.zip
ADD oracle/instantclient-jdbc-linux.x64-11.2.0.4.0.zip /tmp/instantclient-jdbc-linux.x64-11.2.0.4.0.zip
ADD oracle/tnsnames.ora /tmp/tnsnames.ora

RUN mkdir -p /opt/oracle/
RUN apt-get update  -y
RUN apt-get install -y unzip

RUN unzip /tmp/instantclient-basic-linux.x64-11.2.0.4.0.zip -d /opt/oracle/
RUN unzip /tmp/instantclient-sdk-linux.x64-11.2.0.4.0.zip -d /opt/oracle/
RUN unzip /tmp/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip -d /opt/oracle/
RUN unzip /tmp/instantclient-odbc-linux.x64-11.2.0.4.0.zip -d /opt/oracle/
RUN unzip /tmp/instantclient-jdbc-linux.x64-11.2.0.4.0.zip -d /opt/oracle/

RUN ln -s /opt/oracle/instantclient_11_2 /opt/oracle/instantclient
RUN ln -s /opt/oracle/instantclient/libclntsh.so.11.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
ENV TNS_ADMIN=$ORACLE_HOME/network/admin
RUN mkdir -p /opt/oracle/instantclient/network/admin
RUN cp /tmp/tnsnames.ora /opt/oracle/instantclient/network/admin/

RUN pip install cx_Oracle

#Add REDASH ENV to add Oracle Query Runner
ENV REDASH_ADDITIONAL_QUERY_RUNNERS=redash.query_runner.oracle
$ cp docker-compose-example.yml docker-compose.yml
$ vi docker-compose.yml
docker-compose.yml
redash:
#  image: redash/redash:latest
  build: .
  dockerfile: Dockerfile-redash
  ports:
    - "5000:5000"
    - "1555:1555" # Oracle用ポート追加
  links:
    - redis
    - postgres
  environment:
    REDASH_LOG_LEVEL: "INFO"
    REDASH_REDIS_URL: "redis://redis:6379/0"
    REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
    REDASH_COOKIE_SECRET: veryverysecret
redis:
  image: redis:2.8
postgres:
  image: postgres:9.3
  volumes:
    - /opt/postgres-data:/var/lib/postgresql/data
redash-nginx:
  image: redash/nginx:latest
  ports:
    - "80:80"
  links:
    - redash

$ docker-compose up postgres
# Ctrl+C
$ ./setup/docker/create_database.sh
$ docker-compose up -d

良き Redash Life を

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
11
Help us understand the problem. What are the problem?