版本:superset版本2.0.0、python版本3.9(到时候把依赖安装完成,整个miniconda3打包拷过去到对应的目录解压就ok),如果不想安装,可以直接下载我弄好的https://download.csdn.net/download/qq_35233282/88530234?spm=1001.2014.3001.5503
1.安装python环境(推荐安装conda,这样可以隔离python的各个版本)
准备一台能联网的机器,我这里是一台本地的虚拟机,系统版本为cenos7.4,安装好yum源和各种命令,没有的话直接
sudo yum install xxxx |
或者
wget -c https://mirrors.bfsu.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh #清华的镜像源latest的版本的话就是说以后一直会更新最新的版本 |
或者自己去下载好,上传到服务器也是一样的
然后执行
bash Miniconda3-latest-Linux-x86_64.sh |
一直按回车就行了,输个yes,再后面就是选择安装路径,默认为/root/miniconda3,后面迁移直接到对应的目录下就ok了。输入个yes,等着安装完就OK了。
接下来就需要把miniconda3配到环境变量中,
vim /etc/profile 然后就是source /etc/profile |
下面添加个Python的虚拟环境
conda create -n envname python=3.9 |
source activate envname |
前面就会显示你的envname
下面安装编译环境
sudo yum install gcc gcc-c++ libffi-devel python3-devel python3-pip python3-wheel openssl-devel cyrus-sasl-devel openldap-devel |
2.安装superset,这个过程比较慢,各种依赖会一同安装,耐心等待安装完成
pip install apache-superset=2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/ |
#如果下载过慢 可以使用国内镜像
(1)阿里云 http://mirrors.aliyun.com/pypi/simple/
(2)豆瓣http://pypi.douban.com/simple/
(3)清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
(4)中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
(5)华中科技大学http://pypi.hustunique.com/
#gunicorn是一个Python Web Server,可以和java中的TomCat类比
pip install gunicorn -i Simple Index |
#初始化db
superset db upgrade |
#创建admin用户
superset fab create-admin |
Username [admin]: User first name [admin]: User last name [user]: Email [admin@fab.org]: xxx@qq.com Password: Repeat for confirmation: Recognized Database Authentications. Admin User admin created. |
#加载例子
superset load_examples |
#superset初始化
superset init |
#测试启动
superset run -p 8088 --host=0.0.0.0 --with-threads --reload --debugger |
或者
gunicorn --workers 5 --timeout 120 --bind 127.0.0.1:8080 "superset.app:create_app()" --daemon |
说明:
--workers:指定进程个数
--timeout:worker进程超时时间,超时会自动重启
--bind:绑定本机地址,即为Superset访问地址
--daemon:后台运行
3.过程出现的各种问题
Could not locate a Flask application. Use the 'flask --app' option, 'FLASK_APP' environment variable, or a 'wsgi.py' or 'app.py' file in the current directory. |
这个是因为superset是基于Flask框架开发的,运行时,需要到项目的根目录下运行,所以,对应的superset根目录为/home/minicoda3/envs/superset-py39/lib/python3.9/site-packages/superset,到该目录下重新执行命令。
或者export FLASK_APP=superset
(2)
ModuleNotFoundError: No module named 'werkzeug.wrappers.etag' |
# 这个是在 superset 2.0 版本出现的bug,通过降低Werkzeug的版本解决,直接安装就行,会自动卸载已安装的版本
pip install Werkzeug==2.0.3 -i https://pypi.tuna.tsinghua.edu.cn/simple/
(3)
TypeError: __init__() got an unexpected keyword argument 'unbound_message' |
# 这个是在 superset 2.0 版本出现的bug,需要降低Flask的版本到2.0.3
pip install Flask==2.0.3 -i https://pypi.tuna.tsinghua.edu.cn/simple/
(4)
ModuleNotFoundError: No module named 'wtforms.ext' |
# 这个是因为WTForms 3.0的版本去掉了ext,需要降低WTForms的版本到2.3.3
pip install WTForms==2.3.3 -i https://pypi.tuna.tsinghua.edu.cn/simple/
(5)
cannot import name 'Log' from 'distutils.log' |
这是由于setuptools为65.6.0版本的原因,将setuptools降为65.5.0版本即可。
pip install setuptools==65.5.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/
superset迁移到另一台机器上需要将对应的数据库拷贝过去,默认的存储位置在/root/.superset
如果需要修改请到/home/miniconda3/envs/superset-py39/lib/python3.9/site-packages/superset/config.py DATA_DIR改为你的存储路径就OK