redash安装教程 使用构建Docker镜像的方式搭建redash服务
尝试过使用以 docker-compose.production.yml 为核心拉取已构建好的redash服务镜像,但服务正常启动后,出现sql查询没有任何响应的问题,暂时没有找到解决办法。索性不再使用已有镜像,改用redash官方资源包自己构建镜像,目前使用一切正常。网上资源较少,踩了不少坑,这里整合出来分享给大家。1. 前置环境dockerdocker-composenodejs...
尝试过使用以
docker-compose.production.yml
为核心拉取已构建好的redash服务镜像,但服务正常启动后,出现sql查询没有任何响应的问题,暂时没有找到解决办法。索性不再使用已有镜像,改用redash官方资源包自己构建镜像,目前使用一切正常。网上资源较少,踩了不少坑,这里整合出来分享给大家。
1. 前置环境
- docker
- docker-compose
- nodejs
由于本文使用了较新的redash版本(7.0.0),其Dockerfile需要支持 FROM as
以及 COPY --from
等语法,所以需要替换较新Docker版本,否则在创建redash服务镜像步骤时会出错
[root@instance-j69t4n5q bin]# docker --version
Docker version 18.06.3-ce, build d7080c1
以上为必要环境,这里不细说了
2. 获取redash资源包
打开 https://version.redash.io/API/releases
// https://version.redash.io/API/releases
[
{
"id": 37,
"version": "7.0.0",
"channel": "stable",
"download_url": "https://s3.amazonaws.com/redash-releases/redash.7.0.0.b17535.tar.gz",
"backward_compatible": false,
"released_at": "2019-03-17T00:00:00.000Z",
"description": "**Please read the following before upgrading:**\n\n1. If you're using the tarball deployment and not Docker, you might need to manually update some of the dependencies. Compare your current Python dependencies with the ones in the `requirements*.txt` files.\n\n2. This release adds encryption of your data sources configuration. By default it will use the `REDASH_COOKIE_SECRET` as encryption key. But we recommend setting a new key for it using the `REDASH_SECRET_KEY` environment variable. Note that you need to set this **before running migrations**. Otherwise everything will be encrypted with `REDSAH_COOKIE_SECRET`.\n\n---\n\n* Before doing an upgrade, please make sure you have a backup.\n* If you have any issues, please refer to the troubleshooting section in the upgrade guide:\n https://redash.io/help/open-source/admin-guide/how-to-upgrade\n* If the upgrade guide doesn't help, you can ask for help on the forum (https://discuss.redash.io).\n\nFull CHANGELOG for this release: https://github.com/getredash/redash/blob/master/CHANGELOG.md",
"docker_image": "redash/redash:7.0.0.b18042"
},
{
"id": 35,
"version": "6.0.0",
"channel": "stable",
"download_url": "https://s3.amazonaws.com/redash-releases/redash.6.0.0.b8536.tar.gz",
"backward_compatible": false,
"released_at": "2018-12-17T00:00:00.000Z",
"description": "***IMPORTANT: make sure to clear out the Celery queue before upgrading.***\n\n* Before doing an upgrade, please make sure you have a backup.\n* If you have any issues, please refer to the troubleshooting section in the upgrade guide:\n https://redash.io/help/open-source/admin-guide/how-to-upgrade\n* If the upgrade guide doesn't help, you can ask for help on the forum (https://discuss.redash.io).\n\nFull CHANGELOG for this release: https://github.com/getredash/redash/blob/master/CHANGELOG.md",
"docker_image": "redash/redash:6.0.0.b8537"
},
...
这里选择7.0.0版本,根据 download_url 下载资源包
wget https://s3.amazonaws.com/redash-releases/redash.7.0.0.b17535.tar.gz
下载完成
[root@instance-j69t4n5q ~]# ll
total 9572
-rw-r--r-- 1 root root 9798216 May 8 15:16 redash.7.0.0.b17535.tar.gz
解压,进入目录
[root@instance-j69t4n5q ~]# mkdir /usr/local/redash
[root@instance-j69t4n5q ~]# tar -zxf redash.7.0.0.b17535.tar.gz -C /usr/local/redash/
[root@instance-j69t4n5q ~]# cd /usr/local/redash/
[root@instance-j69t4n5q redash]# ll
total 872
drwxr-xr-x 2 3434 3434 4096 Mar 18 18:34 bin
-rw-r--r-- 1 3434 3434 71151 Mar 18 18:34 CHANGELOG.md
drwxr-xr-x 4 3434 3434 4096 Mar 18 18:38 client
-rw-r--r-- 1 3434 3434 4626 Mar 18 18:34 CONTRIBUTING.md
-rw-r--r-- 1 3434 3434 59 Mar 18 18:34 cypress.json
-rw-r--r-- 1 3434 3434 1405 Mar 18 18:34 docker-compose.yml
-rw-r--r-- 1 3434 3434 814 Mar 18 18:34 Dockerfile
-rw-r--r-- 1 3434 3434 1320 Mar 18 18:34 LICENSE
-rw-r--r-- 1 3434 3434 1231 Mar 18 18:34 Makefile
-rwxr-xr-x 1 3434 3434 126 Mar 18 18:34 manage.py
drwxr-xr-x 3 3434 3434 4096 Mar 18 18:34 migrations
-rw-r--r-- 1 3434 3434 771 Mar 18 18:34 netlify.toml
-rw-r--r-- 1 3434 3434 5080 Mar 18 18:34 package.json
-rw-r--r-- 1 3434 3434 709560 Mar 18 18:35 package-lock.json
-rw-r--r-- 1 3434 3434 58 Mar 18 18:34 pytest.ini
-rw-r--r-- 1 3434 3434 3235 Mar 18 18:34 README.md
drwxr-xr-x 13 3434 3434 4096 Mar 18 18:35 redash
-rw-r--r-- 1 3434 3434 588 Mar 18 18:34 requirements_all_ds.txt
-rw-r--r-- 1 3434 3434 275 Mar 18 18:34 requirements_dev.txt
-rw-r--r-- 1 3434 3434 187 Mar 18 18:34 requirements_oracle_ds.txt
-rw-r--r-- 1 3434 3434 1517 Mar 18 18:34 requirements.txt
drwxr-xr-x 2 3434 3434 4096 Mar 18 18:34 setup
-rw-r--r-- 1 3434 3434 88 Mar 18 18:34 setup.cfg
drwxr-xr-x 7 3434 3434 4096 Mar 18 18:34 tests
-rw-r--r-- 1 3434 3434 6060 Mar 18 18:34 webpack.config.js
3. 启动redash库表服务
docker-compose -f docker-compose.yml run --rm server create_db
4. 创建redash服务镜像,并启动
[root@instance-j69t4n5q redash]# pwd
/usr/local/redash
[root@instance-j69t4n5q redash]# docker-compose up
...
这需要等待一段时间
DBAccessError: (13, 'Permission denied')
提示权限异常,修改目录读写权限
chmod o+w /usr/local/redash/
重新创建服务
docker-compose up
5. 至此redash已经安装完成
[root@VM_32_167_centos redash.7.0.0]# docker-compose up
...
worker_1 | [tasks]
worker_1 | . redash.tasks.check_alerts_for_query
worker_1 | . redash.tasks.cleanup_query_results
worker_1 | . redash.tasks.execute_query
worker_1 | . redash.tasks.record_event
worker_1 | . redash.tasks.refresh_queries
worker_1 | . redash.tasks.refresh_schema
worker_1 | . redash.tasks.refresh_schemas
worker_1 | . redash.tasks.send_mail
worker_1 | . redash.tasks.subscribe
worker_1 | . redash.tasks.sync_user_details
worker_1 | . redash.tasks.version_check
worker_1 |
worker_1 | [2019-05-08 14:11:17,868][PID:110][INFO][Beat] beat: Starting...
worker_1 | [2019-05-08 14:11:18,038][PID:1][INFO][MainProcess] Connected to redis://redis:6379/0
worker_1 | [2019-05-08 14:11:18,045][PID:1][INFO][MainProcess] mingle: searching for neighbors
server_1 | [2019-05-08 14:11:18,462][PID:111][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
server_1 | [2019-05-08 14:11:18,481][PID:111][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
worker_1 | [2019-05-08 14:11:19,058][PID:1][INFO][MainProcess] mingle: all alone
worker_1 | [2019-05-08 14:11:19,067][PID:1][INFO][MainProcess] celery@bae098efb35e ready.
server_1 | [2019-05-08 14:11:20,156][PID:111][WARNING][werkzeug] * Debugger is active!
server_1 | [2019-05-08 14:11:20,156][PID:111][INFO][werkzeug] * Debugger pin code: 543-027-435
使用 docker-compose up -d
将服务启动在docker后台
打开 ip:5000
访问页面
放在最后,部分异常问题
Dockerfile执行异常
Building server
Step 1/17 : FROM node:10 as frontend-builder
ERROR: Service 'server' failed to build: Error parsing reference: "node:10 as frontend-builder" is not a valid repository/tag: invalid reference format
由于Dockerfile使用了 FROM <image> [AS <name>]
语法,低版本docker并不支持,需要切换到更高版本docker
npm ERR!
Killed
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! redash-client@7.0.0 build: `npm run clean && NODE_ENV=production node --max-old-space-size=4096 node_modules/.bin/webpack`
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the redash-client@7.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-05-08T10_13_03_023Z-debug.log
ERROR: Service 'server' failed to build: The command '/bin/sh -c npm run build' returned a non-zero code: 137
内存不足,需要预留3-4GB
缺少文件
No such file or directory: '/app/redash/settings/../../client/dist/index.html
这是由于搭建redash镜像需要使用资源包,而非 git clone
下来的源码,替换为资源包即可
缺少库表
postgres_1 | FROM queries LEFT OUTER JOIN query_results AS query_results_1 ON query_results_1.id = queries.latest_query_data_id
postgres_1 | WHERE queries.schedule IS NOT NULL ORDER BY queries.id
worker_1 | [2019-05-08 14:00:54,659][PID:111][ERROR][ForkPoolWorker-2] Task redash.tasks.refresh_queries[1720a74a-2dfc-4e2e-a8ea-32f69493e542] raised unexpected: ProgrammingError('(psycopg2.ProgrammingError) relation "queries" does not exist\nLINE 2: FROM queries LEFT OUTER JOIN query_results AS query_results_...\n ^\n',)
worker_1 | Traceback (most recent call last):
worker_1 | File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 382, in trace_task
worker_1 | R = retval = fun(*args, **kwargs)
worker_1 | File "/app/redash/worker.py", line 64, in __call__
worker_1 | return TaskBase.__call__(self, *args, **kwargs)
worker_1 | File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 641, in __protected_call__
worker_1 | return self.run(*args, **kwargs)
worker_1 | File "/app/redash/tasks/queries.py", line 171, in refresh_queries
worker_1 | for query in models.Query.outdated_queries():
worker_1 | File "/app/redash/models/__init__.py", line 562, in outdated_queries
worker_1 | for query in queries:
worker_1 | File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2995, in __iter__
worker_1 | return self._execute_and_instances(context)
worker_1 | File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 3018, in _execute_and_instances
worker_1 | result = conn.execute(querycontext.statement, self._params)
worker_1 | File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 948, in execute
worker_1 | return meth(self, multiparams, params)
worker_1 | File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
worker_1 | return connection._execute_clauseelement(self, multiparams, params)
worker_1 | File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
worker_1 | compiled_sql, distilled_params
worker_1 | File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
worker_1 | context)
worker_1 | File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
worker_1 | exc_info
worker_1 | File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 265, in raise_from_cause
worker_1 | reraise(type(exception), exception, tb=exc_tb, cause=cause)
worker_1 | File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
worker_1 | context)
worker_1 | File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 509, in do_execute
worker_1 | cursor.execute(statement, parameters)
worker_1 | ProgrammingError: (psycopg2.ProgrammingError) relation "queries" does not exist
worker_1 | LINE 2: FROM queries LEFT OUTER JOIN query_results AS query_results_...
worker_1 | ^
worker_1 | [SQL: 'SELECT queries.query AS queries_query, queries.updated_at AS queries_updated_at, queries.created_at AS queries_created_at, queries.id AS queries_id, queries.version AS queries_version, queries.org_id AS queries_org_id, queries.data_source_id AS queries_data_source_id, queries.latest_query_data_id AS queries_latest_query_data_id, queries.name AS queries_name, queries.description AS queries_description, queries.query_hash AS queries_query_hash, queries.api_key AS queries_api_key, queries.user_id AS queries_user_id, queries.last_modified_by_id AS queries_last_modified_by_id, queries.is_archived AS queries_is_archived, queries.is_draft AS queries_is_draft, queries.schedule AS queries_schedule, queries.schedule_failures AS queries_schedule_failures, queries.options AS queries_options, queries.search_vector AS queries_search_vector, queries.tags AS queries_tags, query_results_1.id AS query_results_1_id, query_results_1.retrieved_at AS query_results_1_retrieved_at \nFROM queries LEFT OUTER JOIN query_results AS query_results_1 ON query_results_1.id = queries.latest_query_data_id \nWHERE queries.schedule IS NOT NULL ORDER BY queries.id'] (Background on this error at: http://sqlalche.me/e/f405)
redash缺失所需库表服务。启动库表服务即可。
更多推荐
所有评论(0)