superset安装部署

来源:互联网 发布:c语言中调用文本文件 编辑:程序博客网 时间:2024/05/22 03:09
https://superset.incubator.apache.org/druid.html
https://superset.inccubator.apache.org/installation.html
OS: centos7
Superset版本:0.18.4
Python版本:2.7
Druid版本:0.9.2

步骤一:安装cryptography
cryptography的作用是将连接密码加密。

sudo yum upgrade python-setuptools
sudo yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel

步骤二,安装pip
如果还没有安装pip,就需要安装pip:
pip下载:
wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate

pip安装:
tar -xzvf pip-1.5.4.tar.gz
cd pip-1.5.4
python setup.py install
如果报错,请看:
https://zhidao.baidu.com/question/1240554972151163659.html

步骤三,安装virtualenv
官网推荐在virtualenv中安装 superset (Python 3 already ships virtualenv, for Python 2 you need to install it)。
pip install virtualenv
创建和激活一个 virtualenv :
# virtualenv is shipped in Python 3 aspyvenv
virtualenv venv
source ./bin/activate
想要退出virtualenv,直接输入:
deactivate

参考:http://www.cnblogs.com/tk091/p/3700013.html
注意:接下来都在virtualenv下操作。

步骤四,更新pip和setuptools:
pip install --upgrade setuptools pip

步骤五,安装mysqlclient。
将superset的元数据存储改成mysql,就需要这一步。
ROOT权限下
yum install mysql-devel
virtualenv下:
pip install mysqlclient

参考:将 superset 的sqlite 改成 MySQL :
https://github.com/apache/incubator-superset/issues/2467

步骤六,安装superset
1、添加superset的配置文件。
在python所在的目录(如,我这里是/hadoop/haozhuo/superset-venv/bin下),手动添加superset的配置文件superset_config.py。内容如下:

# ===============superset_config.py开始================
#使用python2.7,如果下面三行不加的话,使用中文时会出问题。
import sys # import sys package, if not already imported
reload(sys)
sys.setdefaultencoding('utf-8')
#---------------------------------------------------------
# Superset specific config
#---------------------------------------------------------
ROW_LIMIT = 5000
SUPERSET_WORKERS = 4
#默认是8088,改成8388
SUPERSET_WEBSERVER_PORT = 8388
#---------------------------------------------------------

#---------------------------------------------------------
# Flask App Builder configuration
#---------------------------------------------------------
# Your App secret key 这个我也不知道具体什么作用。按照官网就这么写了
SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h'

#元数据存储默认使用的是sqlite。SQLALCHEMY_DATABASE_URI = 'sqlite:////path/to/superset.db'
#我这里改成mysql
#mysql://用户名:密码@192.168.1.162/数据库名?charset=utf8
SQLALCHEMY_DATABASE_URI = 'mysql://datag:yjkdatag@192.168.1.162/superset?charset=utf8'
# Flask-WTF flag for CSRF
WTF_CSRF_ENABLED = True

# Set this API key to enable Mapbox visualizations
MAPBOX_API_KEY = ''
#汉化
BABEL_DEFAULT_LOCALE='zh'
LANGUAGES = {
'zh': {'flag': 'cn', 'name': 'Chinese'},
'en': {'flag': 'us', 'name': 'English'}
}

# =============== superset_config.py结束================


2) 安装
查看有哪些版本
pip查看superset所有可用版本(这里指定了镜像。官网的太慢),输入一个不存在的版本号,pip就会告诉你可用的版本号:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple superset==999999


安装
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple superset==0.18.4
如果不指定镜像,直接输入下面的即可:
pip install superset==0.18.4

卸载:
pip uninstall superset

3) 设置Druid的时区:
vi /hadoop/haozhuo/super/lib/python2.7/site-packages/superset/config.py
DRUID_TZ = tz.tzutc()
改成:DRUID_TZ = tz.gettz('Asia/Shanghai')
如下图:


4)初始化数据
fabmanager create-admin --app superset
然后需要输入:
Username [admin]: datag
User first name [admin]: zhang
User last name [user]: san
Email [admin@fab.org]: your_email@163.com
Password: 1234
Repeat for confirmation: 1234

# Initialize the databasesuperset db upgrade# Load some data to play with
# superset load_examples# Create default roles and permissionssuperset init

5) 汉化
从源码中下载
https://github.com/apache/incubator-superset/tree/master/superset/translations
这个目录,复制到
./lib/python2.7/site-packages/superset/下

自已翻译后需要将.po文件翻译成.mo文件:
pybabel compile -d translations

6)启动
# Start the web server on port 8088, use -p to bind to another ports
uperset runserver
或者指定端口:
superset runserver -p 8388 &

登录:
http://192.168.1.153:8388
# To start a development web server, use the -d switch# superset runserver -d
https://github.com/apache/incubator-superset/issues/1935
原创粉丝点击