superset安装教程
首先依赖安装
yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel
- 官网下载Anconda https://www.anaconda.com/products/distribution#Downloads
- 安装
sh Anaconda3-2022.10-Linux-x86_64.sh - 环境配置
在 /etc/profile中加入以下语句:
export PATH=$PATH:/root/anaconda3/bin
source /etc/profile
- 安装python3.6环境
conda create -n python36 python=3.6
- 激活python环境
conda activate python36【激活使用python36环境,需要先执行下】
source activate 【初始化conda,必须执行,执行之后可以使用conda命令激活环境】
conda deactivate 【退出当前base环境】
conda activate python36【激活使用python36环境】
conda deactivate 【退出当前使用python36环境】
conda remove -n python36 --all 【删除python36环境】
- 安装supserset
注意在这个地方
(python36) [root@localhost ~]#
pip install apache-superset==0.37.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
superset db upgrade
注意:如果在安装初始化过程中出现“ImportError: cannot import name ‘_ColumnEntity’ from ‘sqlalchemy.orm.query’ (/home/cod7/superset-env/lib/python3.8/site-packages/sqlalchemy/orm/query.py)”错误,以上错误是由于SQLAlchemy包版本太高导致,按照以下步骤解决:
pip uninstall SQLAlchemy
pip install sqlalchemy==1.3.24
#创建用户名和密码
superset fab create-admin 【创建用户名和密码】
superset init 【初始化】
superset run -h 0.0.0.0 -p 8088
#注意:-p 8088来指定端口启动服务,-h 0.0.0.0是避免只能本地访问superset服务
gunicorn --workers 5 --timeout 120 --bind 192.168.1.132:8088 "superset.app:create_app()" --daemon
--workers:指定进程个数
--timeout:worker 进程超时时间,超时会自动重启
--bind:绑定本机地址,即为 Superset 访问地址
--daemon:后台运行
#停止后台服务
ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | xargs kill -9
其他
设置自动激活为false
conda config --set auto_activate_base false
国内常用源镜像地址:
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:https://mirrors.aliyun.com/pypi/simple/
中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:https://pypi.hustunique.com/
山东理工大学:https://pypi.sdutlinux.org/
豆瓣:https://pypi.douban.com/simple/
- 添加镜像源
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/free/
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/main/
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/conda-forge/
Anaconda有两个修改默认设置的命令,如下:第一行语句代表添加命令,第二行代表删除命令,其中的key是指关键词,value指关键词对应的值,可以是某些链接或者文件位置。
添加删除命令
conda config --add key value
conda config --remove key value
添加镜像源
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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
创建 superset.sh 文件
vi superset.sh
#!/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/module/miniconda3/bin/conda''shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f"/opt/module/miniconda3/etc/profile.d/conda.sh" ]; then
. "/opt/module/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/module/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 sc1: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
加执行权限
chmod +x superset.sh
superset.sh start
superset.sh stop
superset.sh status