系统相关
首页 > 系统相关> > centos7.6.1810最小安装(无附加项)部署redash-8.0.0

centos7.6.1810最小安装(无附加项)部署redash-8.0.0

作者:互联网

centos7.6.1810最小安装(无附加项)部署redash-8.0.0

[2020.05.07]

一、基础环境

网络配置

虚拟网卡配置
	1)使用NAT模式
	2)选中VMnet8,关闭“使用本地DHCP服务将IP地址分配给虚拟机”
	3)修改子网IP210.38.240.0、子网掩码255.255.255.0
	4)NAT设置,网关IP210.38.240.2
	5)修改物理机网络适配器VMnet8,IPv4配置IP210.38.240.1、子网掩码255.255.255.0
系统网卡配置
	vi /etc/sysconfig/network-scripts/ifcfg-ens33
	Modify:
		BOOTPROTO=dhcp => static
		ONBOOT=no => yes
	Add:
		IPADDR=210.38.240.5
		NETMASK=255.255.255.0
		GATEWAY=210.38.240.2
		DNS1=8.8.8.8
		DNS2=112.29.29.29
	systemctl restart network
	ping 210.38.240.2
	ping www.baidu.com
【至此可进行ping测试物理机和虚拟机的网络是否通,不通在确认上面服务后进行下面防火墙配置】

安装lrzsz

# yum安装lrzsz工具
yum -y install lrzsz
# 查看是否完成安装
rpm -qa|grep lrzsz
# 上传
rz
rz [-y 覆盖原文件]
# 下载
sz {file}
# xshell:Alt+P打开属性框,打开【文件传输】,这里可以调整传输的一些属性。下载文件,可以执行下载目录,下载文件时就不会再询问。上传文件,可以直接拖动文件到xshell上传

安装net-tools

# 安装后才可用ifconfig命令
yum install net-tools

安装wget

yum install wget

安装gcc

yum -y install gcc
yum -y install gcc-c++
# 安装gcc和gcc-c++后续才可make(使用源码编译部署需要)

二、主要环境

安装nodejs

# 此处选用node v12.4.0,低版本编译会导致npm自身报错npm ERR! cb()never called!
# 下载、解压、移动/重命名解压出的nodejs文件夹
wget https://npm.taobao.org/mirrors/node/v12.4.0/node-v12.4.0-linux-x64.tar.xz
tar -xvf node-v12.4.0-linux-x64.tar.xz
mv node-v12.4.0 /usr/local/nodejs

# 创建NODE_HOME环境变量,修改PATH环境变量加入NODE_HOME/bin部分
export NODE_HOME=/usr/local/nodejs
export PATH=$NODE_HOME/bin:$PATH
source /etc/profile

# 创建node、npm命令的软连接到/usr/bin目录
ln -s /usr/local/nodejs/bin/node /usr/bin/node
ln -s /usr/local/nodejs/bin/npm /usr/bin/npm
#此项可不操作 ln -s /usr/local/nodejs/bin/npx /usr/bin/npx

# 设置npm使用淘宝镜像
npm config set registry https://registry.npm.taobao.org

# 安装webpack、wenpack-cli并创建软连接到/usr/bin
npm install webpack -g
npm install webpack-cli -g
ln -s /usr/local/nodejs/bin/webpack /usr/bin/webpack

# redash的前端环境编译需要nodejs

安装python环境

# 安装pip前先安装epel扩展源:(EPEL(http://fedoraproject.org/wiki/EPEL) 是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。)
yum -y install epel-release

# 安装python-pip
yum install python-pip

# 安装python虚拟环境
yum install python-virtualenv

安装postgres

# redash官方要求postgresql-9.5及以上,此处使用了9.5版本(测试使用过9.3版本导致user功能无法使用)

# 访问https://www.postgresql.org/download/linux/redhat/,选择9.5,centos7(根据实际情况选择),后安装提示命令复制到centos中执行,如下:
# 安装仓库RPM
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# 安装客户端&服务端
yum install postgresql95
yum install postgresql95-server
# 初始化
/usr/pgsql-9.5/bin/postgresql95-setup initdb
systemctl enable postgresql-9.5
systemctl start postgresql-9.5

