网上看到superset,比较感兴趣,虚机上搭一下,记录操作过程。

版本信息:CentOS 6.6 + python 2.7.12 + mysql 5.1.73 + setuptools 36.5.0 + pip-9.0.1

一、安装superset

1、升级Python

安装虚机操作CentOS6.6的系统环境,过程略,运行如下脚本(替换yum源、升级Python、安装Python setuptools、pip)

#!/bin/bash
#####################################################################################
#基础设置:
# 启用163yum源
# 升级Python
#
#
#####################################################################################
v_down_tools=~/down_loads yum -y gcc gcc-c++ make cmake openssl openssl-devel zlib zlib-devel [[ ! -d ${v_down_tools} ]] && mkdir -p ${v_down_tools} ###################################启用163yum源######################################
yum_upgrade_163(){
cd ${v_down_tools}
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
if `grep -q 'release 5' /etc/redhat-release` ; then
OS_version='CentOS5'
elif `grep -q 'release 6' /etc/redhat-release` ; then
OS_version='CentOS6'
elif `grep -q 'release 7' /etc/redhat-release` ; then
OS_version='CentOS7'
fi
wget -N http://mirrors.163.com/.help/${OS_version}-Base-163.repo
mv ${OS_version}-Base-.repo /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum makecache
} ##################################升级Python###########################################
python_upgrade(){
# 安装Python包
cd ${v_down_tools}
wget -N https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
tar -xf Python-2.7..tar.xz
if [ -d Python-2.7. ]
then
cd Python-2.7.
./configure --prefix=/usr/local/python-2.7.
make && make install
mv /usr/bin/python /usr/bin/python_backup
#ln -s /usr/local/python-2.7. /usr/local/python
ln -s /usr/local/python-2.7./bin/python /usr/bin/python2.
ln -s /usr/local/python-2.7./bin/python /usr/bin/python
ln -s /usr/local/python-2.7./lib/python2. /usr/lib/python2.
ln -s /usr/local/python-2.7./lib/python2. /usr/lib/python
ln -s /usr/local/python-2.7./lib/python2. /usr/lib64/python2.
ln -s /usr/local/python-2.7./lib/python2. /usr/lib64/python
fi
##设置yum,注意sed的分隔符这里用了|
sed -i "s|#!/usr/bin/python|#!/usr/bin/python2.6|g" /usr/bin/yum
##添加环境变量
echo 'export PYTHON_HOME=/usr/local/python-2.7.12' >> /etc/profile
echo 'export PATH=$PATH:$PYTHON_HOME/bin' >> /etc/profile
source /etc/profile } python_setuptools_pip{
cd ${v_down_tools}
##安装setuptools,注意先安装setuptools才能再安装pip
wget https://pypi.python.org/packages/a4/c8/9a7a47f683d54d83f648d37c3e180317f80dc126a304c45dc6663246233a/setuptools-36.5.0.zip#md5=704f500dd55f4bd0be905444f3ba892c
unzip setuptools-36.5..zip
cd setuptools-36.5.
#python setup.py --help
python setup.py build
python setup.py install cd ${v_down_tools}
##安装pip
wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
tar -xf pip-9.0..tar.gz
cd pip-9.0.
#python setup.py -h
python setup.py build
python setup.py install ##升级
#pip install --upgrade setuptools pip } main(){
yum_upgrade_163
python_upgrade
python_setuptools_pip
}
main

注:Python setuptools和pip从这里获取:PyPI - the Python Package Index : Python Package Index https://pypi.python.org/pypi

这里选择的是最新版的,脚本运行完毕,正常情况下已经安装好pip了,可以执行命令查看一下是否安装成功。

2、安装、设置MySQL

(1)安装

# yum -y install mysql-server mysql-client mysql-devel    ##一定要安装mysql-devel,否则安装MySQL-python会报错

(2)启动、初始化服务

# service mysqld start
# /usr/bin/mysql_secure_installation #设置用户、密码等后,创建supersetdb数据库

具体过程根据提示进行就可以。

3、部署superset

(1)安装并使用virtualenv部署superset工程

pip install virtualenv #安装
virtualenv env      #创建虚拟环境
source env/bin/activate #进入虚拟环境
pip install superset #安装supperset
pip install MySQL-python #安装驱动

(2)设置supperset的连接参数

vim env/lib/python2./site-packages/superset_config.py

