Docker 安装
1. 拉取稳定版
docker run --rm --network host --name superset amancevice/superset:2.1.0
2. 配置MySQL 数据库存储
5.7 或 8.0 均适用
创建 superset 用户并配置远程访问
create user superset
identified by 'superset';
# MysQL 5.7
GRANT ALL PRIVILEGES ON *.* TO 'superset'@'%' IDENTIFIED BY 'superset' WITH GRANT OPTION;
# MySQL 8.0
GRANT ALL PRIVILEGES ON *.* TO 'superset'@'%' WITH GRANT OPTION;
3.配置 Redis 缓存
安装过程忽略
4. 自定义配置 superset
更多配置, 请参见
https://superset.apache.org/docs/installation/configuring-superset/
或
https://github.com/apache/superset/blob/master/superset/config.py
存储到 MySQL, 缓存到 Redis
创建配置目录
mkdir -p /etc/superset
创建配置文件
cd /etc/superset/
touch superset_config.py
/etc/superset/superset_config.py
import os
# MAPBOX_API_KEY = os.getenv("MAPBOX_API_KEY", "")
CACHE_CONFIG = {
"CACHE_TYPE": "RedisCache",
"CACHE_DEFAULT_TIMEOUT": 300,
"CACHE_KEY_PREFIX": "superset_",
"CACHE_REDIS_HOST": "redis",
"CACHE_REDIS_PORT": 6379,
"CACHE_REDIS_DB": 1,
"CACHE_REDIS_URL": "redis://redis.example.com:6379/11",
}
FILTER_STATE_CACHE_CONFIG = {**CACHE_CONFIG, "CACHE_KEY_PREFIX": "superset_filter_"}
EXPLORE_FORM_DATA_CACHE_CONFIG = {**CACHE_CONFIG, "CACHE_KEY_PREFIX": "superset_explore_form_"}
SQLALCHEMY_DATABASE_URI = "mysql://superset:superset@mysql.example.com:3306/superset?charset=utf8mb4"
SQLALCHEMY_TRACK_MODIFICATIONS = True
SECRET_KEY = "thisISaSECRET_1234"
5.启动
指定自定义配置项 superset_config.py
-v /etc/superset:/etc/superset
指定端口映射到主机的 28088 端口-p 28088:8088
docker run -d --restart always -v /etc/superset:/etc/superset --name superset amancevice/superset:2.1.0
6.首次启动后需要初始化
docker exec -it superset superset-init
配置用户名 / 密码
[root@jansora superset]# docker exec -it superset superset-init
Username [admin]: admin
User first name [admin]:
User last name [user]:
Email [admin@fab.org]:
Password:
Repeat for confirmation:
Loaded your LOCAL configuration at [/etc/superset/superset_config.py]
logging was configured successfully
...
7. 配置到 nginx
server {
listen 443 ssl http2;
server_name superset.jansora.app;
# ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/openresty/certs/lets-encrypt-jansora.app/jansora.app.crt;
ssl_certificate_key /etc/openresty/certs/lets-encrypt-jansora.app/jansora.app.key;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://127.0.0.1:28088;
}
}
访问测试
Kubernetes 安装 superset
与 Docker 安装类似
1.2.3.4 步骤同 Docker 安装
忽略
5. 配置到 ConfigMap
kubectl create configmap superset-config --from-file=/etc/superset/superset_config.py
6. 配置 Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: superset
spec:
selector:
matchLabels:
app: superset
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 20
maxUnavailable: 20
replicas: 1
template:
metadata:
labels:
app: superset
spec:
containers:
- name: superset
image: amancevice/superset:2.1.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8088
volumeMounts:
- name: config-volume
mountPath: /etc/superset/superset_config.py
subPath: superset_config.py
volumes:
- name: config-volume
configMap:
name: superset-config
7. 配置 Service
apiVersion: v1
kind: Service
metadata:
name: superset-service
spec:
type: ClusterIP
selector:
app: superset
ports:
- protocol: TCP
port: 8080
targetPort: 8088
name: http
8. 配置 ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: superset-ingress
spec:
ingressClassName: nginx
rules:
- host: superset.kubernetes.jansora.com
http:
paths:
- backend:
service:
name: superset-service
port:
number: 8080
pathType: Prefix
path: /
9. 初始化
root@master:~# kubectl get pods | grep superset
superset-665796cd87-5l4l7 1/1 Running 0 5h3m
root@master:~# kubectl exec -it superset-665796cd87-5l4l7 -- superset-init
...
init log
...
转发
server {
listen 443 ssl http2;
server_name superset.jansora.com;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/openresty/certs/lets-encrypt-jansora.com/jansora.com.crt;
ssl_certificate_key /etc/openresty/certs/lets-encrypt-jansora.com/jansora.com.key;
location / {
proxy_pass http://kubernetes;
proxy_set_header Host superset.kubernetes.jansora.com;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
}
}
访问测试
附: MAC 安装手稿
cd /Users/jansora/Library
python3 -m venv superset
export SUPERSET_HOME=/Users/jansora/Library/superset
$SUPERSET_HOME/bin/pip3 install apache-superset pillow -i https://pypi.tuna.tsinghua.edu.cn/simple
$SUPERSET_HOME/bin/superset db upgrade
$SUPERSET_HOME/bin/superset fab create-admin
nohup /Users/jansora/Library/superset/bin/superset run -p 19088 >/Users/jansora/Library/superset/superset.log 2>&1 &
Username [admin]:
User first name [admin]:
User last name [user]:
Email [admin@fab.org]:
Password: admin
Repeat for confirmation: admin
Recognized Database Authentications.
Admin User admin created.
./superset load_examples
./superset init
- 配置驱动
驱动名参见 https://superset.apache.org/docs/connecting-to-databases/installing-database-drivers/
安装驱动参考 https://superset.apache.org/docs/connecting-to-databases/docker-add-drivers
# Oracle
$SUPERSET_HOME/bin/pip3 install cx_Oracle -i https://pypi.tuna.tsinghua.edu.cn/simple
# Mysql
$SUPERSET_HOME/bin/pip3 install mysqlclient -i https://pypi.tuna.tsinghua.edu.cn/simple