第一章 Docker搭建superset 可视化平台

一、安装Docker

1.编写安装docker脚本

[root@staging ~]# vim docker_install.sh  
#!/usr/bin/bash
# Author:jh
# Time:2021-04-21  11:54:22
# Name:docker_ins_apm.sh
# Version: 1.0
# Discription: To  

rely_software=(yum-utils device-mapper-persistent-data lvm2)

#1.检测系统内核版本
kernel_version=`uname -a |awk '{print $3}'|cut -d. -f1`
if [ $kernel_version -ge 3 ];then
    echo 'The System Can Install docker;' 
else
    echo 'The System Can not Install docker;';exit 
fi

#2.安装依赖软件
for i in ${rely_software[*]}
do       
    rpm -q $i &>/dev/null
    if [ $? -eq 0 ];then
        echo "$i is installed"            
    else            
        yum -y install $i  &>/dev/null                                                           
        action "$i is installing"  /usr/bin/true           
    fi                     
done

#3.添加docker镜像源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
if [ $? -eq 0 ];then
    echo "Docker Image added;" 
else 
    echo "Docker Image add failed" 
fi

#4.安装docker
yum install docker-ce -y

#5.启动docker并设置开机自启
systemctl enable --now docker
if [ $? -eq 0 ];then
    echo "Docker started;" 
else    
    echo "Docker start failed"
fi

#6.验证服务
docker_version=`docker -v |awk -F ',' '{print $1}'`

#7.设置加速器
sudo mkdir -p /etc/docker
sudo cat >/etc/docker/daemon.json <<EOF
{
      "registry-mirrors": ["https://8mh75mhz.mirror.aliyuncs.com"]
  }
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

#8.docker安装完成提示语
cat << EOF
+-------------------------------------------------+
| $docker_version 安 装 已 完 成           |
| 请 使 用 相 关 服 务 !                          |
+-------------------------------------------------+
EOF

sleep 5

mv ./docker_install.sh /tmp

2.验证docker服务

[root@staging ~]# docker version 
Client: Docker Engine - Community
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        370c289
 Built:             Fri Apr  9 22:45:33 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:43:57 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

二、安装superset

1.创建本地目录

[root@staging ~]# ll /opt/docker/superset/

2.运行superset容器

[root@staging ~]# docker run -d -p 523:8088 -v /opt/docker/superset:/home/superset amancevice/superset

3.查看服务状态

[root@staging ~]# netstat -lntp|grep docker
tcp6       0      0 :::523                  :::*                    LISTEN      1408/docker-proxy-c

[root@staging ~]# docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS                 PORTS                   NAMES
a843d4a8e62d        amancevice/superset   "gunicorn superset..."   10 days ago         Up 10 days (healthy)   0.0.0.0:523->8088/tcp   heuristic_brown

三、初始化superstet

#1. superset初始化(docker exec -it 容器ID superset init)

[root@staging ~]# docker exec -it superset superset-init
Username [admin]: admin
User first name [admin]: jin
User last name [user]: hui
Email [admin@fab.org]: 974089352@qq.com
Password: 
Repeat for confirmation: 
logging was configured successfully
INFO:superset.utils.logging_configurator:logging was configured successfully
/usr/local/lib/python3.8/site-packages/flask_caching/__init__.py:201: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
  warnings.warn(
Recognized Database Authentications.
Admin User admin created.
logging was configured successfully

四、重启superset服务

[root@staging ~]# docker restart superset

五、配置内网穿透

#1.进入frpc目录
[root@staging ~]# cd /opt/frp_0.34.2_linux_amd64/

#2.配置frpc
[root@staging frp_0.34.2_linux_amd64]# vim frpc.ini
#添加以下内容
[superset_dl]
type = tcp
local_ip = 127.0.0.1
local_port = 523
remote_port = 6405

#3.重启内网穿透服务
[root@staging frp_0.34.2_linux_amd64]# nohup ./frpc -c ./frpc.ini &

六、浏览器验证服务

浏览器输入URL:http://161.189.107.66:6405/login/

posted @ 2021-05-19 15:22  年少纵马且长歌  阅读(673)  评论(0编辑  收藏  举报