CentOS7-之Superset安装
1 准备工作,安装python环境
在不破坏linux原先的python2.7的情况下安装python3.7
1.1 安装miniconda
下载地址:https://docs.conda.io/en/latest/miniconda.html
选择Miniconda3 Linux 64-bit
这是一个开源的python的版本管理工具,与anaconda差不大,只是该工具中的包要少一些。
bash Miniconda3-latest-Linux-x86_64.sh
然后按照执行的指示进行操作
> ENTER > 空格 > 空格 Do you accept the license terms? [yes|no] [no] >>> yes ENTER #############################安装路径####################################### Miniconda3 will now be installed into this location: ........ [/home/shufang/miniconda3] >>> /opt/module/miniconda3 # 这个是手动输入,指定安装路径 PREFIX=/opt/module/miniconda3 Unpacking payload ... Collecting package metadata ########################是否初始化#################### Do you wish the installer to initialize Miniconda3 by running conda init? [yes|no] [no] >>> yes ##########################安装完成############################ If you'd prefer that conda's base environment not be activated on startup, set the auto_activate_base parameter to false: # 将自动切换到conda的base环境关闭 conda config --set auto_activate_base false Thank you for installing Miniconda3! ########################使miniconda的python环境生效##################### [shufang@shufang103 software]$ source ~/.bashrc (base) [shufang@shufang103 software]$
1.2 配置python3.7环境
- 配置conda的国内镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- 创建python3.7的环境
conda create --name superset python=3.7 或者 conda create -n superset python=3.7
- 激活环境
(base) [shufang@shufang103 software]$ conda activate superset (superset) [shufang@shufang103 software]$
如果不想使用指定的环境,或者切换,可以执行
# 反激活当前环境 conda deactivate # 切换base环境 conda activate base
2 安装部署Superset
2.1 安装依赖
(superset) [shufang@shufang103 software]$ sudo yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel python-setuptools openssl-devel cyrus-sasl-devel openldap-devel
2.2 安装Superset
2.2.1 升级setuptools和pip
(superset) [shufang@shufang103 software]$ pip install --upgrade setuptools pip -i https://pypi.douban.com/simple
2.2.2 安装superset
(superset) [shufang@shufang103 software]$ pip install apache-superset -i https://pypi.douban.com/simple
2.2.3 初始化superset的数据库
# 1 sqlite数据库 superset db upgrade # 2 创建管理员用户,管理superset,或者登录(shufang/888888) # flask是一个python中的web框架,superset使用的就是flask export FLASK_APP=superset superset fab create-admin
2.2.4 启动superset
1 安装gunicorn Python Web Server
pip install gunicorn -i https://pypi.douban.com/simple
2 启动Superset
必须在superset对应的python环境下启动
gunicorn --workers 5 --timeout 120 --bind shufang103:8787 "superset.app:create_app()" --daemon ###说明 --workers 指定进程的个数,web容器的并发 --timeout 指定worker进程的超时时间,超时会自动重启 --bind 绑定本机的地址,即为superset的访问地址 --daemon 后台运行
3 登录Superset
直接访问:http://shufang103:8787 ,使用shufang/888888登录
4 停止superset服务
# 杀掉进程
ps -ef | awk '/superset/&& !/awk/{print $2}' | xargs kill -9
# 退出环境
conda deactivate
3 连接MySQL数据源
superset可以连接多种数据源,每种数据源都需要安装指定的驱动依赖。
官网参考:https://superset.apache.org/docs/databases/installing-database-drivers
conda install mysqlclient



