1 官网介绍
官网:https://superset.incubator.apache.org/
2 升级Python到3.6
python 官网下载:https://www.python.org/ftp/python/3.7.0/
2.1 安装wget
yum install wget
2.2 安装python
2.2.1 下载安装包
1. sudo su
2. wget -P /usr/local https://www.python.org/ftp/python/3.7.0//Python-3.7.0.tgz
3.tar -xzvf Python-3.3.0.tgz -C /usr/local #解压到指定目录
4.mkdir /usr/local/python3 #在编译前先在/usr/local建一个文件夹python3(作为python的安装路径,以免覆盖老的版本)
5../configure --prefix=/usr/local/python3 #开始编译
6.make
7.make install
8.mv /usr/bin/python /usr/bin/python_old2 #此时没有覆盖老版本,再将原来/usr/bin/python链接改为别的名字
9.ln -s /usr/local/python3/bin/python3 /usr/bin/python #再建立新版本python的链接
10.python -V
2.2.2 错误信息总结
2.2.2.1 问题描述
configure: error: in `/home/xiaoxu/Python-3.6.1':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
2.2.2.2 解决方法
# yum install gcc -y
2.3 配置python环境
2.3.1 备份python文件
cd /usr/bin
mv python python.bak
2.3.2 添加环境变量
vi /etc/profile
export PYTHON_HOME=/usr/local/python3/
export PATH=$PATH:$PYTHON_HOME/bin
source /etc/profile
2.3.3 创建软连接
sudo ln -s /usr/local/python3/bin/python3.6 /usr/bin/python
2.3.4 配置yum使用最新的python
vi /usr/bin/yum
将#!/usr/bin/python修改为#!/usr/bin/python2.7
vi /usr/libexec/urlgrabber-ext-down
将#!/usr/bin/python修改为#!/usr/bin/python2.7
2.3.5 查看python的版本
python -V
Python 3.6.1
3 配置superset需要的环境
3.1 安装需要的软件包
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
yum -y install sqlite-devel
在线安装pip
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py # 下载安装脚本
$ sudo python get-pip.py # 运行安装脚本
3.2 安装 virtualenv
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
pip install virtualenv
3.3 安装最新的 pip 和 和 setuptools
pip install --upgrade setuptools pip
pip install psycopg2-binary
4 stuperset 安装和初始化
源码安装
https://zhuanlan.zhihu.com/p/52502210
配置文件修改
https://zhuanlan.zhihu.com/p/45620490
4.1 按照以下几个简单步骤安装 Superset
安装Superset
pip install superset
创建管理员用户名和密码
fabmanager create-admin --app superset
记住以下的信息,作为登录使用
Username [admin]: admin
User first name [admin]: admin
User last name [user]: user
Email [admin@fab.org]: 123@qq.com
Password:
Repeat for confirmation:
Recognized Database Authentications.
Admin User admin created.
详细日志请查看:http://blog.csdn.net/xfg0218/article/details/79435399
初始化Superset
superset db upgrade
装载初始化样例数据
superset load_examples
详细日志请查看:http://blog.csdn.net/xfg0218/article/details/79435443
创建默认角色和权限
superset init
详细日志请查看:http://blog.csdn.net/xfg0218/article/details/79435497
启动Superset
superset runserver
详细日志请查看:http://blog.csdn.net/xfg0218/article/details/79435525
4.2 查看启动参数
superset runserver --help
Usage: superset runserver [OPTIONS]
Starts a Superset web server.
Options:
-d, --debug Start the web server in debug mode
--console-log Create logger that logs to the browser console
(implies -d)
-n, --no-reload Don't use the reloader in debug mode
-a, --address TEXT Specify the address to which to bind the web server
-p, --port INTEGER Specify the port on which to run the web server
-w, --workers INTEGER Number of gunicorn web server workers to fire up
[DEPRECATED]
-t, --timeout INTEGER Specify the timeout (seconds) for the gunicorn web
server [DEPRECATED]
-s, --socket TEXT Path to a UNIX socket as an alternative to
address:port, e.g. /var/run/superset.sock. Will
override the address and port values. [DEPRECATED]
5 修改superset配置文件
5.1 搜索配置文件
# find / -name config.py
/usr/local/lib/python3.7/site-packages/setuptools/config.py
/usr/local/lib/python3.7/site-packages/botocore/config.py
/usr/local/lib/python3.7/site-packages/flask/config.py
/usr/local/lib/python3.7/site-packages/flask_login/config.py
/usr/local/lib/python3.7/site-packages/sqlalchemy/testing/config.py
/usr/local/lib/python3.7/site-packages/alembic/config.py
/usr/local/lib/python3.7/site-packages/alembic/testing/config.py
/usr/local/lib/python3.7/site-packages/gunicorn/config.py
/usr/local/lib/python3.7/site-packages/numpy/distutils/command/config.py
/usr/local/lib/python3.7/site-packages/tabulator/config.py
/usr/local/lib/python3.7/site-packages/tableschema/config.py
/usr/local/lib/python3.7/site-packages/superset/config.py
/usr/local/lib/python3.7/site-packages/pandas/core/config.py
/usr/local/lib/python3.7/logging/config.py
/usr/local/lib/python3.7/idlelib/config.py
/usr/local/lib/python3.7/distutils/command/config.py
/usr/local/lib/python3.7/distutils/config.py
/usr/local/Python-3.7.2/Lib/distutils/command/config.py
/usr/local/Python-3.7.2/Lib/distutils/config.py
/usr/local/Python-3.7.2/Lib/logging/config.py
/usr/local/Python-3.7.2/Lib/idlelib/config.py
/home/superset/software/Python-3.6.1/Lib/distutils/command/config.py
/home/superset/software/Python-3.6.1/Lib/distutils/config.py
/home/superset/software/Python-3.6.1/Lib/logging/config.py
/home/superset/software/Python-3.6.1/Lib/idlelib/config.py
5.2 修改限制返回数据的行数
在安装服务器上搜索关键字,以下标红的就是需要修改的配置文件,主要修改以下参数
SQL_MAX_ROW = 100
# Limit to be returned to the frontend.
DISPLAY_MAX_ROW = 100
# Maximum number of tables/views displayed in the dropdown window in SQL Lab.
MAX_TABLE_NAMES = 100
5.3 修改使用中文界面
把以下的BABEL_DEFAULT_LOCALE = 'en' 修改成BABEL_DEFAULT_LOCALE = 'zh'即可
# Setup default language
BABEL_DEFAULT_LOCALE = 'zh'
# Your application default translation path
BABEL_DEFAULT_FOLDER = 'superset/translations'
# The allowed translation for you app
LANGUAGES = {
'en': {'flag': 'us', 'name': 'English'},
'it': {'flag': 'it', 'name': 'Italian'},
'fr': {'flag': 'fr', 'name': 'French'},
'zh': {'flag': 'cn', 'name': 'Chinese'},
'ja': {'flag': 'jp', 'name': 'Japanese'},
'de': {'flag': 'de', 'name': 'German'},
'pt': {'flag': 'pt', 'name': 'Portuguese'},
'pt_BR': {'flag': 'br', 'name': 'Brazilian Portuguese'},
'ru': {'flag': 'ru', 'name': 'Russian'},
}
5.4 修改使用数据库保存源数据
把默认的sqlite修改成postgresql数据源
# The SQLAlchemy connection string.
# SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(DATA_DIR, 'superset.db')
# SQLALCHEMY_DATABASE_URI = 'mysql://myapp@localhost/myapp'
SQLALCHEMY_DATABASE_URI = 'postgresql://postgres:*****@127.0.0.1/postgres'
5 安装superset需要的链接驱动
按照以下需要安装不同的驱动包
database | pypi package | SQLAlchemy URI prefix |
---|---|---|
database | pypi package | SQLAlchemy URI prefix |
MySQL | pip install mysqlclient | mysql:// |
Postgres | pip install psycopg2 | postgresql+psycopg2:// |
Presto | pip install pyhive | presto:// |
Hive | pip install pyhive | hive:// |
Oracle | pip install cx_Oracle | oracle:// |
sqlite | sqlite:// | |
Snowflake | pip install snowflake-sqlalchemy | snowflake:// |
Redshift | pip install sqlalchemy-redshift | redshift+psycopg2:// |
MSSQL | pip install pymssql | mssql:// |
Impala | pip install impyla | impala:// |
SparkSQL | pip install pyhive | jdbc+hive:// |
Greenplum | pip install psycopg2 | postgresql+psycopg2:// |
Athena | pip install "PyAthenaJDBC>1.0.9" | awsathena+jdbc:// |
Athena | pip install "PyAthena>1.2.0" | awsathena+rest:// |
Vertica | pip install sqlalchemy-vertica-python | vertica+vertica_python:// |
ClickHouse | pip install sqlalchemy-clickhouse | clickhouse:// |
Kylin | pip install kylinpy | kylin:// |
BigQuery | pip install pybigquery | bigquery:// |
Teradata | pip install sqlalchemy-teradata | teradata:// |