Redash详细Docker部署教程

Redash详细部署教程
1、安装Docker-CE
1.1、安装步骤

Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。

Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本。

#检测Linux版本 命令:uname -r
[root@mongodb-salve ~]# uname -r
3.10.0-693.2.2.el7.x86_64

#安装系统依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2

#添加软件源信息
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

#更新yum缓存
sudo yum makecache fast

#查看所有docker版本
#yum list docker-ce --showduplicates | sort -r

#安装Docker-ce
sudo yum -y install docker-ce

#启动 Docker 后台服务
sudo systemctl start docker

#设置开机启动
sudo systemctl enable docker

#安装检测 当提示安装的版本号就已经标示安装完成
[root@mongodb-salve ~]# docker --version
Docker version 18.09.6, build 481bc77156
#或
[root@mongodb-salve ~]# docker version
Client:
Version: 18.09.6
API version: 1.39
Go version: go1.10.8
Git commit: 481bc77156
Built: Sat May 4 02:34:58 2019
OS/Arch: linux/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 18.09.6
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: 481bc77
Built: Sat May 4 02:02:43 2019
OS/Arch: linux/amd64
Experimental: false

1.2、卸载Docker-CE

sudo yum remove docker-ce
sudo rm -rf /var/lib/docker

注:移除旧版本Docker

sudo yum remove docker
docker-client
docker-client-latest
docker-common
docker-latest
docker-latest-logrotate
docker-logrotate
docker-selinux
docker-engine-selinux
docker-engine

1.3、镜像加速

鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,我们可以需要配置加速器来解决,我使用的是网易的镜像地址:http://hub-mirror.c.163.com。(或者使用其他的镜像)

新版的 Docker 使用 /etc/docker/daemon.json(Linux) 或者 %programdata%\docker\config\daemon.json(Windows) 来配置 Daemon。

请在该配置文件中加入(没有该文件的话,请先建一个):

{
“registry-mirrors”: [“http://hub-mirror.c.163.com”]
}

1.4、常见错误

不能正常使用命令,报错信息如下

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 

解决:检测Docker服务是否启动,是否需要超级管理员权限

2、安装Docker-compose

安装方式(二进制文件)

#下载最新版的docker-compose文件 github地址:https://github.com/docker/compose/releases
curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-uname -s-uname -m -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

#添加可执行权限
sudo chmod +x /usr/local/bin/docker-compose

#测试安装结果
docker-compose --version
docker-compose version 1.24.0, build 0aa59064

删除方式

#直接删除二进制文件
sudo rm -rf /usr/local/bin/docker-compose

注:另一种方式请自行百度,这里不做过多介绍

3、安装Redash

Redash介绍

​ 此处省略一万字

安装过程

#从GitHub下载源码
git clone https://github.com/getredash/redash.git

#进入redash目录
cd redash

#创建docker-compose.production.yml文件,内容参考yml配置
touch docker-compose.production.yml


#创建db
docker-compose -f docker-compose.production.yml run --rm server create_db
 
#Starting redash_redis_1
#Starting redash_postgres_1
#[2019-06-11 09:02:39,580][PID:1][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
#[2019-06-11 09:02:39,601][PID:1][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
#[2019-06-11 09:02:41,707][PID:1][INFO][alembic.runtime.migration] Context impl PostgresqlImpl.
#[2019-06-11 09:02:41,708][PID:1][INFO][alembic.runtime.migration] Will assume transactional DDL.
#[2019-06-11 09:02:41,724][PID:1][INFO][alembic.runtime.migration] Running stamp_revision -> 969126bd800f
 
#redash运行
docker-compose -f docker-compose.production.yml up
#redash运行后台运行
docker-compose -f docker-compose.production.yml up -d


#如果配置邮箱预警可用以下命令检测 可以接受到邮件,如有问题可检测你的邮件配置
docker exec -it redash_server_1 python manage.py send_test_mail

docker-compose.production.yml(注意用yml的编写格式)

# This is an example configuration for Docker Compose. Make sure to atleast update
# the cookie secret & postgres database password.
#
# Some other recommendations:
# 1. To persist Postgres data, assign it a volume host location.
# 2. Split the worker service to adhoc workers and scheduled queries workers.
version: '2'
services:
  server:
    image: redash/redash:6.0.0.b8537
    command: server
    depends_on:
      - postgres
      - redis
    ports:
      - "5000:5000"
    environment:
      PYTHONUNBUFFERED: 0
      REDASH_LOG_LEVEL: "INFO"
      REDASH_REDIS_URL: "redis://redis:6379/0"
      REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
      REDASH_COOKIE_SECRET: "yongzheng"
      REDASH_WEB_WORKERS: 4   
      #邮箱 
      REDASH_MAIL_SERVER: "smtp.exmail.qq.com"
      REDASH_MAIL_PORT: 465
      REDASH_MAIL_USE_TLS: "true"
      REDASH_MAIL_USE_SSL: "true"
      REDASH_MAIL_USERNAME: "[email protected]"
      REDASH_MAIL_PASSWORD: "yongzheng"
      REDASH_MAIL_DEFAULT_SENDER: "[email protected]"
      REDASH_HOST: "http://192.168.3.110:88"
    restart: always
  worker:
    image: redash/redash:6.0.0.b8537
    command: scheduler
    environment:
      PYTHONUNBUFFERED: 0
      REDASH_LOG_LEVEL: "INFO"
      REDASH_REDIS_URL: "redis://redis:6379/0"
      REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
      QUEUES: "queries,scheduled_queries,celery"
      WORKERS_COUNT: 2
    restart: always
  redis:
    image: redis:3.0-alpine
    ports:
     - "6379:6379"
    volumes: 
      - ./data/redis_data:/data
    restart: always
  postgres:
    image: postgres:9.5.6-alpine
    ports:
     - "5432:5432"
    volumes:
      - ./data/postgresql_data:/var/lib/postgresql/data
    restart: always
  nginx:
    image: redash/nginx:latest
    ports:
      - "88:80"
    volumes:
      - ./data/nginx:/etc/nginx
    #depends_on:
    #  - server
    links:
      - server:redash
    restart: always

注:Redash的版本请勿使用latest,否则则会query查询不出。

​ 网上很多教程都是使用latest版本,但是文章写得

4、使用介绍

使用请自行找度娘

你可能感兴趣的:(Docker)