# 用刚安装的客户端测试刚安装的服务端(安装默认向系统增加用户postgres)
su - postgres
#进入客户端并自动连接本地服务端,从psql退出Ctrl+D
psql 

# 配置远程访问、初始密码
# 找到并修改postgresql.conf,不修改则导致远程连接被拒绝
find / -name postgresql.conf
vi postgresql.conf
# 修改内容:listen_address="localhost" --->>> listen_address="*"
# 修改后需要重启pg服务
systemctl restart postgresql-9.5

# 找到并修改pg_hba.conf,增加 
find / -name pg_hba.conf
vi pg_hba.conf
# 增加如下内容
host	all		all		0.0.0.0/0	trust
# 或:host	all		all		0.0.0.0/0	md5

# 修改默认密码(pg9.5版本无需操作此项,pg11需要)
su - postgres
psql
alter user postgres password 'xxxxxx' 

# 配置防火墙允许pg端口5432
firewall-cmd --zone=public --add-port=5432/tcp --permanent  
firewall-cmd --reload

# 创建目的数据库
su - postgres
createdb redash

安装redis

方式1:yum安装redis,找不到包则使用epel源

yum install -y redis
systemctl enable redis
systemctl start redis
# --------------------------------------------------
# 后续需要先执行【redis统一修改部分】
# --------------------------------------------------

方式2:编译安装redis

# 下载、解压、移动/重命名redis解压文件夹
cd /usr/local
wget http://download.redis.io/redis-stable.tar.gz
tar -xvf redis-stable.tar.gz 
mv redis-stable /redis
# 创建目录(必须先建目录,不建它不会自动建立目录导致后续make报错)
mkdir -p /usr/local/redis/bin
mkdir -p /usr/local/redis/etc
# 切换至redis根目录redis
make
# 进入redis\src
make install Prefix=/usr/local/redis  
# 复制redis.conf
cp redis/redis.conf /usr/local/redis/etc

# --------------------------------------------------
# 此处需要先执行【redis统一修改部分】
# --------------------------------------------------

# 手动启动redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf 

# 添加到服务,使用systemctl启动
#	方法1: ×失败 
    vi /etc/rc.local
        添加内容/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf      
#   方法2: √成功 
    vi /etc/systemd/system/redis.service
        # 添加以下内容
        [Unit]
        Description=Redis
        After=network.target
        [Service]
        Type=forking
        ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
        ExecStop=/usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown
        [Install]
        WantedBy=multi-user.target
    # 创建软连接到/etc/systemd/system/multi-user.target.wants
    ln -s /lib/systemd/system/redis.service /etc/systemd/system/multi-user.target.wants/redis.service
    # 重新加载服务配置文件,后即可将redis用systemctl启动
    systemctl daemon-reload
    systemctl start redis
    systemctl enable redis 
    # systemctl enable redis时如提示File exists先: systemctl disable redis,原因是已启用,其实已可不用disable
    # systemctl服务配置参考:
    https://my.oschina.net/yun7/blog/2872176
    https://blog.csdn.net/changqing1234/article/details/82882765
    https://www.cnblogs.com/wangxu01/articles/11015822.html
    https://blog.csdn.net/chwshuang/article/details/68489968

redis统一修改部分(上面两种方式安装完后均需要修改下列文件)

# redis统一修改部分(上面两种方式安装完后均需要修改下列文件)
vi redis.conf
# 设置任意地址可访问连接redis
# 修改内容:bind localhost --->>> bind 0.0.0.0 
# 设置后台启动
# 修改:daemonize no --->>> daemonize yes
# 配置防火墙开放6379端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --reload

安装supervisor(部署到系统时需要)

yum install supervisor
# 下面2行不操作,但在报相关错误时可以找到这两项做如下操作,目录位置不一定一致
chmod 777 /var/run/supervisor/supervisor.sock
chmod 777 /var/log/supervisor/supervisor.log

# supervisor常用命令
	# 指定配置文件启动
    supervisord -c /etc/supervisord.conf
    # 重启supervisor
    supervisorctl reload
    # 启动名字为django的program 
    supervisorctl start django
    # 停止名字为django的program 
    supervisorctl stop django
    # 查看名字为django的program 状态
    supervisorctl status django
    # 查看所有program的状态
    supervisorctl status all
    # 停止所有program
    supervisorctl stop all

