Superset安裝部署操作
1、安裝Miniconda
因為安裝Superset需要Python3.7的環境,為了實現一個機器不同版本的Python,所以可以通過Miniconda來在不同的Python環境中進行切換
1、下載Miniconda
官網地址://conda.io/en/latest/miniconda.html
2、安裝
執行命令:bash Miniconda3-latest-Linux-x86_64.sh
接下就是一直回車空格
這裡設置安裝路徑
3、開啟一個新的shell窗口
4、設置新窗口不自動開啟conda
conda config –set auto_activate_base false
重回base命令:conda activate base
2、創建Python3.7環境
conda自帶3.7的python環境,這裡主要是為了學習conda命令,所以可以跳過
1、配置國內鏡像
conda config --add channels //mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels //mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
2、常用命令
conda create -n superset python=3.7 # 創建環境superset
conda info --envs # 查看所有環境
#conda remove -n superset --all # 刪除環境superset
conda activate superset # 切換到 superset 環境
python -V # 檢查環境
conda deactivate # 退出當前環境
3、安裝Superset
1、安裝依賴
yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel python-setuptools openssl-devel cyrus-sasl-devel openldap-devel
2、升級setuptools和pip
pip install –upgrade setuptools pip -i //pypi.douban.com/simple
3、安裝Superset
pip install apache-superset -i //pypi.douban.com/simple
4、初始化Superset數據庫
superset db upgrade
這裡我出現了error:ImportError: cannot import name 『soft_unicode』 from 『markupsafe』,是因為markupsafe的問題,解決:pip install markupsafe==2.0.1 將markupsafe進行降級處理
5、創建管理員用戶
export FLASK_APP=superset
superset fab create-admin
修改用戶時:進入root用戶下隱藏文件刪除superset.db,然後初始化,重新創建
6、Superset初始化
superset init
4、啟動Supterset
1、安裝gunicorn
pip install gunicorn -i //pypi.douban.com/simple ,gunicorn是一個web Server,和java中的tomcat類似
2、啟動
gunicorn –workers 5 –timeout 120 –bind 92.168.163.201:8787:8787 “superset.app:create_app()” –daemon
3、停止
ps -ef | awk ‘/superset/ && !/awk/{print $2}’ | xargs kill -9
4、使用啟停腳本
#!/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 0.0.0.0:8787 --daemon "superset.app:create_app()"
else
echo "superset is running."
fi
}
superset_stop(){
superset_status >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo "superset is not run."
else
ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | xargs kill -9
fi
}
case $1 in
start )
echo "start superset..."
superset_start
;;
stop )
echo "stop superset..."
superset_stop
;;
restart )
echo "restart superset..."
superset_stop
superset_start
;;
status )
superset_status >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo "superset is not run."
else
echo "superset is running."
fi
esac
設置執行權限:chmod +x
後續執行命令:
superset.sh status
superset.sh start
superset.sh stop
5、對接MySQL數據源
1、安裝依賴
conda install mysqlclient
hive的依賴:conda install pyhive