centos 7 安装 superset

张映 发表于 2020-03-25

分类目录: 服务器相关

标签:,

superset是可视化数据工具。本以为在centos7上面可以很快速的安装,但是花了一天的时间。遇到了不少坑。

1,不要用python2去装superset,我装的superset版本是0.25.5,会报以下错。

Flask-AppBuilder requires Python '~=3.6' but the running Python is 2.7.5

2,安装包

  1. # yum install mysql-devel python36-virtualenv gcc gcc-c++ libffi-devel python3-devel python3-pip python3-wheel openssl-devel openldap-devel  

如果报以下错误:

MySQLdb/_mysql.c:38:20: 致命错误:Python.h:没有那个文件或目录
#include "Python.h"

解决办法:yum install python3-devel

sasl/saslwrapper.h:22:23: 致命错误:sasl/sasl.h:没有那个文件或目录
#include <sasl/sasl.h>

解决办法:yum install cyrus-sasl-devel

3,创建虚拟环境

  1. # cd /opt && virtualenv-3 superset  
  2. # cd superset && source ./bin/activate  
  3. (superset) [root@bigserver4 superset]# deactivate //退出  
  4. [root@bigserver4 superset]#  

4,安装mysqlclient,从该步起虚拟环境中执行

  1. (superset) [root@bigserver4 superset]# pip3 install mysqlclient  
  2. Collecting mysqlclient  
  3.  Using cached mysqlclient-1.4.6.tar.gz (85 kB)  
  4. Building wheels for collected packages: mysqlclient  
  5.  Building wheel for mysqlclient (setup.py) ... done  
  6.  Created wheel for mysqlclient: filename=mysqlclient-1.4.6-cp36-cp36m-linux_x86_64.whl size=96322 sha256=07edc48e69a9deac80058dd54117a0dc0b6e560e439239e005ce5f27bfaf27bb  
  7.  Stored in directory: /root/.cache/pip/wheels/c6/8c/80/527c233e7cb169f828b7168ebeab0fc5206d09b0fa133472fb  
  8. Successfully built mysqlclient  
  9. Installing collected packages: mysqlclient  
  10. Successfully installed mysqlclient-1.4.6  

5,创建数据库

  1. mysql> show variables like "%char%";  
  2. mysql> create database superset  
  3. mysql> use superset  
  4. mysql> alter database superset character set utf8;  
  5. mysql> grant all privileges on superset.* to tank@% identified by 'superset+123';  
  6. mysql> flush privileges;  

注意:字符集不设置,默认是latin1,这会导致中文乱码。

6,创建superset配置文件

  1. (superset) [root@bigserver4 superset]# vim /opt/superset/bin/superset_config.py  
  2. # -*- coding: utf-8 -*-  
  3.   
  4. ROW_LIMIT = 5000  
  5. SUPERSET_WORKERS = 4  
  6. SUPERSET_WEBSERVER_PORT = 8388  
  7.   
  8. SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h'  
  9.   
  10. SQLALCHEMY_DATABASE_URI = 'mysql://tank:*****@10.0.40.200/superset?charset=utf8'  
  11.   
  12. WTF_CSRF_ENABLED = True  
  13.   
  14. MAPBOX_API_KEY = ''  
  15.   
  16. BABEL_DEFAULT_LOCALE='zh'  
  17. LANGUAGES = {  
  18. 'zh': {'flag''cn''name''Chinese'},  
  19. 'en': {'flag''us''name''English'}  
  20. }  

7,安装superset

  1. (superset) [root@bigserver4 superset]# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple superset==999999 //找不到,就显示可用版本  
  2. (superset) [root@bigserver4 superset]# pip3 install superset==0.25.5  

虽成功,但报以下错误:

ERROR: flask-jwt-extended 3.24.1 has requirement Flask>=1.0, but you'll have flask 0.12.5 which is incompatible.

解决办法:pip3 install flask-jwt-extended==3.18

8,修改时区

  1. # vim /opt/superset/lib/python3.6/site-packages/superset/config.py  
  2.   
  3. #DRUID_TZ = tz.tzutc()  
  4. DRUID_TZ = tz.gettz('Asia/Shanghai')  