安装docker(部署到docker时需要)

# 国外镜像一般很难访问,建议配置阿里云镜像。yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 安装必要的软件包
yum install -y yum-utils device-mapper-persistent-data lvm2
# 配置仓库
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 安装docker ce(此处默认选择最新的,也可查看yum list docker-ce --showduplicates | sort -r指定版本yum install docker-ce-17.12.0.ce)
yum install docker-ce
# 启动docker
systemctl start docker
# 设置自启动
systemctl enable docker

# 安装docker-compose
#    方式一: (官网方式)
    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
#    创建软链接,在其他目录也能使用docker-compose命令
    ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
#    方式二:
    pip install docker-compose
#    查看默认安装的最新版本信息
    docker-compose version

docker常用命令
    docker version 验证安装是否成功(有client和service两部分表示docker安装启动都成功了)
    docker ps 查看当前正在运行的容器
    docker ps -a 查看所有容器的状态
    docker start/stop id/name 启动/停止某个容器
    docker attach id 进入某个容器(使用exit退出后容器也跟着停止运行)
    docker exec -ti id 启动一个伪终端以交互式的方式进入某个容器(使用exit退出后容器不停止运行)
    docker images 查看本地镜像
    docker rm id/name 删除某个容器
    docker rmi id/name 删除某个镜像
    docker run --name test -ti ubuntu /bin/bash  复制ubuntu容器并且重命名为test且运行,然后以伪终端交互式方式进入容器,运行bash
    docker build -t soar/centos:7.1 .  通过当前目录下的Dockerfile创建一个名为soar/centos:7.1的镜像
    docker run -d -p 2222:22 --name test soar/centos:7.1  以镜像soar/centos:7.1创建名为test的容器,并以后台模式运行,并做端口映射到宿主机2222端口,P参数重启容器宿主机端口会发生改变

tips:

# 查询需要的命令xxx【例:mysql_config】由哪个安装包提供,pip安装时或其他安装时的依赖缺少可通过这个查询
yum provides xxx
yum search xxx

# 文件内容搜索
grep -rn "MatchChar" filename

# 检查进程是否启动
ps -ef|grep xxx

# 防火墙配置
# 查看防火墙状态
systemctl status firewalld
# 开启xxx端口
firefirewall-cmd --zone=public --add-port=xxx/tcp --permanent
# 重启防火墙:
firewall-cmd --reload

三、部署redash

方式1、部署到系统中

前端编译+后端python环境、依赖python库安装

# 下载、解压、移动/重命名redash
wget https://github.com/getredash/redash/archive/v8.0.0.tar.gz 
tar -xvf v8.0.0.tar.gz 
mv redash-8.0.0 /opt/redash
cd /opt/redash

# 前端
npm install 
# install提示npm自身问题报错的,可更新npm或重新安装node和npm
npm run build
# build生成的文件在client/dist,8.0.0的版本是生成在该位置

# 后端
# 修改redash/settings/__init__.py的postgresql、redis的连接和默认发件配置,其他配置可参考官网说明。另附示例文件
# 创建虚拟环境
mkdir /usr/local/virtualenvs  #预先建立文件夹,后续的虚拟环境都创建在这里面,可自行建在其他路径
python -m virtualenv /usr/loacl/virtualenvs/redash 
# 或:virtualenv -p /usr/bin/python2.7 /usr/local/virtualenvs/redash

# 进入上面创建的虚拟环境,并安装redash依赖的python库
source ./usr/local/virtualenvs/redash
pip install -r requirements.txt #需要在虚拟环境中
    #    运行前可以先yum安装的依赖的库:
    #        psycopg2==2.8.3 --->>> yum install -y postgresql-devel
