前言
最简部署superset的方法
一、系统环境
CentOS 7.9 (理论上其他linux系统也行)
宝塔面板
二、使用步骤
1.宝塔面板
进入宝塔-软件商店,安装 Docker管理器
2.Docker管理器
①进入Docker管理器-镜像管理-镜像搜索,输入superset,选择apache/superset:latest拉取
②创建容器,将8088端口映射到你想要的端口,勾选自动启动,并在宝塔安全组中放行(应该会自动),如果用的外网服务器需同步放行(大概率需手动设置)。
③从Docker管理器进入终端。
④终端中依次输入
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip install apache-superset --upgrade (更新软件到最新)
set FLASK_APP=superset
flask fab create-admin (设置自己的管理员账户,设置内容要记牢)
superset load_examples(更新一些样例数据大概率失败,可忽略不执行)
superset init
superset run -p 8088 -h 0.0.0.0 --with-threads --reload --debugger
⑤通过之前设置的端口号访问即可,之后每次重启服务器理论上都会自动启动。
ps. 升级
pip install apache-superset --upgrade
superset db upgrade
superset init
三、总结
此方法可以省去自己部署环境的烦恼,而且使用的Docker也不影响系统已有环境,实乃最便捷的部署方法。
3.修改config.py文件中的SECRET_KEY
SECRET_KEY = os.environ.get(“SUPERSET_SECRET_KEY”) or “KJWdIVBUKdgCaTNUqzudOWAJKjZ8kgAHdpRNivv/K6tIwTDLuEwJofrv” or CHANGE_ME_SECRET_KEY
SECRET_KEY = os.environ.get(“SUPERSET_SECRET_KEY”) or “KJWdIVBUKdgCaTNUqzudOWAJKjZ8kgAHdpRNivv/K6tIwTDLuEwJofrv” or CHANGE_ME_SECRET_KEY
可以使用命令 openssl rand -base64 42 来生成一个强密钥
- 错误四:Refusing to start due to insecure SECRET_KEY
WARNING
A Default SECRET_KEY was detected, please use superset_config.py to override it.
Use a strong complex alphanumeric string and use a tool to help you generate
a sufficiently random sequence, ex: openssl rand -base64 42
Refusing to start due to insecure SECRET_KEY
错误原因:Flask应用程序的SECRET_KEY配置不安全或弱不安全。
解决办法:(最难且重要的一步,睁大眼睛好好看!)
进入superet的安装目录下。输入vim superset_config.py增加配置文件
(注意!!! superset_config.py文件原先是没有的,得自己创建)
在superset_config.py文件下添加以下内容:
Superset specific config
SS 相关的配置
行数限制 5000 行
ROW_LIMIT = 5000
网站服务器端口 8088,该端口被Hadoop占用,改为其他端口比如18088
SUPERSET_WEBSERVER_PORT = 8088
Flask App Builder configuration
Your App secret key will be used for securely signing the session cookie
and encrypting sensitive information on the database
Make sure you are changing this key for your deployment with a strong key.
You can generate a strong key using openssl rand -base64 42
Flask 应用构建器配置
应用密钥用来保护会话 cookie 的安全签名
并且用来加密数据库中的敏感信息
请确保在你的部署环境选择一个强密钥
可以使用命令 openssl rand -base64 42 来生成一个强密钥
SECRET_KEY = “ZT2uRVAMPKpVkHM/QA1QiQlMuUgAi7LLo160AHA99aihEjp03m1HR6Kg”
The SQLAlchemy connection string to your database backend
This connection defines the path to the database that stores your
superset metadata (slices, connections, tables, dashboards, …).
Note that the connection information to connect to the datasources
you want to explore are managed directly in the web UI
SQLAlchemy 数据库连接信息
这个连接信息定义了 SS 元数据库的路径(切片、连接、表、数据面板等等)
注意:需要探索的数据源连接及数据库连接直接通过网页界面进行管理
#SQLALCHEMY_DATABASE_URI = ‘sqlite:path/to/superset.db’
Flask-WTF flag for CSRF
跨域请求攻击标识
WTF_CSRF_ENABLED = True
Add endpoints that need to be exempt from CSRF protection
CSRF 白名单
WTF_CSRF_EXEMPT_LIST = []
A CSRF token that expires in 1 year
CSFR 令牌过期时间 1 年
WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365
Set this API key to enable Mapbox visualizations
接口密钥用来启用 Mapbox 可视化
MAPBOX_API_KEY = ‘’
添加之后,在/etc/profile 文件中加入以下命令:,然后生效以下配置或者重启一下大数据环境即可
(路径写 superset_config.py文件的绝对路径,不然会一直报Refusing to start due to insecure SECRET_KEY的错误)
export SUPERSET_CONFIG_PATH=/app/superset_config.py