ubuntu server superset大数据分析平台搭建

superset安装配置,大部分内容来自superset的官网;目前网上的文章都是比较早的,直接按照官网步骤即可,最近superset和flask更新后导致了不兼容的问题,安装过程中会报错,自己重新摸索了一下,记录下来,供有需要的人参考。

环境安装

系统依赖

sudo apt-get install build-essential libssl-dev libffi-dev python-dev python-pip libsasl2-dev libldap2-dev
ubuntu 16.04
sudo apt-get install build-essential libssl-dev libffi-dev python3.5-dev python-pip libsasl2-dev libldap2-dev

pip国内源配置

配置文件的位置
全局的位于 /etc/pip.conf
用户级别的位于 HOME/.pip/pip.conf 每个 virtualenv 也可以有自己的配置文件VIRTUAL_ENV/pip.conf

cd ~
mkdir ~/.pip
vi ~/.pip/pip.conf

配置文件的内容

[global]
trusted-host=mirrors.aliyun.com
index-url=http://mirrors.aliyun.com/pypi/simple

安装virtualenv

pip install virtualenv

创建&激活virtualenv

virtualenv superset
. ./superset/bin/activate

pip工具升级

pip install --upgrade setuptools pip

安装superset

安装superset

pip install superset==0.25.0

指定flask&sql版本号

pip uninstall Flask SQLAlchemy-Utils
pip install -U 'Flask~=0.12.2' 'SQLAlchemy-Utils~=0.0,<0.33'

创建管理员用户

fabmanager create-admin --app superset

初始化数据库

superset db upgrade

加载样例数据

superset load_examples

初始化默认角色和权限

superset init

获取mapbox api token

需要自己去mapbox官网注册申请public API key

创建superset_config.py配置文件

创建文件

vi ~/.superset/superset_config.py

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 = '修改为自己实际的superset.db路径'

# Flask-WTF flag for CSRF
WTF_CSRF_ENABLED = True
# Add endpoints that need to be exempt from CSRF protection
WTF_CSRF_EXEMPT_LIST = []
# A CSRF token that expires in 1 year
WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365

# Set this API key to enable Mapbox visualizations
MAPBOX_API_KEY = '修改为自己实际的API key'

配置PYTHONPATH

vi ~/.bashrc
添加如下一行
export PYTHONPATH=/home/fangqi/.superset/
source ~/.bashrc

运行superset服务

run server模式

Start the web server on port 8088, use -p to bind to another port

superset runserver

To start a development web server, use the -d switch

superset runserver -d

gunicorn模式

前台运行
gunicorn -w 2 --timeout 60 -b  0.0.0.0:8088 --limit-request-line 0 --limit-request-field_size 0 superset:app
后台运行
gunicorn -D -w 2 --timeout 60 -b  0.0.0.0:8088 --limit-request-line 0 --limit-request-field_size 0 superset:app

创建sh脚本

cd ~
vi superset.sh

. /home/fangqi/superset/bin/activate
/home/fangqi/superset.sh

sudo chmod +x superset.sh

关闭进程

查看gunicorn进程

pstree -ap|grep gunicorn

按pid终止单个进程

kill -9 PID

按进程名称终止进程

killall -9 gunicorn

mysql数据库连接配置

pip install pymysql
mysql+pymysql://账号:密码@host:3306/数据库名?charset=utf8

superset安装包位置

~/venv/lib/python2.7/site-packages/superset

运行信息

(superset) fangqi@ubuntu-server:~$ superset runserver
2018-05-12 14:54:03,775:INFO:root:The Gunicorn 'superset runserver' command is deprecated. Please use the 'gunicorn' command instead.
Starting server with command:
gunicorn -w 2 --timeout 60 -b  0.0.0.0:8088 --limit-request-line 0 --limit-request-field_size 0 superset:app

[2018-05-12 14:54:03 +0000] [2050] [INFO] Starting gunicorn 19.8.1
[2018-05-12 14:54:03 +0000] [2050] [INFO] Listening at: http://0.0.0.0:8088 (2050)
[2018-05-12 14:54:03 +0000] [2050] [INFO] Using worker: sync
[2018-05-12 14:54:03 +0000] [2054] [INFO] Booting worker with pid: 2054
[2018-05-12 14:54:04 +0000] [2055] [INFO] Booting worker with pid: 2055

你可能感兴趣的:(ubuntu server superset大数据分析平台搭建)