• Superset 安装配置


     

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

    conda是一个开源的包、环境管理器,可以用于在同一个机器上安装不同Python版本的软件包及其依赖,并能够在不同的Python环境之间切换,Anaconda包括Conda、Python以及一大堆安装好的工具包,比如:numpy、pandas等,Miniconda包括Conda、Python

    安装Miniconda

    1 .wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

    2. bash Miniconda3-latest-Linux-x86_64.sh

    .................

    Do you accept the license terms? [yes|no]
    [no] >>>
    Please answer 'yes' or 'no':'
    >>> yes

    Miniconda3 will now be installed into this location:
    /home/datalink/miniconda3

    - Press ENTER to confirm the location
    - Press CTRL-C to abort the installation
    - Or specify a different location below

    [/home/datalink/miniconda3] >>> /opt/module/miniconda3   ----安装目录
    PREFIX=/opt/module/miniconda3
    Unpacking payload ...

     3.配置环境变量

    vim /etc/profile

    export CONDA_HOME=/opt/module/miniconda3
    export PATH=$PATH:$CONDA_HOME/bin

    source /etc/profile

    4.取消激活base环境

    Miniconda安装完成后,每次打开终端都会激活其默认的base环境

    (base) [datalink@slave1 ~]$ conda config --set auto_activate_base false

    创建Python3.6环境

    配置conda国内镜像

    [datalink@slave1 ~]$ conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/
    [datalink@slave1 ~]$ conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    [datalink@slave1 ~]$ conda config --set show_channel_urls yes

    [datalink@slave1 ~]$ cat ~/.condarc
    auto_activate_base: false
    channels:
    - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/
    - defaults
    show_channel_urls: true

    创建Python3.6环境

    [datalink@slave1 ~]$ conda create -n superset python=3.6
    Collecting package metadata (current_repodata.json): |

    conda环境管理常用命令如下:

    创建环境:conda create -n env_name

    查看所有环境:conda info --envs

    删除一个环境:conda remove -n env_name --all

    [datalink@slave1 ~]$ conda create -n superset python=3.6  
    Collecting package metadata (current_repodata.json): failed

    UnavailableInvalidChannel: The channel is not accessible or is invalid.
    channel name: anaconda/pkgs
    channel url: http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs
    error code: 404

    You will need to adjust your conda configuration to proceed.
    Use `conda config --show channels` to view your configuration's current state,
    and use `conda config --show-sources` to view config file locations.

    解决办法:使用以下命令恢复默认源
    [datalink@slave1 ~]$ conda config --remove-key channels
    [datalink@slave1 ~]$ cat ~/.condarc
    auto_activate_base: false
    show_channel_urls: true

    重新安装

    [datalink@slave1 ~]$ conda create -n superset python=3.6
    Collecting package metadata (current_repodata.json): done
    Solving environment: done

    ## Package Plan ##

    environment location: /opt/module/miniconda3/envs/superset

    added / updated specs:
    - python=3.6

    ..........................

    激活superset环境

    [datalink@slave1 ~]$ conda activate superset
    (superset) [datalink@slave1 ~]$

    退出当前环境:

    conda deactivate

    查看python版本

    [datalink@slave1 ~]$ python
    Python 3.8.5 (default, Sep 4 2020, 07:30:14)
    [GCC 7.3.0] :: Anaconda, Inc. on linux
    Type "help", "copyright", "credits" or "license" for more information.

    Superset部署

    安装依赖

    [datalink@slave1 ~]$ sudo yum install -y python-setuptools

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

    安装Superset

    安装(更新)setuptools和pip

    [datalink@slave1 ~]$ pip install --upgrade setuptools pip -i https://pypi.douban.com/simple/

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

    安装Superset

    [datalink@slave1 ~]$ pip install apache-superset -i https://pypi.douban.com/simple/

    说明:-i的作用是指定镜像,这里选择国内镜像

    初始化Superset数据库

    superset db upgrade

    采用的数据库是sqllite数据库,是一个轻量级的数据量

     创建管理员用户

    给superset创建管理员用户

    export FLASK_APP=superset

    [datalink@slave1 ~]$ export FLASK_APP=superset
    [datalink@slave1 ~]$ flask fab create-admin
    Username [admin]: datalink
    User first name [admin]:
    User last name [user]:
    Email [admin@fab.org]:
    Password:
    Repeat for confirmation:
    logging was configured successfully
    INFO:superset.utils.logging_configurator:logging was configured successfully
    /opt/module/miniconda3/lib/python3.8/site-packages/flask_caching/__init__.py:201: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
    warnings.warn(
    No PIL installation found
    INFO:superset.utils.screenshots:No PIL installation found
    Recognized Database Authentications.
    Admin User datalink created.

    密码同mysql密码

    初始化

    superset init

     

    启动Superset

    安装gunicorn

    [datalink@slave1 ~]$ pip install gunicorn -i https://pypi.douban.com/simple/
    Looking in indexes: https://pypi.douban.com/simple/
    Requirement already satisfied: gunicorn in /opt/module/miniconda3/lib/python3.8/site-packages (20.0.4)
    Requirement already satisfied: setuptools>=3.0 in /opt/module/miniconda3/lib/python3.8/site-packages (from gunicorn) (54.1.2)

    说明:gunicorn是一个Python Web Server,可以和java中的Tomcat类比

    1.确保当前conda环境为superset

    (superset) [datalink@slave1 ~]$ 

    如果没有,需要执行:conda activate superset

    2.启动

    (superset) [datalink@slave1 ~]$ gunicorn --workers 5 --timeout 120 --bind slave1:8787 superset:app --daemon

    (superset) [datalink@slave1 ~]$ curl http://192.168.130.62:8787
    <html>
    <head>
    <title>Internal Server Error</title>
    </head>
    <body>
    <h1><p>Internal Server Error</p></h1>

    </body>
    </html>

    解决:

    (superset) [datalink@slave1 ~]$ pip install gevent  -i https://pypi.douban.com/simple 

    (superset) [datalink@slave1 ~]$ gunicorn --workers 5 --timeout 120 --bind slave1:8787 "superset.app:create_app()"
    [2021-03-16 15:15:13 +0800] [16119] [INFO] Starting gunicorn 20.0.4
    [2021-03-16 15:15:13 +0800] [16119] [INFO] Listening at: http://192.168.130.62:8787 (16119)
    [2021-03-16 15:15:13 +0800] [16119] [INFO] Using worker: sync
    [2021-03-16 15:15:13 +0800] [16122] [INFO] Booting worker with pid: 16122
    [2021-03-16 15:15:13 +0800] [16123] [INFO] Booting worker with pid: 16123
    [2021-03-16 15:15:13 +0800] [16124] [INFO] Booting worker with pid: 16124
    [2021-03-16 15:15:13 +0800] [16125] [INFO] Booting worker with pid: 16125
    [2021-03-16 15:15:13 +0800] [16126] [INFO] Booting worker with pid: 16126
    logging was configured successfully

    (superset) [datalink@slave1 ~]$ gunicorn --workers 5 --timeout 120 --bind slave1:8787 "superset.app:create_app()" --daemon
    (superset) [datalink@slave1 ~]$

    说明:

    –workers:指定进程个数

    –timeout:worker进程超时时间,超时会自动重启

    –bind:绑定本机地址,即为Superset访问地址

    –daemon:后台运行

  • 相关阅读:
    黑胶100
    界面滑动+ztree
    Linux下Java获取本机IP地址
    垂直对齐vertical-align:top
    针对jquery获取表单数据并且迭代方式
    js传递参数中文乱码
    前端开发资源库
    webpack加载器(Loaders)
    webpack基础知识点
    webpack操作基础
  • 原文地址:https://www.cnblogs.com/playforever/p/14543115.html
Copyright © 2020-2023  润新知