Superset部署

Superset部署

今天给大家分享一个我安装了很久的Superset这个可视化工具。当时我在安装的过程当中遇到过很多很多的问题,第一个就是解决Python环境变量的问题,其次是在安装Miniconda3-latest-Linux-x86_64.sh,安装superset过程当中也遇到很多的坑,我上网去查了,也解决了很久,可是也没有成功。2021-01-07我安装成功了,我希望分享这个部署的经历,能够帮助有需要的人。

查看Linux的环境

[root@bigdata114 ~]# python
Python 2.7.5 (default, Apr 11 2018, 07:36:10) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

现在我们需要把Linux系统自带的python2的环境给替换成Python3的环境。

[root@bigdata114 ~]#  cd /usr/local/src

# 后面会出现 ---> Is this ok [y/d/N]: y

[root@bigdata114 src]# yum install wget

安装Python3.6

注意:我们在编译的时候可能会出现问题,如果出现问题之后,我们把它删除之后然后在重新编译就可以了。

[root@bigdata114 src]# wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz

[root@bigdata114 src]# ll
total 21740
-rw-r--r--  1 root root  22256403 Jan  7 02:14 Python-3.6.0.tgz
[root@bigdata114 src]# tar -zxvf Python-3.6.0.tgz

[root@bigdata114 src]# ll
total 21740
drwxr--r-- 17  501 games     4096 Dec 22  2016 Python-3.6.0
-rw-r--r--  1 root root  22256403 Jan  7 02:14 Python-3.6.0.tgz

[root@bigdata114 src]# cd Python-3.6.0
[root@bigdata114 src]# ./configure --prefix=/usr/local/python
[root@bigdata114 src]#  make && make install 

添加环境变量

# 添加Python3的环境变量
export PYTHON_HOME=/usr/local/python
export PATH=$PATH:$PYTHON_HOME/bin

source /etc/profile

检查是否安装成功

[root@bigdata114 Python-3.6.0]# python3.6
Python 3.6.0 (default, Jan  7 2021, 05:22:48) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

修改系统Python的环境变量

[root@bigdata114 Python-3.6.0]# mv /usr/bin/python /usr/bin/python-2.7.5
[root@bigdata114 bin]# ln -s /usr/local/python/bin/python3.6 /usr/bin/python
[root@bigdata114 bin]# ln -s /usr/local/python/bin/pip3 /usr/bin/pip

因为yum是依赖python的,所以这里我们修改了默认的python,就要修改yum,让其运行指向旧的版本

#  vi /usr/bin/yum
#  vi /usr/libexec/urlgrabber-ext-down

修改成:#! /usr/bin/python-2.7.5

验证

[root@bigdata114 bin]# python
Python 3.6.0 (default, Jan  7 2021, 05:27:52) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

安装容器和密码验证工具

[root@bigdata114 bin]#  yum upgrade python-setuptools
[root@bigdata114 bin]#  yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel cyrus-sasl-devel openldap-devel
[root@bigdata114 bin]# pip install cryptography

Superset安装

1)下载Miniconda(Python3版本)

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

2)安装Miniconda

[root@bigdata114 src]# ll
total 91844
-rw-r--r--  1 root root  71785000 Dec 10 19:06 Miniconda3-latest-Linux-x86_64.sh
drwxr--r-- 18  501 games     4096 Jan  7 06:15 Python-3.6.0
-rw-r--r--  1 root root  22256403 Jan  7 02:14 Python-3.6.0.tgz

[root@bigdata114 src]# bash Miniconda3-latest-Linux-x86_64.sh

# 一路回车
Do you accept the license terms? [yes|no]
[no] >>> yes
# 一路回车
[/root/miniconda3] >>> /opt/module/miniconda3

by running conda init? [yes|no]
[no] >>> yes

3)加载环境变量配置文件,使之生效

[root@bigdata114 src]# source ~/.bashrc
(base) [root@bigdata114 src]# 

4)取消激活base环境

(base) [root@bigdata114 src]# conda config --set auto_activate_base false

创建Python3.6环境

1)配置conda国内镜像

(base) [root@bigdata114 src]# conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
(base) [root@bigdata114 src]# conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
(base) [root@bigdata114 src]# conda config --set show_channel_urls yes

2)创建Python3.6环境

(base) [root@bigdata114 src]# conda create --name superset python=3.6

Proceed ([y]/n)? y

3)激活superset环境

(base) [root@bigdata114 src]# conda activate superset
(superset) [root@bigdata114 src]# 

说明:退出当前环境

(superset) [root@bigdata114 src]#  conda deactivate

安装依赖

安装Superset之前,需安装以下所需依赖

(superset) [root@bigdata114 src]# sudo yum install -y python-setuptools
(superset) [root@bigdata114 src]# sudo yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel cyrus-sasl-devel openldap-devel

1)安装(更新)setuptools和pip

(superset) [root@bigdata114 src]#  pip install --upgrade setuptools pip -i https://pypi.douban.com/simple/

2)安装Supetset

(superset) [root@bigdata114 src]#  pip install apache-superset -i https://pypi.douban.com/simple/

3)初始化Supetset数据库

(superset) [root@bigdata114 src]# superset db upgrade

注意:会出现错误
Superset部署
解决办法

(superset) [root@bigdata114 src]# pip install dataclasses
Collecting dataclasses
  Downloading dataclasses-0.8-py3-none-any.whl (19 kB)
Installing collected packages: dataclasses
Successfully installed dataclasses-0.8

4)创建管理员用户

(superset) [root@bigdata114 src]#  export FLASK_APP=superset

(superset) [root@bigdata114 src]#  flask fab create-admin
Username [admin]: admin
User first name [admin]: admin
User last name [user]: admin
Email [admin@fab.org]: admin
Password: 
Repeat for confirmation: 
logging was configured successfully
INFO:superset.utils.logging_configurator:logging was configured successfully
/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/flask_caching/__init__.py:192: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
  "Flask-Caching: CACHE_TYPE is set to null, "
No PIL installation found
INFO:superset.utils.screenshots:No PIL installation found
Recognized Database Authentications.
Admin User admin created.

5)Superset初始化

(superset) [root@bigdata114 src]#  superset init

启动Supterset

1)安装gunicorn

(superset) [root@bigdata114 src]#  pip install gunicorn -i https://pypi.douban.com/simple/

2)启动Superset

(superset) [root@bigdata114 src]# gunicorn --workers 5 --timeout 120 --bind bigdata114:8787  "superset.app:create_app()" --daemon

3)停止superset

(superset) [root@bigdata114 src]#  ps -ef | awk '/superset/ && !/awk/{print $2}' | xargs kill -9

退出superset环境

(superset) [root@bigdata114 src]#  conda deactivate

成功显示

登录:admin admin
Superset部署
启动mysql
Superset部署

使用superset连接mysql

(superset) [root@bigdata114 src]# conda install mysqlclient

Superset部署
关闭superset

(superset) [root@bigdata114 src]# ps -ef | awk '/superset/ && !/awk/{print $2}' | xargs kill -9
上一篇:Windows部署superset操作手册


下一篇:Apache Superset功能介绍