Centos7安装可视化工具Superset1.2.0(含中文配置)

目录

  • 1. 安装superset的依赖
  • 2. 安装python
  • 3. 安装Superset的python3.7虚拟环境
  • 4. 安装mysql客户端、在mysql中创建superset元数据库
  • 5. 安装superset
  • 6. 配置
    • 6.1 superset_config.py
    • 6.2 中文的配置
  • 7. superset初始化相关操作
  • 8. 启动
  • 9. 查看web页面

1. 安装superset的依赖

[root@bigdata005 ~]# 
[root@bigdata005 ~]# yum install -y libffi-devel gcc-c++
[root@bigdata005 ~]#

2. 安装python

这里我们安装两个python

  1. python3.9.6为服务器的python3环境
  2. 因为Superset1.2.0需要python3.7, 所以我们安装python3.7.11作为virtualenv的引用python3环境,但python3.7.11不设置系统软链接
  • python3的安装可以参考我的centos7同时安装Python2和Python3

3. 安装Superset的python3.7虚拟环境

  1. 安装virtualenv
[root@bigdata005 python3]# 
[root@bigdata005 python3]# pip3 install --upgrade pip
[root@bigdata005 python3]#
[root@bigdata005 python3]# pip3 install virtualenv
[root@bigdata005 python3]#
  1. 用virtualenv虚拟superset的python环境
[root@bigdata005 python3]# 
[root@bigdata005 python3]# /opt/python3/python-3.9.6/bin/virtualenv superset --python=/opt/python3/python-3.7.11/bin/python3.7
[root@bigdata005 python3]#

会在当前目录生成虚拟的python3.7环境目录superset

  1. 进入superset虚拟环境
[root@bigdata005 python3]# 
[root@bigdata005 python3]# . /opt/python3/superset/bin/activate
(superset) [root@bigdata005 python3]#
  • 此时安装和卸载python的包,都只影响虚拟环境
  • 可以使用deactivate退出虚拟环境

4. 安装mysql客户端、在mysql中创建superset元数据库

  1. 安装mysql客户端
(superset) [root@bigdata005 python3]# 
(superset) [root@bigdata005 python3]# pip3 install --upgrade pip
(superset) [root@bigdata005 python3]# 
(superset) [root@bigdata005 python3]# pip3 install pymysql
(superset) [root@bigdata005 python3]# 
  1. 创建superset元数据库
[root@bigdata005 ~]# 
[root@bigdata005 ~]# mysql -u root -pRoot_123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 922
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> create database superset;
Query OK, 1 row affected (0.01 sec)

mysql> 

5. 安装superset

(superset) [root@bigdata005 python3]# 
(superset) [root@bigdata005 python3]# pip3 install apache-superset -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
(superset) [root@bigdata005 python3]#

6. 配置

6.1 superset_config.py

  1. 在/root/.bashrc添加PYTHONPATH环境变量
export PYTHONPATH=/opt/python3/superset
  1. 在PYTHONPATH下,新增superset_config.py,内容如下:
(superset) [root@bigdata005 superset]# pwd
/opt/python3/superset
(superset) [root@bigdata005 superset]# 
(superset) [root@bigdata005 superset]# touch superset_config.py
(superset) [root@bigdata005 superset]# 
(superset) [root@bigdata005 superset]# vi superset_config.py 
(superset) [root@bigdata005 superset]# 
(superset) [root@bigdata005 superset]# cat superset_config.py 
# Superset specific config
ROW_LIMIT = 5000

SUPERSET_WEBSERVER_PORT = 8088

# Flask App Builder configuration
# Your App secret key
SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h'

# The SQLAlchemy connection string to your database backend
# This connection defines the path to the database that stores your
# superset metadata (slices, connections, tables, dashboards, ...).
# Note that the connection information to connect to the datasources
# you want to explore are managed directly in the web UI
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:Root_123@bigdata005:3306/superset?charset=utf8'

(superset) [root@bigdata005 superset]# 
  • superset的默认参数查看请点这里
  • Flask的默认参数查看请点这里

6.2 中文的配置

修改/opt/python3/superset/lib/python3.7/site-packages/superset/config.py文件, 修改内容如下:

BABEL_DEFAULT_LOCALE = "zh"

7. superset初始化相关操作

  1. superset数据库初始化
(superset) [root@bigdata005 python3]# 
(superset) [root@bigdata005 python3]# superset db upgrade
(superset) [root@bigdata005 python3]# 
  1. 设置Flask的APP为superset
(superset) [root@bigdata005 python3]# 
(superset) [root@bigdata005 python3]# export FLASK_APP=superset
(superset) [root@bigdata005 python3]# 
  1. superset管理员用户名初始化
(superset) [root@bigdata005 python3]# 
(superset) [root@bigdata005 python3]# superset fab create-admin
/opt/python3/superset/lib/python3.7/site-packages/pandas/compat/__init__.py:109: UserWarning: Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError.
  warnings.warn(msg)
