CentOS7下使用docker-compose安装部署superset


一、安装 docker、docker-compose

docker在CentOS下安装Docker-compose安装

二、下载

git clone https://github.com/apache/superset.git
cd superset

官网指引:
https://superset.apache.org/docs/installation/installing-superset-using-docker-compose

三、修改 superset 配置文件

1.修改 docker-compose-non-dev.yml

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
x-superset-image: &superset-image apache/superset:${TAG:-latest-dev}
x-superset-depends-on: &superset-depends-on
#  - db
  - redis
x-superset-volumes: &superset-volumes
  # /app/pythonpath_docker will be appended to the PYTHONPATH in the final container
  - ./docker:/app/docker
  - superset_home:/app/superset_home

version: "3.7"
services:
  redis:
    image: redis:7
    container_name: superset_cache
    restart: unless-stopped
    volumes:
      - redis:/data

#  db:
#    env_file: docker/.env-non-dev
#    image: postgres:14
#    container_name: superset_db
#    restart: unless-stopped
#    volumes:
#      - db_home:/var/lib/postgresql/data

  superset:
    env_file: docker/.env-non-dev
    image: *superset-image
    container_name: superset_app
    command: ["/app/docker/docker-bootstrap.sh", "app-gunicorn"]
    user: "root"
    restart: unless-stopped
    ports:
      - 8088:8088
    depends_on: *superset-depends-on
    volumes: *superset-volumes

  superset-init:
    image: *superset-image
    container_name: superset_init
    command: ["/app/docker/docker-init.sh"]
    env_file: docker/.env-non-dev
    depends_on: *superset-depends-on
    user: "root"
    volumes: *superset-volumes
    healthcheck:
      disable: true

  superset-worker:
    image: *superset-image
    container_name: superset_worker
    command: ["/app/docker/docker-bootstrap.sh", "worker"]
    env_file: docker/.env-non-dev
    restart: unless-stopped
    depends_on: *superset-depends-on
    user: "root"
    volumes: *superset-volumes
    healthcheck:
      test: ["CMD-SHELL", "celery -A superset.tasks.celery_app:app inspect ping -d celery@$$HOSTNAME"]

  superset-worker-beat:
    image: *superset-image
    container_name: superset_worker_beat
    command: ["/app/docker/docker-bootstrap.sh", "beat"]
    env_file: docker/.env-non-dev
    restart: unless-stopped
    depends_on: *superset-depends-on
    user: "root"
    volumes: *superset-volumes
    healthcheck:
      disable: true

volumes:
  superset_home:
    external: false
#  db_home:
#    external: false
  redis:
    external: false

注:此处使用自己搭建的 mysql 作为数据的存储

2.修改 .env-non-dev

该文件在 ./superset/docker 目录下,使用 ls -a 进行查看该隐藏文件

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
COMPOSE_PROJECT_NAME=superset

# database configurations (do not modify)
DATABASE_DB=superset
DATABASE_HOST=192.168.1.xx
DATABASE_PASSWORD=superset
DATABASE_USER=superset

# database engine specific environment variables
# change the below if you prefer another database engine
#DATABASE_PORT=5432
DATABASE_PORT=3306
#DATABASE_DIALECT=postgresql
DATABASE_DIALECT=mysql
#POSTGRES_DB=superset
#POSTGRES_USER=superset
#POSTGRES_PASSWORD=superset
MYSQL_DATABASE=superset
MYSQL_USER=superset
MYSQL_PASSWORD=superset
MYSQL_RANDOM_ROOT_PASSWORD=yes

# Add the mapped in /app/pythonpath_docker which allows devs to override stuff
PYTHONPATH=/app/pythonpath:/app/docker/pythonpath_dev
REDIS_HOST=redis
REDIS_PORT=6379

FLASK_ENV=production
SUPERSET_ENV=production
SUPERSET_LOAD_EXAMPLES=yes
SUPERSET_SECRET_KEY=TEST_NON_DEV_SECRET
CYPRESS_CONFIG=false
SUPERSET_PORT=8088
MAPBOX_API_KEY=''

注:
1、增加自行搭建的 mysql 地址、账号和密码,注释掉 pg。
2、redis 改为自行搭建 redis 时会出现无法连接 redis 的错误,笔者还找不到原因,所以仍然使用系统默认配置的 redis。

四、创建数据库及数据库用户

CREATE USER superset IDENTIFIED BY 'superset';
GRANT ALL PRIVILEGES ON *.* TO 'superset'@'%' ;
CREATE DATABASE superset DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

五、启动

docker-compose -f docker-compose-non-dev.yml up -d

启动时可能会报错:

Error response from daemon: oci runtime error: container_linux.go:290: starting container process caused "exec: \"/app/docker/docker-bootstrap.sh\": permission denied"

解决方法:

cd ./docker
chmod 777 *.sh

使用高版本 docker-compose 可能会报错:

unexpected character "(" in variable name 

换为低版本就可以了。我这里将版本从 2.18.1 降为 1.29.2。

六、访问

http://IP:8088/superset/
用户密码:admin
密码:admin

七、汉化

docker cp superset_app:/app/superset/config.py /root
vi config.py
# Setup default language
BABEL_DEFAULT_LOCALE = "zh"
# Your application default translation path
BABEL_DEFAULT_FOLDER = "superset/translations"
# The allowed translation for you app
LANGUAGES = {
    
    
    "en": {
    
    "flag": "us", "name": "English"},
    "es": {
    
    "flag": "es", "name": "Spanish"},
    "it": {
    
    "flag": "it", "name": "Italian"},
    "fr": {
    
    "flag": "fr", "name": "French"},
    "zh": {
    
    "flag": "cn", "name": "Chinese"},
    "ja": {
    
    "flag": "jp", "name": "Japanese"},
    "de": {
    
    "flag": "de", "name": "German"},
    "pt": {
    
    "flag": "pt", "name": "Portuguese"},
    "pt_BR": {
    
    "flag": "br", "name": "Brazilian Portuguese"},
    "ru": {
    
    "flag": "ru", "name": "Russian"},
    "ko": {
    
    "flag": "kr", "name": "Korean"},
    "sk": {
    
    "flag": "sk", "name": "Slovak"},
    "sl": {
    
    "flag": "si", "name": "Slovenian"},
    "nl": {
    
    "flag": "nl", "name": "Dutch"},
}
# Turning off i18n by default as translation in most languages are
# incomplete and not well maintained.
#LANGUAGES = {}

重点是设置:
BABEL_DEFAULT_LOCALE = “zh”
和屏蔽(不屏蔽默认关闭国际化多语言服务):
#LANGUAGES = {}

将文件拷贝回容器:

docker cp /root/config.py superset_app:/app/superset/config.py

进入容器:

docker exec -it --user root superset_app /bin/bash

编译messages.po文件:

cd superset
pybabel compile -d translations

退出,重启 superset:
docker restart ce87640911d6(superset-app 的 容器 id)

八、免登录配置

docker cp superset_app:/app/superset/config.py /root
vi config.py

修改:

WTF_CSRF_ENABLED = False
HTTP_HEADERS: Dict[str, Any] = {
    
    }
PUBLIC_ROLE_LIKE: Optional[str] = "Gamma"

将文件拷贝回容器:

docker cp /root/config.py superset_app:/app/superset/config.py

进入容器:

docker exec -it --user root superset_app /bin/bash

执行:

superset init

猜你喜欢

转载自blog.csdn.net/u012069313/article/details/130747868