当前位置:网站首页>Visualization - Superset installation and deployment
Visualization - Superset installation and deployment
2022-08-01 09:33:00 【Sisi】
1 Superset入门
1.1 Superset概述
Apache Superset是一个开源的、现代的、轻量级BI分析工具,能够对接多种数据源、拥有丰富的图表展示形式、支持自定义仪表盘,且拥有友好的用户界面,十分易用.
1.2 Superset应用场景
由于Superset能够对接常用的大数据分析工具,如Hive、Kylin、Druid等,且支持自定义仪表盘,故可作为数仓的可视化工具.
第2章 Superset安装及使用
Superset官网地址:http://superset.apache.org/
2.1 安装Python环境
Superset是由Python语言编写的Web应用,要求Python3.7的环境.(But the environment comes with itpython2.7.5版本)

2.1.1 安装Miniconda
conda是一个开源的包、环境管理器,可以用于在同一个机器上安装不同Python版本的软件包及其依赖,并能够在不同的Python环境之间切换,Anaconda包括Conda、Python以及一大堆安装好的工具包,比如:numpy、pandas等,Miniconda包括Conda、Python.
此处,我们不需要如此多的工具包,故选择MiniConda.
[[email protected] ~]$ cd /opt/software/
[[email protected]102 software]$ ll
[[email protected] software]$ mkdir superset
[[email protected] software]$ cd superset/
上传Miniconda安装包

Enter the interactive installation process
[[email protected] superset]$ bash Miniconda3-latest-Linux-x86_64.sh

回车翻行,more--空格翻页

注意:when typing the path,如果写错,需要删除时,需要按住Ctrl键删除.

加载环境变量配置文件,使之生效
[[email protected] lib]$ source ~/.bashrc
取消激活base环境
Miniconda安装完成后,每次打开终端都会激活其默认的base环境,我们可通过以下命令,禁止激活默认base环境.
[[email protected] lib]$ conda config --set auto_activate_base false

Now close and reopen the session,就可以了.

2.1.2 创建Python3.7环境
onda环境管理常用命令
创建环境:conda create -n env_name
查看所有环境:conda info --envs
删除一个环境:conda remove -n env_name --all
配置conda国内镜像(Too slow abroad when downloading environments,So configure the mirror first,切换到国内)
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环境
[[email protected] ~]$ conda create --name superset python=3.7


2.2 Superset部署
2.2.1 安装依赖
安装Superset之前,需安装以下所需依赖
(superset) [[email protected] ~]$ sudo yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel python-setuptools openssl-devel cyrus-sasl-devel openldap-devel
2.2.2 安装Superset
安装(更新)setuptools和pip
(superset) [[email protected] ~]$ pip install --upgrade setuptools pip -i https://pypi.douban.com/simple/
说明:pip是python的包管理工具,可以和centos中的yum类比

安装Supetset
(superset) [[email protected] ~]$ pip install apache-superset -i https://pypi.douban.com/simple/
说明:-i的作用是指定镜像,这里选择国内镜像
注:如果遇到网络错误导致不能下载,可尝试更换镜像
(superset) [[email protected] ~]$ pip install apache-superset --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple

初始化Supetset数据库
(superset) [[email protected] ~]$ superset db upgrade

(There are a lot of issues here due to version issues,Finally, I read a big guy's article and it was solved,In short, lowermarkupsafe的版本,‘python -m pip install markupsafe==2.0.1’,卸载原来的superset,‘conda remove -n superset --all’,Then follow the original procedure to reinstall,安装python3.9‘conda create --name superset python=3.9’,再重新激活superset环境,最后出现No module named 'werkzeug.wrappers.etag'Lower this situationwerkzeug版本就行,‘python -m pip install werkzeug==2.0.0’)For details, please refer to the following article
https://blog.csdn.net/qq1787546870/article/details/124582727
创建管理员用户
(superset) [[email protected] ~]$ export FLASK_APP=superset
(superset) [[email protected] ~]$ superset fab create-admin

Superset初始化
(superset) [[email protected] ~]$ superset init

2.2.3 启动Supterset
安装gunicorn
(superset) [[email protected] ~]$ pip install gunicorn -i https://pypi.douban.com/simple/

说明:gunicorn是一个Python Web Server,可以和java中的TomCat类比
启动Superset
确保当前conda环境为superset
(superset) [[email protected] ~]$ gunicorn --workers 5 --timeout 120 --bind hadoop102:8787 "superset.app:create_app()" --daemon
说明:
--workers:指定进程个数
--timeout:worker进程超时时间,超时会自动重启
--bind:绑定本机地址,即为Superset访问地址
--daemon:后台运行
登录Superset,访问http://hadoop102:8787

工作界面

停止superset
停掉gunicorn进程
(superset) [[email protected] ~]$ ps -ef | awk '/superset/ && !/awk/{print $2}' | xargs kill -9

退出superset环境
(superset) [[email protected] ~]$ conda deactivate
2.2.4 superset启停脚本
1)创建superset.sh文件
[[email protected] bin]$ 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 hadoop102: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

添加权限
(superset) [[email protected] bin]$ chmod +x superset.sh
测试
启动superset
[[email protected] bin]$ superset.sh start
停止superset
[[email protected] bin]$ superset.sh stop

边栏推荐
- 【STM32】入门(二):跑马灯-GPIO端口输出控制
- Static Pod, Pod Creation Process, Container Resource Limits
- Redis middleware (from building to refuse pit)
- The soul asks: How does MySQL solve phantom reads?
- CTO强烈禁止使用Calendar,那用啥?
- redis
- leetcode-6134: Find the closest node to the given two nodes
- various network protocols
- YOLOv7-Pose尝鲜,基于YOLOv7的关键点模型测评
- TiDB的真实数据库数据是存在kv和还是pd上?
猜你喜欢

程序员如何学习开源项目,这篇文章告诉你

消息队列面试题(2022最新整理)

How to get page data

leetcode-6134: Find the closest node to the given two nodes

How programmers learn open source projects, this article tells you

C language game - minesweeper

Redis中间件(从搭建到弃坑)

自定义IP在PCIE中使用

Microsoft Azure & NVIDIA IoT developers season I | Azure IoT & NVIDIA Jetson development foundation

Three chess (C language implementation)
随机推荐
Mysql database deployment and initialization steps
毕业论文写作技巧
HoloView -- Tabular Datasets
改版去不图床 Token 的获取
leetcode-6133:分组的最大数量
SkiaSharp's WPF self-painted five-ring bouncing ball (case version)
安装GBase 8c数据库的时候,报错显示“Resource,如何解决?
【STM32】入门(一):环境搭建、编译、下载、运行
笔记。。。。
Graduation thesis writing skills
【STM32】入门(二):跑马灯-GPIO端口输出控制
网络基础学习
scrapy爬虫框架的使用
A problem with writing to the database after PHP gets the timestamp
leetcode-6135:图中的最长环
灵魂发问:MySQL是如何解决幻读的?
杨辉三角(c语言实现)
leetcode-6132:使数组中所有元素都等于零
【无标题】
experiment....