2021年6月22日 09:53 by wst
redashredash系列文章一:redash的安装。
这里采用docker安装,省时省力,步骤如下:
创建文件夹redashsetup, 放入redashenv.sh,docker-compose.yml。脚本内容见下文。
运行如下脚本(redashenv.sh)生成配置文件
#!/usr/bin/env bash
# This script setups dockerized Redash on Ubuntu 18.04.
set -eu
export POSTGRES_PASSWORD=XjGVGggWXHIRyOP5bOaVsPQ8AKunVsuX
mkdir -p /data/redash
mkdir -p /data/redash/postgres-data
REDASH_BASE_PATH=/data/redash
if [[ -e $REDASH_BASE_PATH/env ]]; then
rm $REDASH_BASE_PATH/env
touch $REDASH_BASE_PATH/env
fi
COOKIE_SECRET=$(pwgen -1s 32)
SECRET_KEY=$(pwgen -1s 32)
POSTGRES_PASSWORD=$(pwgen -1s 32)
REDASH_DATABASE_URL="postgresql://postgres:${POSTGRES_PASSWORD}@postgres/postgres"
echo "PYTHONUNBUFFERED=0" >> $REDASH_BASE_PATH/env
echo "REDASH_LOG_LEVEL=INFO" >> $REDASH_BASE_PATH/env
echo "REDASH_REDIS_URL=redis://redis:6379/0" >> $REDASH_BASE_PATH/env
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> $REDASH_BASE_PATH/env
echo "REDASH_COOKIE_SECRET=$COOKIE_SECRET" >> $REDASH_BASE_PATH/env
echo "REDASH_SECRET_KEY=$SECRET_KEY" >> $REDASH_BASE_PATH/env
echo "REDASH_DATABASE_URL=$REDASH_DATABASE_URL" >> $REDASH_BASE_PATH/env
之后会在/data/redash目录生成 env配置文件。
文件内容如下:
version: '2'
x-redash-service: &redash-service
image: redash/redash:10.0.0-beta.b49515
depends_on:
- postgres
- redis
env_file: /data/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: /data/redash/env
volumes:
- /data/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
1. 进入redashsetup文件夹,执行:
docker-compose up -d
2. 初始化数据库依赖:
docker-compose run --rm server create_db
这里生成的前端地址为:http://localhost/