0
点赞
收藏
分享

微信扫一扫

大数据学习教程SD版第十五篇【Superset】

code_balance 2022-01-06 阅读 33

1. Superset 安装

  • 准备工作

    1. 安装python3
    # 此处使用miniconda安装python
    sh miniconda3xxx.sh
    source ~/.bashrc
    # 禁止激活默认环境
    conda config --set auto_activate_base false
    
    1. 配置python环境
    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 create --name superset python=3.7
    
    conda activate superset
    conda deactivate
    
    1. 安装所需依赖
    yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel pythonsetuptools openssl-devel cyrus-sasl-devel openldap-devel
    
    pip install --upgrade setuptools pip -i https://pypi.douban.com/simple/
    
  • 安装Superset

pip install apache-superset -i https://pypi.douban.com/simple/
# 1.init db
superset db upgrade
# 2.set var
export FLASK_APP=superset
# 3.create admin
superset fab create-admin
# 4. init superset
superset init
  • 安装gunicorn
pip install gunicorn -i https://pypi.douban.com/simple/

启动 gunicorn

gunicorn --workers 5 --timeout 120 --bind hadoop102:9999 "superset.app:create_app()" --daemon

访问地址

http://hadoop102:9999
用户名和密码在创建admin的时候指定的值

在这里插入图片描述

# kill gunicorn
ps -ef | awk '/superset/ && !/awk/{print $2}' | xargs kill -9 

2. Superset 启停脚本

#!/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(){
 superset_status >/dev/null 2>&1
  if [[ $? -eq 0 ]]; then
   gunicorn --workers 5 --timeout 120 --bind hadoop102:9999 --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

3. Superset 使用

conda install mysqlclient
# 重启superset

3.1 Superset 添加数据源

  1. 添加DataBases(MySQL Conn)
    在这里插入图片描述

  2. 添加DataSets(Table)

在这里插入图片描述

3.2 Superset 制作仪表盘

  1. 折线图:需要配置metric

在这里插入图片描述

  1. 城市地图:需要配置metric

在这里插入图片描述

  1. 柱状图:需要配置series和metric

在这里插入图片描述

  1. 饼图:需要配置groupby 和metric

在这里插入图片描述

举报

相关推荐

0 条评论