logging was configured successfully
2021-08-20 10:55:54,786:INFO:superset.utils.logging_configurator:logging was configured successfully
2021-08-20 10:55:54,793:INFO:root:Configured event logger of type 
/opt/python3/superset/lib/python3.7/site-packages/flask_caching/__init__.py:202: 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
2021-08-20 10:55:55,054:INFO:superset.utils.screenshots:No PIL installation found
Username [admin]: admin
User first name [admin]: admin
User last name [user]: admin
Email [[email protected]]: [email protected]
Password: 
Repeat for confirmation: 
Recognized Database Authentications.
Admin User admin created.
(superset) [root@bigdata005 python3]#
  • 用户名为:admin, 用户密码为:admin123
  1. 加载superset的测试数据、图表、看板
    1. 因为默认会从github上下载测试数据,下载慢且会失败,所以我们从github测试数据地址下载数据
    2. 上传解压到我们的文件服务器上,文件服务器的部署请参考使用Tomcat10.0.10搭建一个文件下载服务器
    3. 文件服务器目录结构如下
[root@bigdata005 download2]# 
[root@bigdata005 download2]# pwd
/opt/tomcat/apache-tomcat-10.0.10/download2
[root@bigdata005 download2]# 
[root@bigdata005 download2]# cd superset/
[root@bigdata005 superset]# 
[root@bigdata005 superset]# ls
examples-data-master  examples-data-master.zip
[root@bigdata005 superset]# 
[root@bigdata005 superset]# cd examples-data-master
[root@bigdata005 examples-data-master]# 
[root@bigdata005 examples-data-master]# ll
总用量 25240
-rw-r--r--. 1 root root     9836 8月  11 09:42 airports.csv.gz
-rw-r--r--. 1 root root     1267 8月  11 09:42 bart-lines.json.gz
-rw-r--r--. 1 root root     6686 8月  11 09:42 birth_france_data_for_country_map.csv
-rw-r--r--. 1 root root   735076 8月  11 09:42 birth_names2.json.gz
-rw-r--r--. 1 root root   734913 8月  11 09:42 birth_names.json.gz
-rw-r--r--. 1 root root 14752439 8月  11 09:42 countries.json.gz
drwxr-xr-x. 3 root root       22 8月  11 09:42 datasets
-rw-r--r--. 1 root root      985 8月  11 09:42 energy.json.gz
-rw-r--r--. 1 root root  1897423 8月  11 09:42 flight_data.csv.gz
-rw-r--r--. 1 root root    38387 8月  11 09:42 multiformat_time_series.json.gz
-rw-r--r--. 1 root root       84 8月  11 09:42 NOTICE
-rw-r--r--. 1 root root  4427142 8月  11 09:42 paris_iris.json.gz
-rw-r--r--. 1 root root   264250 8月  11 09:42 random_time_series.json.gz
-rw-r--r--. 1 root root      125 8月  11 09:42 README.md
-rw-r--r--. 1 root root  2103726 8月  11 09:42 san_francisco.csv.gz
-rw-r--r--. 1 root root    47217 8月  11 09:42 sf_population.json.gz
-rw-r--r--. 1 root root   778847 8月  11 09:42 tutorial_flights.csv
-rw-r--r--. 1 root root     5030 8月  11 09:42 unicode_utf8_unixnl_test.csv
[root@bigdata005 examples-data-master]# 
    1. 修改/opt/python3/superset/lib/python3.7/site-packages/superset/examples/helpers.py,内容如下:
BASE_URL = "http://bigdata005:8090/download2/superset/examples-data-master/"
    1. 说明:/opt/python3/superset/lib/python3.7/site-packages/superset/examples/configs/datasets/examples目录下xxx.yaml文件中,也有很多github的链接,链接直接打开文件而不是下载;链接的父地址也打不开;链接文件的内容和上面下载的examples-data目录的内容不一样;所以只能多次执行superset load_examples解决
    2. 执行测试数据加载命令superset load_examples
  1. superset初始化
(superset) [root@bigdata005 python3]#
(superset) [root@bigdata005 python3]# superset init
(superset) [root@bigdata005 python3]#

8. 启动

(superset) [root@bigdata005 python3]# 
(superset) [root@bigdata005 python3]# nohup superset run -h 0.0.0.0 -p 8088 --with-threads --reload >> /opt/python3/superset/superset.log 2>&1 &
[1] 17930
(superset) [root@bigdata005 python3]# 

9. 查看web页面

通过http://bigdata005:8088进行查看,如下图所示:
Centos7安装可视化工具Superset1.2.0(含中文配置)_第1张图片

你可能感兴趣的:(Superset,superset,可视化工具,1.2.0,centos,中文汉化)