pip install -r requirements_all_ds.txt #需要在虚拟环境中
    #    运行前可以先yum安装的依赖的库:
    #        mysqlclient==1.3.14 --->>> yum install -y mariadb-devel
    #    可跳过部分,如安装时有部份库超时或其他原因无法下载:
    #        td-client==1.0.0
    #        atsd_client==3.0.5
    #        pymapd==0.19.0
    #        pyexasol==0.12.0
    #        python-rapidjson==0.8.0
    #    安装后续可能出现的问题:
    #        pyodbc sql.h文件不存在的报错 --->>> yum install unixODBC-devel
    #        sasl/saslwrapper.h:22:23: fatal error: sasl/sasl.h: No such file or directory
    #            -- 解决办法:
    #            yum search sasl
    #            -- 安装:
    #            yum -y install cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib
    #	 其他文件缺失的问题也可以参照处理,版本不对的可以暂时注释掉,报错的查看是否缺失yum安装的环境,超时的可以暂时注释掉后续再在虚拟环境中手动单独安装

# 切换到redash目录
cd /usr/local/redash
# 验证测试
python ./manage.py check_settings  #需要在虚拟环境中
# 初始化数据库,创建数据库
python ./manage.py database create_tables #需要在虚拟环境中

# debug/run启动服务,可不执行的部分 #需要在虚拟环境中
# python ./manage.py runserver --debugger –reload –host=0.0.0.0  --->>> python ./manage.py runserver --debugger –reload –h 0.0.0.0
# python ./manage.py runserver –h 0.0.0.0 -p 5000
# python ./manage.py run –h 0.0.0.0 -p 5000

supervirsor配置

# 增加environemnt,python虚拟环境
# echo_supervisord_conf生成supervisord.conf模板
echo_supervisord_conf > /etc/supervisord.conf
vi /etc/supervisor.conf
; >>> supervisor.conf 内容如下,此项配置好后可以通过9001端口查看进程状态和实时日志,帐密在下列配置中有写
; Sample supervisor config file.

[unix_http_server]
file=/var/run/supervisor/supervisor.sock   ; (the path to the socket file)
;chmod=0700                 ; sockef file mode (default 0700)
;chown=nobody:nogroup       ; socket file uid:gid owner
;username=user              ; (default is no username (open server))
;password=123               ; (default is no password (open server))

[inet_http_server]         ; inet (TCP) server disabled by default
port=0.0.0.0:9001        ; (ip_address:port specifier, *:port for all iface)
username=user              ; (default is no username (open server))
password=123               ; (default is no password (open server))

