centos7搭建superset數據平臺
yum -y install perl gd gd-devel libpng libpng-devel libjpeg libjpeg-devel zlib zlib-devel pcre-devel gcc gcc-c++ make cmake autoconf openssl openssl-devel ncurses-devel patch libxml2 libxml2-devel curl-devel openldap openldap-devel libevent libevent-devel bison icu libicu-devel libtool readline-devel net-snmp-devel bzip2-devel freetype-devel vim
1.安裝mysql
useradd -s /sbin/nologin -M mysql
tar zxvf mysql-5.5.29.tar.gz
cd mysql-5.5.29cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DINSTALL_DATADIR=/data/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=complex \
-DMYSQL_USER=mysqlmake && make install
Mysql 安裝之後的配置:
cd /usr/local/mysql
scripts/mysqlinstalldb --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqlchown -R root .
cp support-files/my-medium.cnf /etc/my.cnf
vim /etc/my.cnf
添加以下內容:
[mysqld]
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/mysqldatadir = /data/mysql
user = mysql
character_set_server = utf8
配置mysql 啟動
cp support-files/mysql.server /etc/init.d/mysql
vim /etc/init.d/mysql
添加以下兩行
basedir=/usr/local/mysql
datadir=/data/mysql
安裝完成啟動服務修改密碼:
service mysql start
添加軟連接:
ln -s /usr/local/mysql/bin/mysql /usr/bin
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
初始化密碼:
mysqladmin -uroot password
2.安裝pip
yum install -y epel-release
安裝好 EPEL 之後,還需要運行這個命令:yum install -y yum-utils && yum-config-manager --enable epel
來啟用 EPEL,這樣才可以運行命令:yum install -y python-pip
來安裝 pip 工具。最後,建議大家再運行命令:pip install --upgrade pip
3.安裝superset平臺:
依賴包安裝;
yum upgrade python-setuptools
yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel
官網推薦在virtualenv中安裝 superset
pip install virtualenv
創建和激活一個 virtualenv ,創建後會在當前目錄生成一個 supersetenv的目錄
virtualenv supersetenv
啟動 supersetenv,先進入創建的virtualenv目錄
cd supersetenv/
source ./bin/activate
更新pip和setuptools:
pip install --upgrade setuptools pip
安裝mysqlclient。
將superset的元數據存儲改成mysql,就需要這一步。
ROOT權限下,為了連接mysql
yum install mysql-devel
virtualenv下:
pip install mysqlclient
添加superset的配置文件。
在python所在的目錄即PYTHONPATH(如,我這裏是/root/supersetenv/bin下),手動添加superset的配置文件superset_config.py。內容如下:
#-- coding: utf-8 --
#===============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
SUPERSET_WEBSERVER_PORT = 8088#---------------------------------------------------------
#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
br/>#我這裏改成mysql
#mysql://用戶名:密碼@192.168.1.162/數據庫名?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結束===============
最後,安裝 superset,在安裝之前需要在mysql先創建superset的數據庫
show variables like "%char%";
create database superset
use superset
--這裏如果不設置數據庫為utf8,在後面初始化數據庫時會報 Specified key was too long; max key length is 767 bytes 的錯誤
alter database superset character set utf8;
安裝superset,最新版本是26.3
pip install superset==0.26.3
pip install "markdown<3.0.0" superset
創建admin用戶
fabmanager create-admin --app superset
然後需要輸入:
Username [admin]: admin
User first name [admin]: admin
User last name [user]: admin
Email [[email protected]]: [email protected]
Password: admin
Repeat for confirmation: admin初始化數據
superset db upgrade啟動superset
superset runserver
//或者指定端口
superset runserver -p 8388 &pip install pymysql
centos7搭建superset數據平臺