LoginSignup
9
4

More than 3 years have passed since last update.

Dockerで運用しているRedashをバージョンアップする

Last updated at Posted at 2018-05-11

会社でdocker-composeで運用しているRedashをv3.0からv4.0にバージョンアップをした時のメモです。

まず公式サイトのHow to Upgradeを見てみました。

Docker
If you’re using Docker to run Redash, don’t use the upgrade script, but rather update the >Docker image you’re using.

Dockerのアップデートについの記述はこれだけです(笑)

  1. Make sure to backup your data. You only need to backup Redash's PostgreSQL database (the database Redash stores metadata in, not the ones you might be querying) as the data in Redis is transient.
  2. Update /opt/redash/docker-compose.yml Redash image reference to the one you want to upgrade to.
  3. Stop Redash services: docker-compose stop server scheduler scheduled_worker adhoc_worker (you might need to list additional services if you updated your configuration)
  4. Apply migration (if necessary): docker-compose run --rm server manage db upgrade
  5. Start services: docker-compose up -d

redash本体については、dockerイメージを更新すれば良いのですが、DBのマイグレートが必要なはずなので、updateスクリプトを読んでみました。

updateスクリプトを読み解いていくと、この行
でやっている以下の処理をやってあげれば良さそうです。

    run("sudo -u redash bin/run ./manage.py db upgrade", cwd=version_path(release.version_name))

では、それを踏まえてバージョンアップしていきます。
まずは、dockerイメージを更新するため、docker-compose.ymlのバージョンを書き換えます。

services:
  server:
    image: redash/redash:4.0.1.b4038
 (省略)
  worker:
    image: redash/redash:4.0.1.b4038

この状態で先ほど調べたDBマイグレートを行います。そうするとRedashのDockerイメージが更新され、DBがマイグレートされます。

# docker-compose run --rm server manage db upgrade

Starting redash_postgres_1 ... done
Starting redash_redis_1    ... done
Pulling server (redash/redash:4.0.1.b4038)...
4.0.1.b4038: Pulling from redash/redash
Digest: sha256:57c34a4c8a0232b10fddbd1fbd28370cc9c761befea2871130b4304279ffebb4
Status: Downloaded newer image for redash/redash:4.0.1.b4038
[2018-05-11 03:35:26,974][PID:1][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[2018-05-11 03:35:27,002][PID:1][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
[2018-05-11 03:35:28,628][PID:1][INFO][root] Latest version: 4.0.1 (newer: False)
[2018-05-11 03:35:29,998][PID:1][INFO][alembic.runtime.migration] Context impl PostgresqlImpl.
[2018-05-11 03:35:29,998][PID:1][INFO][alembic.runtime.migration] Will assume transactional DDL.
[2018-05-11 03:35:30,020][PID:1][INFO][alembic.runtime.migration] Running upgrade d1eae8b9893e -> 7671dca4e604, empty message
[2018-05-11 03:35:30,040][PID:1][INFO][alembic.runtime.migration] Running upgrade 7671dca4e604 -> 5ec5c84ba61e, Add Query.search_vector field for full text search.
[2018-05-11 03:35:30,410][PID:1][INFO][alembic.runtime.migration] Running upgrade 5ec5c84ba61e -> 6b5be7e0a0ef, Re-index Query.search_vector with existing queries.
[2018-05-11 03:35:30,604][PID:1][INFO][alembic.runtime.migration] Running upgrade 6b5be7e0a0ef -> 969126bd800f, Update widget's position data based on dashboard layout.
Updating dashboards position data:
  Updating dashboard: 18
    Building widgets map:
    Widget: 80
    Widget: 81
    Iterating over layout:
      Row: 0 - [80, 81]
      Column: 0 - 80
      Column: 1 - 81
(途中省略)
  Updating dashboard: 6
    Building widgets map:
    Iterating over layout:
  Updating dashboard: 2
    Building widgets map:
    Iterating over layout:

あとはいつも通りredashを起動させれば完了です。古いコンテナは--remove-orphansで削除しました。

$ docker-compose up --remove-orphans
9
4
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
9
4