安装Python环境
安装Miniconda取消激活base环境创建Python3.7环境
激活 superset 环境 安装 Superset
安装依赖初始化 Supetset 数据库创建管理员用户 启动Supterset
安装 gunicorn安装 对接MySQL数据源Superset 启停脚本启动 superset
安装Python环境 安装Miniconda命令进行安装,并按照提示操作,直到安装完成
bash Miniconda3-latest-Linux-x86_64.sh
出现以下提示时,可以指定安装路径
/opt/module/miniconda3
加载环境变量配置文件,使之生效
source ~/.bashrc取消激活base环境
Miniconda 安装完成后,每打开终端都会激活其默认的 base 环境
conda config --set auto_activate_base false创建Python3.7环境
配置 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.7环境
conda create --name superset python=3.7
说明:conda 环境管理常用命令
创建环境:conda create -n env_name查看所有环境:conda info --envs删除一个环境:conda remove -n env_name --all
激活 superset 环境conda activate superset
查看 python 版本
python
退出当前环境 ( 不使用 )
conda deactivate安装 Superset 安装依赖
安装Superset之前,需安装以下所需依赖 :
sudo yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel python-setuptools openssl-devel cyrus-sasl-devel openldap-devel
安装(更新)setuptools 和 pip
pip install --upgrade setuptools pip -i https://pypi.douban.com/simple/
pip 是 python 的包管理工具,可以和 centos 中的 yum 类比
安装 Supetset
pip install apache-superset -i https://pypi.douban.com/simple/初始化 Supetset 数据库
错误 importError: cannot import name ‘soft_unicode‘ from ‘markupsafe‘ :
https://blog.csdn.net/qq_44226094/article/details/123799497
superset db upgrade
错误 No PIL installation found :
https://blog.csdn.net/qq_44226094/article/details/123799825?spm=1001.2014.3001.5501
export FLASK_APP=superset
superset fab create-admin
这里设置的用户和密码就是你后面启动要登录的账户和密码
flask是一个python web框架,Superset使用的就是flask
Superset 初始化
superset init启动Supterset 安装 gunicorn
pip install gunicorn -i https://pypi.douban.com/simple/
安装 对接MySQL数据源gunicorn 是一个 Python Web Server,类比 java 中的 TomCat
conda install mysqlclientSuperset 启停脚本
在 /home/cpu/bin 创建 superset.sh 文件
vim 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(){
source ~/.bashrc
superset_status >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
conda activate superset ; gunicorn --workers 5 --timeout 120 --bind cpucode101: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
–workers:指定进程个数–timeout:worker进程超时时间,超时会自动重启–bind:绑定本机地址,即为Superset访问地址–daemon:后台运行
加执行权限
chmod 777 superset.sh启动 superset
superset.sh start
登录 Superset
访问 http://cpucode101:8787