9,创建管理员账号

  1. (superset) [root@bigserver4 bin]# fabmanager create-admin --app superset  
  2. fabmanager is going to be deprecated in 2.2.X, you can use the same commands on the improved 'flask fab <command>'  
  3. Username [admin]: admin  
  4. User first name [admin]: admin  
  5. User last name [user]: admin  
  6. Email [admin@fab.org]: admin@admin.com  
  7. Password:  
  8. Repeat for confirmation:  
  9. Loaded your LOCAL configuration at [/opt/superset/bin/superset_config.py]  
  10. Recognized Database Authentications.  
  11. Admin User admin created.  

报以下错误:

Was unable to import superset Error: cannot import name '_maybe_box_datetimelike'

解决办法:# pip3 install pandas==0.23.4

Was unable to import superset Error: markdown() takes 1 positional argument but 2 were given

解决办法:# pip3 install "markdown<3.0.0" superset

10,初始化数据库

  1. (superset) [root@bigserver4 superset]# superset db upgrade //初始化Superset  
  2. (superset) [root@bigserver4 superset]# superset load_examples //导入样例数据  
  3. (superset) [root@bigserver4 superset]# superset init //创建默认角色和权限  

11,启动superset

  1. (superset) [root@bigserver4 superset]# superset runserver  
  2. Loaded your LOCAL configuration at [/opt/superset/bin/superset_config.py]  
  3. 2020-03-25 16:05:41,859:INFO:root:The Gunicorn 'superset runserver' command is deprecated. Please use the 'gunicorn' command instead.  
  4. Starting server with command:  
  5. gunicorn -w 4 --timeout 60 -b 0.0.0.0:8388 --limit-request-line 0 --limit-request-field_size 0 superset:app  
  6.   
  7. [2020-03-25 16:05:42 +0800] [9266] [INFO] Starting gunicorn 20.0.4  
  8. [2020-03-25 16:05:42 +0800] [9266] [INFO] Listening at: http://0.0.0.0:8388 (9266)  
  9. [2020-03-25 16:05:42 +0800] [9266] [INFO] Using worker: sync  
  10. [2020-03-25 16:05:42 +0800] [9269] [INFO] Booting worker with pid: 9269  
  11. [2020-03-25 16:05:42 +0800] [9270] [INFO] Booting worker with pid: 9270  
  12. [2020-03-25 16:05:42 +0800] [9273] [INFO] Booting worker with pid: 9273  
  13. [2020-03-25 16:05:42 +0800] [9274] [INFO] Booting worker with pid: 9274  
  14. Loaded your LOCAL configuration at [/opt/superset/bin/superset_config.py]  
  15. Loaded your LOCAL configuration at [/opt/superset/bin/superset_config.py]  
  16. Loaded your LOCAL configuration at [/opt/superset/bin/superset_config.py]  
  17. Loaded your LOCAL configuration at [/opt/superset/bin/superset_config.py]  

报以下错误:

File "/opt/superset/lib/python3.6/site-packages/superset/templates/appbuilder/navbar_right.html", line 30, in top-level template code
{% if not current_user.is_anonymous() %}
TypeError: 'bool' object is not callable

找到navbar_right.html,把current_user.is_anonymous() ,改成current_user.is_anonymous

这样的报错很多,改过的文件如下:

/opt/superset/lib/python3.6/site-packages/superset/templates/appbuilder/navbar_right.html
/opt/superset/lib/python3.6/site-packages/superset/views/utils.py
/opt/superset/lib/python3.6/site-packages/superset/views/base.py
/opt/superset/lib/python3.6/site-packages/superset/views/core.py
/opt/superset/lib/python3.6/site-packages/superset/security.py

12,通过supervisor 自启动superset

  1. # yum install supervisor  
  2.   
  3. # cat /etc/supervisord.d/superset.ini  
  4. [program:superset]  
  5. command=/opt/superset/bin/gunicorn -w 4 --timeout 600 -b 0.0.0.0:38388 --limit-request-line 0 --limit-request-field_size 0 superset:app  
  6. directory=/opt/superset  
  7. redirect_stderr=true  
  8. autostart=true  
  9. autorestart=true  
  10. starttries=3  
  11. user=root  
  12. stderr_logfile=/var/log/superset/err.log  
  13. stdout_logfile=/var/log/superset/log.log  
  14.   
  15. # systemctl start supervisord  
  16.   
  17. # supervisorctl status  
  18. superset RUNNING pid 413602, uptime 0:42:02  

 



转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/server/2387.html