当前位置:网站首页>可视化——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
边栏推荐
- Detailed explanation of JVM runtime data area and JMM memory model
- 【应用推荐】常见资源管理器整理,含个人使用体验和产品选型推荐
- 淘宝商品详情又见淘宝详情,升级高级版 API
- HoloView -- Tabular Datasets
- 扁平数组转树结构实现方式
- codeforces每日5题(均1600)-第二十七天
- BGP综合实验
- JVM内存模型之深究模型特征
- leetcode-6135:图中的最长环
- In the background of the GBase 8c database, what command is used to perform the master-slave switchover operation for the gtm and dn nodes
猜你喜欢
随机推荐
【无标题】
Install GBase 8 c database, the error shows "Resource, how to solve?
Shell executes SQL to send emails
JVM 运行时数据区与JMM 内存模型详解
JVM内存模型之深究模型特征
自定义IP在PCIE中使用
Detailed explanation of JVM runtime data area and JMM memory model
热修复技术可谓是百花齐放
【应用推荐】常见资源管理器整理,含个人使用体验和产品选型推荐
Shell: Conditional test action
STM32个人笔记-嵌入式C语言优化
解析MySQL数据库:“SQL优化”与“索引优化”
【Unity3D】相机
笔记。。。。
程序员如何学习开源项目,这篇文章告诉你
SkiaSharp's WPF self-painted five-ring bouncing ball (case version)
rpm and yum
Is the real database data of TiDB stored in kv and pd?
ASP.NET Core 6框架揭秘实例演示[30]:利用路由开发REST API
The soul asks: How does MySQL solve phantom reads?