内容如下:

#---------------------------------------------------------

# Superset specific config

#---------------------------------------------------------

ROW_LIMIT = 

SUPERSET_WORKERS = 

SUPERSET_WEBSERVER_PORT = 

#---------------------------------------------------------

#---------------------------------------------------------

# Flask App Builder configuration

#---------------------------------------------------------

# Your App secret key

SECRET_KEY = '324872319jhdfasdhcx@!#!@'

# The SQLAlchemy connection string to yourdatabase backend

# This connection defines the path to thedatabase that stores your

# superset metadata (slices, connections,tables, dashboards, ...).

# Note that the connection information toconnect to the datasources

# you want to explore are managed directlyin the web UI

# SQLALCHEMY_DATABASE_URI = 'mysql://dbuser:dbpasswd@192.168.1.158:3306/spdbname?charset=utf8'
SQLALCHEMY_DATABASE_URI = 'mysql://root:123456@192.168.116.130:3306/supersetdb?charset=utf8' # Flask-WTF flag for CSRF CSRF_ENABLED = True # Set this API key to enable Mapboxvisualizations MAPBOX_API_KEY = ''

(3)初始化superset并启动服务

依次执行如下命令

# fabmanager create-admin --app superset # 创建一个管理员用户(您将在设置密码之前提示用户设置用户名、姓氏和姓氏)
# superset db upgrade # 初始化数据库
# superset load_examples # 加载样例数据
# superset init # 创建默认角色和权限
# nohup superset runserver -p & #后台启动

打开浏览器,访问配置的地址,ok,其中一个页面截图如下:

4、汉化

这里只能做到部分汉化,不完整

(1)编辑配置文件superset_config.py

编辑上面的superset_config.py配置文件,在末尾添加如下配置

# ---------------------------------------------------
# Babel config for translations
# ---------------------------------------------------
# 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'},
#'it': {'flag': 'it', 'name': 'Italian'},
#'fr': {'flag': 'fr', 'name': 'French'},
'zh': {'flag': 'cn', 'name': 'Chinese'},
}

(2)安装mo文件

cd 【superset安装目录】/lib/python2.7/site-packages/flask_appbuilder/translations/zh/LC_MESSAGES   ##目录不存在,则 mkdir -p 创建
wget https://raw.githubusercontent.com/apache/incubator-superset/master/superset/translations/zh/LC_MESSAGES/messages.mo

重启服务

(3)刷新浏览器

汉化效果如下:

补充:若使用默认的sqlite数据库

    ##先安装sqlite,再安装pysqlite
yum -y install sqlite sqlite-devel ##安装pysqlite (默认使用pysqlite)
wget https://pypi.python.org/packages/42/02/981b6703e3c83c5b25a829c6e77aad059f9481b0bbacb47e6e8ca12bd731/pysqlite-2.8.3.tar.gz#md5=033f17b8644577715aee55e8832ac9fc
tar -xf pysqlite-2.8..tar.gz
cd pysqlite-2.8.
#python setup.py -h
python setup.py build
python setup.py install

参考:

SQLite和PySqlite的使用 - 101010 - 博客园 http://www.cnblogs.com/fortwo/archive/2013/04/22/3035691.html (默认使用sqlite数据库,若用sqlite可参考)

Python的虚拟环境virtualenv_王志_新浪博客 http://blog.sina.com.cn/s/blog_4ddef8f80101eu0w.html

CentOS下安装Superset-zhmg23 http://zhmgz.lofter.com/post/90909_e745201

Superset安装部署 - duncan - CSDN博客 http://blog.csdn.net/dzjun/article/details/62421718

官方文档:https://superset.incubator.apache.org/installation.html

