- 概述
Apache Superset是一个开源的、古代的、轻量级BI剖析工具,领有丰盛的图表展现模式、反对自定义仪表盘,可能对接多种数据源、且领有敌对的用户界面,非常好用。 - 利用场景
因为Superset可能对接罕用的大数据分析工具,如Hive、Kylin、Impala、Druid、mysql等,且反对自定义仪表盘,故可作为数仓的可视化工具。 - 装置及应用
3.1 环境要求
Superset是由Python语言编写的Web利用,要求Python3.7的环境。
3.2 装置Miniconda
为了不影响零碎自身的python环境,本次部署抉择conda,conda是一个开源的包、环境管理器,能够用于在同一个机器上装置不同Python版本的软件包及其依赖,并可能在不同的Python环境之间切换,Anaconda包含Conda、Python以及一大堆装置好的工具包,比方:numpy、pandas等,Miniconda包含Conda、Python。
此处,咱们不须要如此多的工具包,故抉择MiniConda。
下载Miniconda
下载地址: https://repo.anaconda.com/min...
装置Miniconda(普通用户装置)
新建test用户,用普通用户装置部署
[root@node02 ~]# useradd test
[test@node02 opt]$ wget
https://repo.anaconda.com/min...
执行以下命令进行装置,并依照提醒操作,直到装置实现。
[test@node02 opt]$ bash Miniconda3-latest-Linux-x86_64.sh
在装置过程中,呈现以下提醒时,回车键持续
[test@node02 ~]$ bash Miniconda3-latest-Linux-x86_64.sh
Welcome to Miniconda3 py39_4.10.3
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
...
Miscellaneous
--More--
输出yes
Do you accept the license terms? [yes|no]
呈现以下提醒时,能够指定装置门路,不指定默认/home/test/miniconda3
Miniconda3 will now be installed into this location:
/home/test/miniconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/test/miniconda3] >>>
初始化,yes
Preparing transaction: done
Executing transaction: done
installation finished.
Do you wish the installer to initialize Miniconda3
by running conda init? [yes|no]
[no] >>>
呈现以下字样,即为装置实现
conda config --set auto_activate_base false
Thank you for installing Miniconda3!
3.3 加载环境变量,使之失效
[test@node02 opt]$ source ~/.bashrc
(base)[test@node02 opt]$
3.4 勾销激活base环境
Miniconda装置实现后,每次关上终端都会激活其默认的base环境,咱们可通过以下命令,禁止激活默认base环境。
[test@node02 opt]$ conda config --set auto_activate_base false
3.5 创立Python3.7环境
3.5.1 配置conda国内镜像
(base) [test@node02 ~]$ conda config --add channels https://mirrors.tuna.tsinghua...
(base) [test@node02 ~]$ conda config --add channels https://mirrors.tuna.tsinghua...
(base) [test@node02 ~]$ conda config --set show_channel_urls yes
3.5.2 创立Python3.7环境
(base) [test@node02 ~]$ conda create --name superset python=3.7
阐明:conda环境治理常用命令
创立环境:conda create -n env_name
查看所有环境:conda info --envs
删除一个环境:conda remove -n env_name --all
3.5.3 激活superset环境
(base) [test@node02 ~]$ conda activate superset
激活后成果如下所示:
(superset) [test@node02 ~]$
阐明:退出以后环境
(superset) [test@node02 ~]$ conda deactivate
3.5.4 查看python版本
(superset) [test@node02 ~]$ python
Python 3.7.11 (default, Jul 27 2021, 14:32:16)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
- Superset部署
4.1 装置依赖
装置Superset之前,需装置以下所需依赖
(superset) [test@node02 ~]$ sudo yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel python-setuptools openssl-devel cyrus-sasl-devel openldap-devel
4.2 装置Superset
装置(更新)setuptools和pip
(superset) [test@node02 ~]$ pip install --upgrade setuptools pip -i https://pypi.douban.com/simple/
阐明:pip是python的包管理工具,能够和centos中的yum类比
- 装置Supetset
(superset) [test@node02 ~]$ pip install apache-superset -i https://pypi.douban.com/simple/
阐明:-i的作用是指定镜像,这里抉择国内镜像
如果遇到网络谬误导致不能下载,可尝试更换镜像
- 初始化Supetset数据库
(superset) [test@node02 ~]$ superset db upgrade
创立管理员用户
(superset) [test@node02 ~]$ export FLASK_APP=superset
(superset) [test@node02 ~]$ superset fab create-admin
阐明:flask是一个python web框架,Superset应用的就是flask
- Superset初始化
(superset) [test@node02 ~]$ superset init
- 启动Supterset
装置gunicorn
(superset) [test@node02 ~]$ pip install gunicorn -i https://pypi.douban.com/simple/
阐明:gunicorn是一个Python Web Server,能够和java中的TomCat类比
- 启动Superset
(superset) [test@node02 ~]$ gunicorn --workers 5 --timeout 120 --bind hadoop102:8787 "superset.app:create_app()" --daemon
阐明:
–workers:指定过程个数
–timeout:worker过程超时工夫,超时会主动重启
–bind:绑定本机地址,即为Superset拜访地址
–daemon:后盾运行
- 登录Superset
拜访http://node02:8787,并应用下面创立的管理员账号进行登录
大数据培训
- 进行superset
停掉所有的gunicorn过程
(superset) [test@node02 ~]$ ps -ef | awk '/superset/ && !/awk/{print $2}' | xargs kill -9
superset启停脚本
6.1 创立脚本
[test@node02 ~]$ vim superset.sh!/bin/bash
superset_status(){
result=`ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | wc -l`if [[ $result -eq 0 ]]; then return 0else return 1fi
}
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>&1if [[ $? -eq 0 ]]; then echo "superset未在运行"else ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | xargs kill -9fi
}
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
6.2 增加执行权限
[test@node02 ~]$ chmod +x superset.sh
6.3 启停命令
[test@node02 ~]$ superset.sh start
[test@node02 ~]$ superset.sh stop
[test@node02 ~]$ superset.sh status
[test@node02 ~]$ superset.sh restart
- 数据源插件
官网查问反对的数据源列表: https://superset.apache.org/d...
装置命令:
(superset)[test@node02 ~]$ conda install mysqlclient
其它插件可查问官网装置