栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

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

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

Superset 数据可视化工具

Apache免费开源 易用 可对接多种数据源

由Python编写 使用了Flask框架

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

由于Superset是一个python的web应用,所以需要安装一个Web容器

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 使用

可以对接各类数据源,需要下载对应驱动,以mysql为例

documentation | Superset (apache.org)

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/698907.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号