superset是可视化数据工具。本以为在centos7上面可以很快速的安装,但是花了一天的时间。遇到了不少坑。
1,不要用python2去装superset,我装的superset版本是0.25.5,会报以下错。
Flask-AppBuilder requires Python '~=3.6' but the running Python is 2.7.5
2,安装包
# 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,创建虚拟环境
# cd /opt && virtualenv-3 superset # cd superset && source ./bin/activate (superset) [root@bigserver4 superset]# deactivate //退出 [root@bigserver4 superset]#
4,安装mysqlclient,从该步起虚拟环境中执行
(superset) [root@bigserver4 superset]# pip3 install mysqlclient Collecting mysqlclient Using cached mysqlclient-1.4.6.tar.gz (85 kB) Building wheels for collected packages: mysqlclient Building wheel for mysqlclient (setup.py) ... done Created wheel for mysqlclient: filename=mysqlclient-1.4.6-cp36-cp36m-linux_x86_64.whl size=96322 sha256=07edc48e69a9deac80058dd54117a0dc0b6e560e439239e005ce5f27bfaf27bb Stored in directory: /root/.cache/pip/wheels/c6/8c/80/527c233e7cb169f828b7168ebeab0fc5206d09b0fa133472fb Successfully built mysqlclient Installing collected packages: mysqlclient Successfully installed mysqlclient-1.4.6
5,创建数据库
mysql> show variables like "%char%"; mysql> create database superset mysql> use superset mysql> alter database superset character set utf8; mysql> grant all privileges on superset.* to tank@% identified by 'superset+123'; mysql> flush privileges;
注意:字符集不设置,默认是latin1,这会导致中文乱码。
6,创建superset配置文件
(superset) [root@bigserver4 superset]# vim /opt/superset/bin/superset_config.py # -*- coding: utf-8 -*- ROW_LIMIT = 5000 SUPERSET_WORKERS = 4 SUPERSET_WEBSERVER_PORT = 8388 SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h' SQLALCHEMY_DATABASE_URI = 'mysql://tank:*****@10.0.40.200/superset?charset=utf8' WTF_CSRF_ENABLED = True MAPBOX_API_KEY = '' BABEL_DEFAULT_LOCALE='zh' LANGUAGES = { 'zh': {'flag': 'cn', 'name': 'Chinese'}, 'en': {'flag': 'us', 'name': 'English'} }
7,安装superset
(superset) [root@bigserver4 superset]# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple superset==999999 //找不到,就显示可用版本 (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,修改时区
# vim /opt/superset/lib/python3.6/site-packages/superset/config.py #DRUID_TZ = tz.tzutc() DRUID_TZ = tz.gettz('Asia/Shanghai')
9,创建管理员账号
(superset) [root@bigserver4 bin]# fabmanager create-admin --app superset fabmanager is going to be deprecated in 2.2.X, you can use the same commands on the improved 'flask fab <command>' Username [admin]: admin User first name [admin]: admin User last name [user]: admin Email [admin@fab.org]: admin@admin.com Password: Repeat for confirmation: Loaded your LOCAL configuration at [/opt/superset/bin/superset_config.py] Recognized Database Authentications. 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,初始化数据库
(superset) [root@bigserver4 superset]# superset db upgrade //初始化Superset (superset) [root@bigserver4 superset]# superset load_examples //导入样例数据 (superset) [root@bigserver4 superset]# superset init //创建默认角色和权限
11,启动superset
(superset) [root@bigserver4 superset]# superset runserver Loaded your LOCAL configuration at [/opt/superset/bin/superset_config.py] 2020-03-25 16:05:41,859:INFO:root:The Gunicorn 'superset runserver' command is deprecated. Please use the 'gunicorn' command instead. Starting server with command: gunicorn -w 4 --timeout 60 -b 0.0.0.0:8388 --limit-request-line 0 --limit-request-field_size 0 superset:app [2020-03-25 16:05:42 +0800] [9266] [INFO] Starting gunicorn 20.0.4 [2020-03-25 16:05:42 +0800] [9266] [INFO] Listening at: http://0.0.0.0:8388 (9266) [2020-03-25 16:05:42 +0800] [9266] [INFO] Using worker: sync [2020-03-25 16:05:42 +0800] [9269] [INFO] Booting worker with pid: 9269 [2020-03-25 16:05:42 +0800] [9270] [INFO] Booting worker with pid: 9270 [2020-03-25 16:05:42 +0800] [9273] [INFO] Booting worker with pid: 9273 [2020-03-25 16:05:42 +0800] [9274] [INFO] Booting worker with pid: 9274 Loaded your LOCAL configuration at [/opt/superset/bin/superset_config.py] Loaded your LOCAL configuration at [/opt/superset/bin/superset_config.py] Loaded your LOCAL configuration at [/opt/superset/bin/superset_config.py] 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
# yum install supervisor # cat /etc/supervisord.d/superset.ini [program:superset] 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 directory=/opt/superset redirect_stderr=true autostart=true autorestart=true starttries=3 user=root stderr_logfile=/var/log/superset/err.log stdout_logfile=/var/log/superset/log.log # systemctl start supervisord # supervisorctl status superset RUNNING pid 413602, uptime 0:42:02
转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/server/2387.html