解释一波
Apache Superset是一款由Python语言为主开发的开源时髦数据探索分析以及可视化的报表平台;她支持丰富的数据源,且拥有多姿多彩的可视化图表选择。
- 官网 :https://superset.apache.org/
- github :https://github.com/apache/superset
如果你的机器上已经安装了docker,请忽略安装docker的操作
1.安装docker
1.1安装必要的一些系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
1.2 添加软件源信息
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
1.3 更新yum索引列表并安装Docker引擎
sudo yum makecache fast
yum索引列表没有更新可以直接使用yum makecache
sudo yum install docker-ce
安装过程中会提示确认,输入y以确认。
1.4 开启docker服务
sudo service docker start
1.5 替换docker镜像仓库(自选)
根据需求配置下载docker镜像的仓库
docker的默认仓库Docker Hub下载速度在国内是很慢的,需要我们替换为阿里云的仓库。
具体操作步骤如下:
打开阿里云的官网,搜索容器,找到容器与镜像服务!
进入容器与镜像服务页面,点击镜像加速器。
依据页面的提示,在命令行中输入以下指令:
这里注意registry-mirrors的地址每个人都是不一样的,要查看页面上显示的地址。
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
2、选择superset镜像
- 查找superset相关的镜像(docker search superset)
- 选择STARS最高的amancevice/superset
- 拉取镜像(docker pull amancevice/superset)
- 查看镜像是否下载完成(docker images)
3、安装superset容器
3.1 配置本地superset挂载配置文件
创建本地目录(让容器中的superset挂载本地机的配置文件)
mkdir /opt/docker/superset/ -p
创建挂载的配置文件信息
touch /opt/docker/superset/superset_config.py
文件内容如下
#Superset specific config
ROW_LIMIT = 5000
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.
# Alternatively you can set it with `SUPERSET_SECRET_KEY` environment variable.
# You MUST set this for production environments or the server will not refuse
# to start and you will see an error in the logs accordingly.
SECRET_KEY = '****************************'
# 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
# The check_same_thread=false property ensures the sqlite client does not attempt
# to enforce single-threaded access, which may be problematic in some edge cases
SQLALCHEMY_DATABASE_URI = 'mysql://superset:123456@127.0.0.1/superset'
# Flask-WTF flag for CSRF
WTF_CSRF_ENABLED = True
# Add endpoints that need to be exempt from CSRF protection
WTF_CSRF_EXEMPT_LIST = []
# A CSRF token that expires in 1 year
WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365
# Set this API key to enable Mapbox visualizations
MAPBOX_API_KEY = ''
3.2 创建superset容器,并挂载对应配置信息
docker run --name superset -d -p 8088:8088 -v /opt/docker/superset/superset_config.py:/etc/superset/superset_config.py -v /opt/docker/superset/data:/var/lib/superset amancevice/superset
3.3 查看容器是否运行成功
docker ps
4、配置superset容器
4.1 初始化数据库
docker exec -it superset superset db upgrade
4.2 创建superset管理员用户
docker exec -it superset superset fab create-admin
4.3 初始化superset
docker exec -it superset superset init
4.4 启动服务
docker exec -it superset superset run --with-threads --reload --debugger
5、访问superset
浏览器地址栏输入 IP:8088
番外
配置文件中的 SECRET_KEY 需要手动生产一串密码,命令是:
openssl rand -base64 42
如果你想让界面显示中文,也可以在配置文件中添加以下配置:
LANGUAGES = { 'en': {'flag': 'us', 'name': 'English'}, 'zh': {'flag': 'cn', 'name': 'Chinese'}, }
然后重启服务