当前位置:网站首页>可视化——Superset安装与部署
可视化——Superset安装与部署
2022-08-01 09:28:00 【丝丝呀】
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的环境。(但是环境中自带的是python2.7.5版本)
2.1.1 安装Miniconda
conda是一个开源的包、环境管理器,可以用于在同一个机器上安装不同Python版本的软件包及其依赖,并能够在不同的Python环境之间切换,Anaconda包括Conda、Python以及一大堆安装好的工具包,比如:numpy、pandas等,Miniconda包括Conda、Python。
此处,我们不需要如此多的工具包,故选择MiniConda。
[[email protected]p102 ~]$ cd /opt/software/
[[email protected] software]$ ll
[[email protected] software]$ mkdir superset
[[email protected] software]$ cd superset/
上传Miniconda安装包
进入交互式安装过程
[[email protected] superset]$ bash Miniconda3-latest-Linux-x86_64.sh
回车翻行,more--空格翻页
注意:敲路径时,如果写错,需要删除时,需要按住Ctrl键删除。
加载环境变量配置文件,使之生效
[[email protected] lib]$ source ~/.bashrc
取消激活base环境
Miniconda安装完成后,每次打开终端都会激活其默认的base环境,我们可通过以下命令,禁止激活默认base环境。
[[email protected] lib]$ conda config --set auto_activate_base false
现在把会话关闭再重新开启,就可以了。
2.1.2 创建Python3.7环境
onda环境管理常用命令
创建环境:conda create -n env_name
查看所有环境:conda info --envs
删除一个环境:conda remove -n env_name --all
配置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环境
[[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
(这里由于版本问题出现了很多问题,最后看了个大佬的文章被解决了,总之就是降低markupsafe的版本,‘python -m pip install markupsafe==2.0.1’,卸载原来的superset,‘conda remove -n superset --all’,然后按照原来的过程重新安装,安装python3.9‘conda create --name superset python=3.9’,再重新激活superset环境,最后出现No module named 'werkzeug.wrappers.etag'这种情况降低下werkzeug版本就行,‘python -m pip install werkzeug==2.0.0’)详情可以参照以下文章
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
边栏推荐
- net stop/start mysql80 access denied
- 【Untitled】
- ASP.NET Core 6框架揭秘实例演示[30]:利用路由开发REST API
- rpm和yum
- [Beyond programming] When the fig leaf is lifted, when people begin to accept everything
- HoloView——实时数据
- pytest interface automation testing framework | parametrize source code analysis
- 如何保证数据库与缓存数据一致性?
- 【编程之外】当遮羞布被掀开,当人们开始接受一切
- 最新的Cesium和Three的整合方法(附完整代码)
猜你喜欢
Analysis of High Availability Solution Based on MySql, Redis, Mq, ES
Holoview--Introduction
How to ensure the consistency of database and cache data?
50.【动态二维数组的运用】
改版去不图床 Token 的获取
获取页面数据的方法
JVM内存模型之深究模型特征
net stop/start mysql80 拒绝访问
[Beyond programming] When the fig leaf is lifted, when people begin to accept everything
JVM 运行时数据区与JMM 内存模型详解
随机推荐
sql server, FULL模式, dbcc shrinkfile(2,1) 不能收缩事务日志,还是原来的大小,是为什么?
Lsky Pro 企业版手动升级、优化教程
指针的介绍及应用
2022.7.31-----leetcode.1161
消息队列面试题(2022最新整理)
常见的API安全缺陷有哪些?
WLAN networking experiment of AC and thin AP
Graduation thesis writing skills
淘宝商品详情又见淘宝详情,升级高级版 API
Shell: Conditional test action
leetcode-6133: maximum number of groupings
leetcode 42. Catch the rain
《时代》杂志:元宇宙时代将改变世界
ACmix 论文精读,并解析其模型结构
改版去不图床 Token 的获取
获取页面数据的方法
SkiaSharp 之 WPF 自绘 五环弹动球(案例版)
程序员如何学习开源项目,这篇文章告诉你
network basic learning
How to query database configuration parameters in GBase 8c, such as datestyle