supperset (python 2.7.12 + mysql)记录的更多相关文章

  1. Python高级特性: 12步轻松搞定Python装饰器

    12步轻松搞定Python装饰器 通过 Python 装饰器实现DRY(不重复代码)原则:  http://python.jobbole.com/84151/   基本上一开始很难搞定python的装 ...

  2. Python操作数据库之 MySQL

    Python操作数据库之MySQL 一.安装Python-MySQLdb模块 Python-MySQLdb是一个操作数据库的模块,Python 通过它对 mysql 数据实现各种操作. 如果要源码安装 ...

  3. mysql 5.7以上版本安装配置方法图文教程(mysql 5.7.12\mysql 5.7.13\mysql 5.7.14)(转)

    http://www.jb51.net/article/90302.htm ******************************* 这篇文章主要为大家分享了MySQL 5.7以上缩版本安装配置 ...

  4. python程序中使用MySQL数据库

    目录 python程序中使用MySQL数据库 1 pymysql连接数据库 2 sql 注入 3 增删改查操作 4 pymysql使用总结 python程序中使用MySQL数据库 1.python中使 ...

  5. Python进阶----索引原理,mysql常见的索引,索引的使用,索引的优化,不能命中索引的情况,explain执行计划,慢查询和慢日志, 多表联查优化

    Python进阶----索引原理,mysql常见的索引,索引的使用,索引的优化,不能命中索引的情况,explain执行计划,慢查询和慢日志, 多表联查优化 一丶索引原理 什么是索引:       索引 ...

  6. 【转】Centos升级Python 2.7.12并安装pip、ipython

    Centos系统一般默认就安装有Python2.6.6版本,不少软件需要2.7以上的,通过包管理工具安装不了最新的版本,通过源码编译可以方便安装指定版本,只需要把下面版本的数字换成你想要的版本号. 1 ...

  7. python课程第二周重点记录

    python课程第二周重点记录 1.元组的元素不可被修改,元组的元素的元素可以被修改(字典在元组中,字典的值可以被修改) 2.个人感觉方便做加密解密 3.一些方法的使用 sb = "name ...

  8. python爬虫循环导入MySql数据库

    1.开发环境 操作系统:win10    Python 版本:Python 3.5.2   MySQL:5.5.53 2.用到的模块 没有的话使用pip进行安装:pip install xxx     ...

  9. python入门(12)dict

    python入门(12)dict Python内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度. 举个例 ...

随机推荐

  1. 11.5 Daily Scrum

    请把现在当成11月5日······   Today's tasks  Tomorrow's tasks 丁辛 餐厅列表数据结构设计 餐厅列表UI设计             李承晗           ...

  2. 第二阶段冲刺——seven

    个人任务: 马佳慧:设计界面背景,统一风格. 王金萱:整体运行测试上传到公网上的程序. 季方:修改优化已上传的代码. 司宇航:整体调试程序继续优化. 站立会议: 任务看板和燃尽图:

  3. 冲刺Two之站立会议2

    今天我们进行了主界面部分的设置,因为它包含的部分有很多,所以就只能它拆分进行一一突破.今天主要完成了主界面的框架搭建,以及添加了需要的按钮,包括好友管理,退出登录,开启聊天通信界面的内容等.

  4. vs2013c#测试using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1_CXY { class Program { stati

    首先安装Unit Test Generator.方法为:工具->扩展和更新->联机->搜索“图标为装有蓝色液体的小试管.Unit Test Generator”, 编写代码,生成一个 ...

  5. 我们的团队-IT梦想队

    IT梦想队 队长:李遇塘 队员:王长.周兴荣.朱岭杰.马婧婧 团队宣言:  一匹狼战斗力低,但一群狼的我们无所畏惧!李遇塘http://www.cnblogs.com/Liyutang/ 王 长htt ...

  6. Installing OpenSSH from the Settings UI on Windows Server 2019 or Windows 10 1809

    Installing OpenSSH from the Settings UI on Windows Server 2019 or Windows 10 1809 OpenSSH client and ...

  7. [CB] 支付宝区块链的应用- 区块链发票医保理赔.

    全国第一单区块链理赔.发票开出:1分钟报销     区块链技术和概念随着比特币等虚拟电子货币的兴起而尽人皆知,但是区块链的用途可不仅仅只玩币,尤其是在“矿难”到来之后,区块链正在向更多应用领域渗透.最 ...

  8. SpringBoot 6.SpringBoot使用 Log4j2 实现日志输出

    一.添加 Log4j2 的依赖 <!-- 引入 log4j2 必须排除 logging --> <dependency> <groupId>org.springfr ...

  9. CodeForces - 707C

    C. Pythagorean Triples time limit per test 1 second memory limit per test 256 megabytes input standa ...

  10. 做前端好还是Java好?

    做前端好还是Java好?看这三方面 转载 2017年11月14日 00:00:00 1047这几年来伴随着互联网的迅速发展,新兴互联网产业的兴起,传统行业也逐渐开始互联网化,使得互联网职业在这样的背景 ...