欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

安装superset官方容器

时间:2023-05-16
前置条件

1.主机上安装好docker

2.主机上安装好dnscrypt-proxy(用于解决dns污染),参考Installation linux · DNSCrypt/dnscrypt-proxy Wiki · GitHub

3.主机上装好http代理服务用于容器访问github示例数据

安装容器

Docker Hubhttps://hub.docker.com/r/apache/superset安装并启动容器后,先不要运行初始化,需要作一些修改:

安装vim、修改dns:

# 以root身份进入容器安装好vimdocker exec -it -u root superset /bin/bashapt updateapt install vim# 还可以设置一下root密码passwd# 按dnscrypt-proxy文档修改dns,其中的ip换为主机的vim /etc/resolv.conf

修改代理、代码:

# 进入容器docker exec -it superset /bin/bash# 设置代理,ip和端口指向主机代理服务,替换为自己的export http_proxy=http://172.17.0.1:1081export https_proxy=http://172.17.0.1:1081# 具体修改内容见后面vim /app/superset/examples/helpers.py# 具体修改内容见后面vim /app/superset/datasets/commands/importers/v1/utils.py

修改容器内/app/superset/examples/helpers.py

# 头部引入requestsimport requests# 注释以下3行#content = request.urlopen( # pylint: disable=consider-using-with# f"{base_URL}{filepath}?raw=true"#).read()# 紧随其后增加以下4行res = requests.get( f"{base_URL}{filepath}?raw=true")content = res.content

 修改容器内/app/superset/datasets/commands/importers/v1/utils.py

# 修改load_data方法# 注释此行#data = request.urlopen(data_uri) # pylint: disable=consider-using-with# 随后增加以下两行res = requests.get(data_uri)data = io.BytesIO(res.content)

将urllib修改为requests的目的是解决以下错误:
http.client.RemoteDisconnected: Remote end closed connection without response

 中文支持

找到config.py,修改BABEL_DEFAULT_LOCALE为zh,注释LANGUAGES = {},重启容器:

docker restart superset

# ---------------------------------------------------# Babel config for translations# ---------------------------------------------------# Setup default languageBABEL_DEFAULT_LOCALE = "zh"# Your application default translation pathBABEL_DEFAULT_FOLDER = "superset/translations"# The allowed translation for you appLANGUAGES = { "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"},}# Turning off i18n by default as translation in most languages are# incomplete and not well maintained.# LANGUAGES = {}

 

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。