[supervisord]
logfile=/var/log/supervisor/supervisord.log  ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10          ; (num of main logfile rotation backups;default 10)
loglevel=info               ; (log level;default info; others: debug,warn,trace)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false              ; (start in foreground if true;default false)
minfds=1024                 ; (min. avail startup file descriptors;default 1024)
minprocs=200                ; (min. avail process descriptors;default 200)
;umask=022                  ; (process file creation umask;default 022)
;user=chrism                 ; (default is current user, required if root)
;identifier=supervisor       ; (supervisord identifier, default is 'supervisor')
;directory=/tmp              ; (default is not to cd during start)
;nocleanup=true              ; (don't clean up tempfiles at start;default false)
;childlogdir=/tmp            ; ('AUTO' child log dir, default $TEMP)
;environment=KEY=value       ; (key value pairs to add to environment)
;strip_ansi=false            ; (strip ansi escape codes in logs; def. false)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL  for a unix socket
serverurl=http://0.0.0.0:9001 ; use an http:// url to specify an inet socket
username=user              ; should be same as http_username if set
password=123                ; should be same as http_password if set
;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history  ; use readline history if available

; The below sample program section shows all possible program subsection values,
; create one or more 'real' program: sections to be able to control them under
; supervisor.

;[program:theprogramname]
;command=/bin/cat              ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1                    ; number of processes copies to start (def 1)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=999                  ; the relative start priority (default 999)
;autostart=true                ; start at supervisord start (default: true)
;autorestart=true              ; retstart at unexpected quit (default: true)
;startsecs=10                  ; number of secs prog must stay running (def. 1)
;startretries=3                ; max # of serial start failures (default 3)
;exitcodes=0,2                 ; 'expected' exit codes for process (default 0,2)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;user=chrism                   ; setuid to this UNIX account to run the program
;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (default 10)
;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10     ; # of stderr logfile backups (default 10)
;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;environment=A=1,B=2           ; process environment additions (def no adds)
;serverurl=AUTO                ; override serverurl computation (childutils)

; The below sample eventlistener section shows all possible
; eventlistener subsection values, create one or more 'real'
; eventlistener: sections to be able to handle event notifications
; sent by supervisor.

;[eventlistener:theeventlistenername]
;command=/bin/eventlistener    ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1                    ; number of processes copies to start (def 1)
;events=EVENT                  ; event notif. types to subscribe to (req'd)
;buffer_size=10                ; event buffer queue size (default 10)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=-1                   ; the relative start priority (default -1)
;autostart=true                ; start at supervisord start (default: true)
;autorestart=unexpected        ; restart at unexpected quit (default: unexpected)
;startsecs=10                  ; number of secs prog must stay running (def. 1)
;startretries=3                ; max # of serial start failures (default 3)
;exitcodes=0,2                 ; 'expected' exit codes for process (default 0,2)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;user=chrism                   ; setuid to this UNIX account to run the program
;environment=PATH="/usr/local/virtualenvs/redash-8.0.0/bin:/sbin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/X11R6/bin"
#environment=PYTHONPATH=/usr/local/virtualenvs/redash-8.0.0/bin:%(ENV_PYTHONPATH)s,PATH=/usr/local/virtualenvs/redash-8.0.0/bin:%(ENV_PATH)s
#redirect_stderr=true          ; redirect proc stderr to stdout (default false)
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (default 10)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups        ; # of stderr logfile backups (default 10)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;environment=A=1,B=2           ; process environment additions
;serverurl=AUTO                ; override serverurl computation (childutils)

; The below sample group section shows all possible group values,
; create one or more 'real' group: sections to create "heterogeneous"
; process groups.

;[group:thegroupname]
;programs=progname1,progname2  ; each refers to 'x' in [program:x] definitions
;priority=999                  ; the relative start priority (default 999)

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = supervisord.d/*.ini
# 创建redash.ini文件
vi /etc/supervisor.d/redash.ini
# >>> redash.ini 内容如下
[group:redash]
programs=redash_server,redash_celery,redash_celery_scheduled

[program:redash_server]
environment=PYTHONPATH=/usr/local/virtualenvs/redash/bin,PATH=/usr/local/virtualenvs/redash/bin:%(ENV_PATH)s
command=/opt/redash/bin/run gunicorn -b 0.0.0.0:5000 --name redash -w 4 --max-requests 1000 redash.wsgi:app
directory=/opt/redash
process_name=redash_server
user=root
numprocs=1
autostart=true
autorestart=true
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /opt/redash/logs/redash_server_stdout.log

# There are two queue types here: one for ad-hoc queries, and one for the refresh of scheduled queries
# (note that "scheduled_queries" appears only in the queue list of "redash_celery_scheduled").
# The default concurrency level for each is 2 (-c2), you can increase based on your machine's resources.

[program:redash_celery]
environment=PYTHONPATH=/usr/local/virtualenvs/redash/bin,PATH=/usr/local/virtualenvs/redash/bin:%(ENV_PATH)s
command=/opt/redash/bin/run celery worker --app=redash.worker --beat -c2 -Qqueries,celery --maxtasksperchild=10 -Ofair
directory=/opt/redash
process_name=redash_celery
user=root
numprocs=1
autostart=true
autorestart=true
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /opt/redash/logs/redash_celery_stdout.log

[program:redash_celery_scheduled]
environment=PYTHONPATH=/usr/local/virtualenvs/redash/bin,PATH=/usr/local/virtualenvs/redash/bin:%(ENV_PATH)s
command=/opt/redash/bin/run celery worker --app=redash.worker -c2 -Qscheduled_queries --maxtasksperchild=10 -Ofair
directory=/opt/redash
process_name=redash_celery_scheduled
user=root
numprocs=1
autostart=true
autorestart=true
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /opt/redash/logs/redash_celery_scheduled_stdout.log
# 启动,如启动有问题可systemctl status supervisord\supervisorctl status all\tail -f /opt/redash/中的日志文件查看原因
systemctl start supervisord
# 开机自启
systemctl enable supervisord

方式2、部署到docker中

前端编译

# 下载、解压、移动/重命名redash
wget https://github.com/getredash/redash/archive/v8.0.0.tar.gz 
tar -xvf v8.0.0.tar.gz 
mv redash-8.0.0 /opt/redash
cd /opt/redash

# 前端
npm install 
# install提示npm自身问题报错的,可更新npm或重新安装node和npm
npm run build
# build生成的文件在client/dist,8.0.0的版本是生成在该位置

在redash根目录下创建env文件

>>> env 文件内容,其中的内容在部署时会作用替换redash/settings/__init__.py的对应参数的内容
REDASH_REDIS_URL=redis://210.38.240.6:6379/0
REDASH_DATABASE_URL=postgresql://postgres:postgres@210.38.240.6/redash
REDASH_MAIL_SERVER=smtp.163.com
REDASH_MAIL_PORT=465
REDASH_MAIL_USE_TLS=FALSE
REDASH_MAIL_USE_SSL=TRUE
REDASH_MAIL_USERNAME=gss@163.com
REDASH_MAIL_PASSWORD=mailpasswd
REDASH_MAIL_DEFAULT_SENDER=gss@163.com
REDASH_MAIL_MAX_EMAILS=None
REDASH_MAIL_ASCII_ATTACHMENTS=FALSE

修改redash/setup/docker-compose.yml文件

# >>> redash/setup/docker-compose.yml 文件内容,由于需要采用外部数据库,所以注释了postgres的依赖和镜像安装(redis、nginx可以不注释,此处因当时不太会用docker和nginx,先注释了)
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/setup 
# 初始化系统数据
docker-compose run --rm server create_db
# 安装镜像
docker-compose up
# 或docker-compose up > imageInstall.log 2>&1,将输出记录到日志。再通过另一终端tail -f /opt/redash/setup/imageInstall.log实时查看

# 测试邮件发送
docker exec -it redash_server_1 python manage.py send_test_mail

其他

# 使用/opt/redash/docker-compose.yml也可部署测试环境,且不需要配env文件,env的内容可以写在yml文件中
server:
    environment:
下添加以下内容:
		REDASH_MAIL_SERVER: "smtp.xxx.com"
		REDASH_MAIL_PORT: xx
		REDASH_MAIL_USE_TLS: "false"
		REDASH_MAIL_USE_SSL: "false"
		REDASH_MAIL_USERNAME: "xxx@xx.com"
		REDASH_MAIL_PASSWORD: "xx"
		REDASH_MAIL_DEFAULT_SENDER: "xxx@xx.com"	
		server:
    image: redash/redash:latest
    environment:
      ...
      #邮箱 
      REDASH_MAIL_SERVER: "smtp.exmail.qq.com"
      REDASH_MAIL_PORT: 465
      REDASH_MAIL_USE_TLS: "false"
      REDASH_MAIL_USE_SSL: "false"
      REDASH_MAIL_USERNAME: "gss@qq.com"
      REDASH_MAIL_PASSWORD: "gss"
      REDASH_MAIL_DEFAULT_SENDER: "gss@qq.com"
  
	  REDASH_MAIL_SERVER: "smtp.163.com"
      REDASH_MAIL_PORT: 465
      REDASH_MAIL_USE_TLS: "false"
      REDASH_MAIL_USE_SSL: "true"
      REDASH_MAIL_USERNAME: "gss@163.com"
      REDASH_MAIL_PASSWORD: "mailpasswd"
      REDASH_MAIL_DEFAULT_SENDER: "gss@163.com"
测试是否配置成功:
docker exec -it redash_server_1 python manage.py send_test_mail

附:问题

1、德龙centos7.7 npm install 报npm自身的cb()错误,且重装也无效

docker
1、docker安装了容器后再手动修改配置使用外部数据库
2、当前使用docker进行生产部署无法进入查询创建页面

调试
1、vscode远程调试服务器上的python程序

nginx
1、反向代理需要关闭selinux才起作用的问题

统一认证
1、LDAP统一认证

标签:bin,8.0,1810,default,redis,usr,docker,redash
来源: https://www.cnblogs.com/hbibighead/p/12852418.html