LoginSignup
7
1

More than 3 years have passed since last update.

Docker運用のRedashをv4からv7へバージョンアップした

Last updated at Posted at 2019-06-12

はじめに

Dockerで運用しているRedashをv4からv7へバージョンアップした時の手順になります。

前提情報

  • Docker運用のRedash
  • ホストOSはCentOS7
  • 対応前のRedashのバージョン:4.0.1
  • 対応後のRedashのバージョン:7.0.0

バージョンアップ手順

バックアップ

  • Postgresのバックアップを取得する

    $ docker exec -it redash_postgres_1 /bin/bash -c ‘pg_dump -U postgres 
    postgres | gzip > /tmp/redash_backup.gz’
    
    $ docker cp redash_postgres_1:/tmp/redash_backup.gz redash_backup.gz
    

バージョンアップ

  • Redashを停止する

    $ docker-compose -f docker-compose.production.yml down
    
  • docker-compose.production.ymlを更新する

    • 使用してるdocker-compose.production.ymlredash/setup/docker-compose.ymlを確認して修正する。
      • version7から docker-compose.production.ymlではなく docker-compose.ymlを使うらしいが、今回はそのままdocker-compose.production.ymlを使っている(バージョンアップ後に知りました。。)
    docker-compose.production.yml
    version: ‘2’
    x-redash-service: &redash-service
      image: redash/redash:7.0.0.b18042
      depends_on:
        - postgres
        - redis
      env_file: /opt/redash/env
      restart: always
    services:
      server:
        <<: *redash-service
        command: server
        ports:
          - “5000:5000”
        environment:
          REDASH_WEB_WORKERS: 4
      scheduler:
        <<: *redash-service
        command: scheduler
        environment:
          QUEUES: “celery”
          WORKERS_COUNT: 1
      scheduled_worker:
        <<: *redash-service
        command: worker
        environment:
          QUEUES: “scheduled_queries,schemas”
          WORKERS_COUNT: 1
      adhoc_worker:
        <<: *redash-service
        command: worker
        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の作成
      • v7からenvファイルを使うようになってる。
      • redash/setup/setup.shと使用してるdocker-compose.production.ymlの内容を元に作成する
    PYTHONUNBUFFERED=0
    REDASH_LOG_LEVEL=INFO
    REDASH_REDIS_URL=redis://redis:6379/0
    POSTGRES_PASSWORD=postgres
    REDASH_COOKIE_SECRET=veryverysecret
    REDASH_SECRET_KEY=veryverysecret
    REDASH_DATABASE_URL=postgresql://postgres:postgres@postgres/postgres
    HTTP_PROXY=http://proxy.hoge.jp:9999/ # Proxy環境下の場合
    
  • Redashの最新イメージを取得する

    $ docker pull redash/redash:latest
    
  • PostgresのBackupを読み込む

    # コンテナを起動する
    $ docker-compose up docker-compose.production.yml
    
    # postgre以外のコンテナを停止する
    $ docker-compose down redash_worker_1 redash_nginx_1 redash_server_1 redash_redis_1
    
    # バックアップをコンテナに渡す
    $ docker cp redash_backup.gz redash_postgres_1:/tmp/ redash_backup.gz
    
    $ docker exec -it redash_postgres_1 /bin/bash
    # psql -U postgres template1
    # DROP DATABASE IF EXISTS postgres;
    # CREATE DATABASE postgres;
    # \q
    
    # データ投入
    $ zcat /tmp/redash_backup.gz | psql -U postgres -d postgres
    $ exit
    
  • データベースのコンバート

    $ docker-compose -f docker-compose.production.yml run --rm server manage db upgrade
    

docker-composeを起動

$ docker-compose -f docker-compose.production.yml up -d

Redashの動作確認

  • versionが7に更新されてること
  • クエリが実行できること
    • 各データソース(MySQL, BigQuery etc)で確認すること
7
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
1