Superset
1、安装
一、安装Python环境
-
第一步:下载Miniconda(Python3版本),(Miniconda3-latest-Linux-x86_64.sh),上传到服务器并运行
# 下载地址 https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh # 运行shell bash Miniconda3-latest-Linux-x86_64.sh
-
第二步:加载环境变量配置文件,使之生效
source ~/.bashrc
-
第三步:取消激活base环境
conda config --set auto_activate_base false
-
第四步:配置conda国内镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main conda config --set show_channel_urls yes
-
第五步:创建Python3.6环境
conda create --name superset python=3.6
-
第六步:激活superset环境
# 激活 conda activate superset # 退出当前环境 conda deactivate
二、Superset部署
-
第一步:安装依赖和更新
# 安装依赖 yum install -y python-setuptools yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel cyrus-sasl-devel openldap-devel # 更新依赖 pip install --upgrade setuptools pip -i https://pypi.douban.com/simple/
-
第二步:安装Superse
pip install apache-superset -i https://pypi.douban.com/simple/ pip install dataclasses pip install gunicorn -i https://pypi.douban.com/simple/
-
第三步:初始化Superset数据库
superset db upgrade
-
第四步:创建管理员用户
export FLASK_APP=superset flask fab create-admin
-
第五步:初始化Superset
superset init
三、启动Superset
启动(确保当前conda环境为superset)
# 确保当前conda环境为superset
conda activate superset
# --workers:指定进程个数
# --timeout:worker进程超时时间,超时会自动重启
# --bind:绑定本机地址,即为Superset访问地址
# --daemon:后台运行
gunicorn --workers 5 --timeout 120 --bind hadoop151:8787 "superset.app:create_app()" --daemon
# 访问地址
http://hadoop151:8787
停止
# 停止
ps -ef | awk '/superset/ && !/awk/{print $2}' | xargs kill -9
# 退出当前环境
conda deactivate
shell启动、停止 脚本
#!/bin/bash
superset_status(){
result=`ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | wc -l`
if [[ $result -eq 0 ]]; then
return 0
else
return 1
fi
}
superset_start(){
# 该段内容取自~/.bashrc,所用是进行conda初始化
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/software/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/software/miniconda3/etc/profile.d/conda.sh" ]; then
. "/opt/software/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/software/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
superset_status >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
conda activate superset ; gunicorn --workers 5 --timeout 120 --bind hadoop151:8787 --daemon 'superset.app:create_app()'
else
echo "superset正在运行"
fi
}
superset_stop(){
superset_status >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo "superset未在运行"
else
ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | xargs kill -9
fi
}
case $1 in
start )
echo "启动Superset"
superset_start
;;
stop )
echo "停止Superset"
superset_stop
;;
restart )
echo "重启Superset"
superset_stop
superset_start
;;
status )
superset_status >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo "superset未在运行"
else
echo "superset正在运行"
fi
esac