Superset(二)安装

Superset官网地址:

http://superset.apache.org/

安装Python环境

Superset是由Python语言编写的Web应用,要求Python3.7的环境。

安装Miniconda

Miniconda安装过程参考:https://blog.csdn.net/qq_38214903/article/details/97100821

由于我用的是虚拟机,虽然上面有python,但是版本是2.7的版本。

[admin@hadoop102 script]$ python
Python 2.7.5 (default, Oct 14 2020, 14:45:30)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

所以需要安装一个沙箱工具(Miniconda),将3.7以上版本Python安装在里面。

  • 安装Miniconda,安装过程直接yes即可。
==> For changes to take effect, close and re-open your current shell. <==

If you'd prefer that conda's base environment not be activated on startup,
   set the auto_activate_base parameter to false:

conda config --set auto_activate_base false

Thank you for installing Miniconda3!

安装完成,提示以上信息

  • 若此时重新打开一个窗口,默认则进入base沙箱中。
(base) [admin@hadoop102 ~]$ 

可以设置conda config --set auto_activate_base false,默认为true,表示不自动进入base沙箱

(base) [admin@hadoop102 ~]$  conda config --set auto_activate_base false

退出Miniconda

若想退出Miniconda,输入conda deactivate命令即可

(base) [admin@hadoop102 ~]$ conda deactivate

进入Miniconda

若想重新进入Miniconda
语法 :conda activate <沙箱名称>

[atguigu@hadoop102 ~]$  conda activate base
(base) [admin@hadoop102 ~]$

安装python环境

superset :表示沙箱名称,随意
3.7:python版本可改,可以修改成 3.9

conda create --name superset python=3.9
  • 安装过程中,全部同意即可。
Proceed ([y]/n)? y
  • 安装完成之后,退出当前Miniconda,进入superset
# 退出 base
(base) [admin@hadoop102 ~]$ conda deactivate
# 进入 superset
[admin@hadoop102 ~]$ conda activate superset
  • 查看当前python版本
(superset) [admin@hadoop102 ~]$ python
Python 3.9.5 (default, Jun  4 2021, 12:28:51)

Superset 安装

准备好python3.7以上的环境后,就进行Superset的安装

  • Superset 环境依赖安装

sudo yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel python-setuptools openssl-devel cyrus-sasl-devel openldap-devel

(superset) [admin@hadoop102 ~]$ sudo yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel python-setuptools openssl-devel cyrus-sasl-devel openldap-devel

稍等片刻即可。

  • 安装(更新)setuptools和pip

pip install --upgrade setuptools pip -i https://pypi.douban.com/simple/

说明:pip是python的包管理工具,可以和centos中的yum类比

  • 安装Supetset
    前两步工作准备好之后,就可以正式安装Supetset

pip install apache-superset -i https://pypi.douban.com/simple/

说明:-i的作用是指定镜像,这里选择国内镜像
注:如果遇到网络错误导致不能下载,可尝试更换镜像

(superset) [admin@hadoop102 ~]$ pip install apache-superset --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple

稍等片刻...

创建管理员用户

安装Supetset之后,创建管理员账号

  • 执行 export FLASK_APP=superset
(superset) [admin@hadoop102 ~]$ export FLASK_APP=superset
  • 创建管理员,执行superset fab create-admin命令
(superset) [admin@hadoop102 ~]$ superset fab create-admin
  • 输入账号,名称随意
2021-07-27 19:27:43,706:INFO:superset.utils.screenshots:No PIL installation found
Username [admin]: admin 
  • User first name 随意
User first name [admin]: ma
  • User last name 随意
User last name [user]: ma
  • 邮箱 随意
Email [[email protected]]:
  • 密码,随意能记住就行
Password:
  • 再次确认密码
Repeat for confirmation:
  • 安装完成
Recognized Database Authentications.
Admin User atguigu created.

初始化Supetset数据库

(superset) [admin@hadoop102 ~]$ superset db upgrade

Superset初始化

(superset) [admin @hadoop102 ~]$ superset init

启动 Supterset

  • 安装 gunicorn
    pip install gunicorn -i https://pypi.douban.com/simple/
(superset) [admin@hadoop102 ~]$ pip install gunicorn -i https://pypi.douban.com/simple/

服务器容器

  • 启动
    gunicorn --workers 5 --timeout 120 --bind hadoop102:8787 "superset.app:create_app()" --daemon
(superset) [admin@hadoop102 ~]$ gunicorn --workers 5 --timeout 120 --bind hadoop102:8787  "superset.app:create_app()" --daemon

说明:
--workers:指定进程个数
--timeout:worker进程超时时间,超时会自动重启
--bind:绑定本机地址,即为Superset访问地址
--daemon:后台运行

  • 登录Superset
    访问:http://hadoop102:8787
superset登录界面

Superset 退出

由于刚才是后台启动--daemon,若要退出程序,就不得不用kill进程的方式

(superset) [admin@hadoop102 ~]$ lsof -i :8787
COMMAND     PID    USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
gunicorn 127103 admin       5u  IPv4 1611792      0t0  TCP hadoop102:msgsrvr (LISTEN)
gunicorn 127104 admin       5u  IPv4 1611792      0t0  TCP hadoop102:msgsrvr (LISTEN)
gunicorn 127105 admin       5u  IPv4 1611792      0t0  TCP hadoop102:msgsrvr (LISTEN)
gunicorn 127106 admin       5u  IPv4 1611792      0t0  TCP hadoop102:msgsrvr (LISTEN)
gunicorn 127107 admin       5u  IPv4 1611792      0t0  TCP hadoop102:msgsrvr (LISTEN)
gunicorn 127108 admin       5u  IPv4 1611792      0t0  TCP hadoop102:msgsrvr (LISTEN)

keill 进程

 kill 127103

你可能感兴趣的:(Superset(二)安装)