容器部署
本文介绍如何在容器上部署 HENGSHI SENSE,以及部署后如何进行版本升级和数据备份。
部署前准备工作
单机部署前,请完成如下准备工作。
1.检查 docker 的环境。需要满足
- Docker 版本 >= 17.09
- 安装 docker-compose。
2.获取并导入离线镜像。
shell
wget https://download.hengshi.com/releases/hengshi-sense-xxx.tar.gz
docker load -i hengshi-sense-xxx.tar.gz
3.根据版本获取 docker-compose 部署文件。
安装版本 | 部署文件 | 组件依赖 |
---|---|---|
3.x | docker-compose | metadb、engine、hengshi |
4.0.x | docker-compose | metadb、engine、hengshi、minio |
4.1.x | docker-compose | metadb、engine、hengshi、minio、redis、flink |
4.2.x | docker-compose | metadb、engine、hengshi、minio、redis、flink |
4.3.x | docker-compose | metadb、engine、hengshi、minio、redis、flink |
4.4.x | docker-compose | metadb、engine、hengshi、minio、redis、flink |
4.5.0 ~ 4.5.6 | docker-compose | metadb、engine、hengshi、minio、redis、flink |
4.5.7 ~ 4.5.x(x>7) | docker-compose | metadb、engine、hengshi、minio、redis、flink、apm-server |
5.0.x | docker-compose | metadb、engine、hengshi、minio、redis、flink、apm-server |
5.1.x | docker-compose | metadb、engine、hengshi、minio、redis、 |
单机部署
请按下面的操作提示进行单机部署 HENGSHI 服务。
1.解压部署清单文件
shell
# 将下载的 docker-compose 文件解压
unzip -q docker-compose-x.x.zip
# 进入配置文件目录, 例如下载的是5.1版本, 则是cd docker-compose-5.1
cd docker-compose-x.x
- 修改配置
详细变量可参考 .env
shell
# 将默认配置重命名.env,修改.env 中的变量,
# HS_IMAGE_TAG 必须修改为导入的离线镜像的tag
cp hsenv .env
提示
配置.env 时请确保配置的端口没有被占用,可以执行 netstat -anpt 命令进行查询。
如内置引擎类型要求为 Doris,请调整 HS_ENGINE_TYPE 参数。
打开docker-compose文件中 “networks” 的注释部分,避免doris因为ip变化而导致无法启动
3.初始化 metadb 和引擎
shell
# 安装前务必先做 metadb 和引擎的初始化操作,否则 hengshi 无法启动
docker-compose run --rm metadb init metadb # 初始化 metadb
docker-compose run --rm engine init engine # 初始化 engine
运行正常会出现如下提示。
shell
docker-compose run --rm metadb init metadb
# 日志中出现以下字样 则表示 metadb 初始化成功
INIT SUCCESS! : [metadb] /opt/hsdata/pg_data
docker-compose run --rm engine init engine
# 日志中出现以下字样 则表示 engine 初始化成功
INIT SUCCESS! : [engine] /opt/hsdata/engine-cluster
after config docker engine standalone
2.启动服务
shell
docker-compose up -d # detach 方式启动
运行正常会出现如下提示。
shell
docker-compose up -d
[+] Running 8/8
✔ Container hengshi-flink Started 1.1s
✔ Container hengshi-metadb Started 1.1s
✔ Container hengshi-engine Started 1.0s
✔ Container hengshi-apmserver Started 0.8s
✔ Container hengshi-minio Started 1.0s
✔ Container hengshi-monit Started 1.0s
✔ Container hengshi-redis Started 1.2s
✔ Container hengshi-sense Started 1.9s
3.停止服务并删掉容器
shell
docker-compose down # 销毁容器
运行正常会出现如下提示。
shell
docker-compose down
[+] Running 9/8
✔ Container hengshi-monit Removed 0.0s
✔ Container hengshi-apmserver Removed 0.0s
✔ Container hengshi-engine Removed 10.4s
✔ Container hengshi-sense Removed 0.0s
✔ Container hengshi-flink Removed 10.3s
✔ Container hengshi-metadb Removed 10.4s
✔ Container hengshi-minio Removed 10.4s
✔ Container hengshi-redis Removed 10.2s
✔ Network hengshi_default Removed 0.1s
4.暂停服务
shell
docker-compose stop # 停止容器服务
运行正常会出现如下提示。
shell
docker-compose stop
[+] Running 8/8
✔ Container hengshi-monit Stopped 0.0s
✔ Container hengshi-sense Stopped 0.0s
✔ Container hengshi-apmserver Stopped 0.0s
✔ Container hengshi-engine Stopped 10.6s
✔ Container hengshi-minio Stopped 10.5s
✔ Container hengshi-flink Stopped 10.4s
✔ Container hengshi-metadb Stopped 10.4s
✔ Container hengshi-redis Stopped 10.5s
5.启动暂停的服务
shell
docker-compose start # 启用暂停的容器
运行正常会出现如下提示。
shell
docker-compose start
[+] Running 8/8
✔ Container hengshi-flink Started 1.2s
✔ Container hengshi-metadb Started 0.9s
✔ Container hengshi-apmserver Started 1.0s
✔ Container hengshi-redis Started 1.0s
✔ Container hengshi-engine Started 0.9s
✔ Container hengshi-monit Started 1.2s
✔ Container hengshi-minio Started 0.8s
✔ Container hengshi-sense Started 0.7s
示例: .env 文件
shell
#hengshi-sense 镜像的 tag 版本
HS_IMAGE_TAG=$TAG
#可选, 配置 volumn 的根路径,默认为 docker-compose.yaml 目录下。可以选择配置。请规划数据盘,建议配置最大数据盘。
HSHOME=.
# hengshi web service port
HS_HENGSHI_EXPOSE_PORT=8080
# hengshi data-gateway service port
DATA_GATEWAY_PUBLIC_EXPOSE_PORT=8079
#可选, 容器对外暴露的 metadb 端口, 默认54320
HS_PG_EXPOSE_PORT=54320
# 可选,engine 类型 可选项 greenplum|doris
HS_ENGINE_TYPE=greenplum
# 可选, engine 类型为 greenplum, engine 对外暴露的 端口
HS_ENGINE_EXPOSE_PORT=15432
# 可选, engine 类型为 doris, engine 对外暴露的 端口
#HS_ENGINE_EXPOSE_PORT=9030
# remote debug port
HS_JDWP_EXPOSE_PORT=5005
# 可选,MINIO 服务暴露端口
HS_MINIO_EXPOSE_PORT=9891
# 可选,MINIO 控制台对外暴露端口
HS_MINIO_CONSOLE_EXPOSE_PORT=9892
# 可选,redis 服务暴露端口
HS_REDIS_EXPOSE_PORT=6379
# 可选,flink 服务暴露端口
HS_FLINK_EXPOSE_PORT=8082
# 可选,apmserver 服务暴露端口
HS_APMSERVER_EXPOSE_PORT=8200
# MINIO 连接地址|登陆用户|登陆密钥
MINIO_SERVER_HOST=hengshi-minio
MINIO_ROOT_USER=hengshi
MINIO_ROOT_PASSWORD=hengshi202020