1、Python版本要求
Superset支持的python版本为Python 2.7 and Python 3.4+. Python 3 是推荐的版本, Python 2.6目前是不支持。
2、安装操作系统软件依赖
yum install gcc libffi-devel python-devel python-pippython-wheel openssl-devel libsasl2-devel openldap-devel
这步很关键,如果缺少依赖,在装virtualenv和Superset时,会报缺少相应文件
3、建议是在virtualenv环境下安装Superset, 这样可以避免Python版本冲突
(1)安装virtualenv
pip install virtualenv
(2)创建ven环境
virtualenv venv
(3)激活ven环境
. ./venv/bin/activate
(4)如果要退出该环境则执行:
deactivate
4、安装Superset
(1)安装Superset
pip install superset
(2)创建管理员用户名和密码
fabmanager create-admin --app superset
(3)初始化Superset
superset db upgrade
(4)装载初始化样例数据
superset load_examples
(5)创建默认角色和权限
superset init
(6)启动Superset
superset runserver
(7) 访问http://localhost:8088,验证是否正常启动,如出现下面页面说明OK 、
注:我这个页面是经过汉化后的页面,开始的登录界面全是英文 5、Superset汉化 (1)进入Superset安装目录,执行以下命令,创建相应目录: mkdir -p translations/zh/LC_MESSAGES (2)下载汉化的mo文件 wget https://github.com/airbnb/superset/raw/0.18.5
/superset/translations/zh/LC_MESSAGES/messages.mo
也可以下载messages.po文件,自己手动去汉化,再将po文件编译为mo文件,编译方式,执行命令:
msgfmt messages.po -o messages.mo
(3)修改config.py文件,并重启Superset ,修改部分如下:
# Setup default language
BABEL_DEFAULT_LOCALE = 'zh'
# Your application default translation path
BABEL_DEFAULT_FOLDER = 'babel/translations'
# The allowed translation for you app
LANGUAGES = {
#'en': {'flag': 'us', 'name': 'English'},
# 'fr': {'flag': 'fr', 'name': 'French'},
'zh': {'flag': 'cn', 'name':'Chinese'}
}
(4)清理浏览器缓存则可以看到汉化成功
1、ImportError: /usr/local/lib/python2.7/site-packages/pysqlite2/_sqlite.so
: undefined symbol: sqlite3_stmt_readonly
解决:
1,安装 sqlite-devel 包:
yum install sqlite-devel -y
2,重新编译python源码
./configure
make
make altinstall
2、汉化
下载后系统带的messages.po只是汉化了用户权限,需要将下载
wget https://github.com/airbnb/superset/raw/0.18.5
/superset/translations/zh/LC_MESSAGES/messages.mo,但是下载messages.po却没有汉化用户权限的那部分,需要将两者合并到一起安装,安装时会报
/messages.po.2:1156: duplicate messagedefinition...
./messages.po.2:728: ...this is the locationof the first definition
./messages.po.2:1222: duplicate messagedefinition...
./messages.po.2:760: ...this is the locationof the first definition
./messages.po.2:1439: duplicate messagedefinition...
./messages.po.2:536: ...this is the locationof the first definition
./messages.po.2:1444: duplicate messagedefinition...
./messages.po.2:540: ...this is the locationof the first definition
./messages.po.2:1449: duplicate messagedefinition...
./messages.po.2:544: ...this is the locationof the first definition
将1156,1156,1439,1444,1449处注释掉即可。
msgfmt ./messages.po -o ./messages.mo
会报msgfmt命令不存在,需要安装
yum install gettext
重新执行msgfmt ./messages.po -o ./messages.mo
3、将Superset内置数据库sqlite转换为mysql
修改
vi/opt/venv/lib/python2.7/site-packages/superset/config.py文件中的
#SQLALCHEMY_DATABASE_URI = 'sqlite:///' +os.path.join(DATA_DIR, 'superset.db')
#mysql
SQLALCHEMY_DATABASE_URI ='mysql://root:[email protected]:3306/superset?charset=utf8'
执行下面的命令:
Create anadmin user
fabmanager create-admin --app superset
# Initialize the database
superset db upgrade
# Load some data to play with
superset load_examples
# Create default roles and permissions
superset init
# Start the web server on port 8088
superset runserver -p 8088
如果是将Superset内置数据库转换到其他机器上同一个数据库中,只需要将database转移过去即可。修改配置文件,重新启动
4,常用的连接
需要安装相应包
database |
pypi package |
SQLAlchemy URI prefix |
MySQL |
pip install mysqlclient |
mysql:// |
Postgres |
pip install psycopg2 |
postgresql+psycopg2:// |
Presto |
pip install pyhive |
presto:// |
Oracle |
pip install cx_Oracle |
oracle:// |
sqlite |
|
sqlite:// |
Redshift |
pip install sqlalchemy-redshift |
postgresql+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:// |
Vertica |
pip install sqlalchemy-vertica-python |
vertica+vertica_python:// |
ClickHouse |
pip install sqlalchemy-clickhouse |
clickhouse:// |
Hive连接:hive://hive@ip:10000
MySQL连接 :mysql://username:password@ip:3306/superset_test?charset=utf8
Presto连接:presto://ip:8285
gp连接:postgresql+psycopg2://username:[email protected]/eamp