首页 > 其他分享 >StarRocks 容器镜像构建

StarRocks 容器镜像构建

时间:2024-07-07 18:09:10浏览次数:1  
标签:容器 StarRocks SR starrocks fe conf HOME 镜像 true

StarRocks 官方只提供了单节点运行的镜像,如果是构建可以分布式运行的 StarRocks 的容器镜像,那么基于基础镜像可以有两种选择,分别是:starrocks/artifacts-ubuntu 和 starrocks/allin1-ubuntu,这两个都是基于 Ubuntu 22.04 的基础镜像。其中前者是其中只包含 StarRocks 编译好的安装文件,并不包含任何可运行的环境,需要抠出来放到 Ubuntu 22.04 环境上才可以运行,而且需要安装 JDK 等基础镜像。而后者是编写了具体的启动脚本,可以单机运行所有的服务,作为快速开始使用的,所以里面很多必要的环境都存在,我们可以基于 allin1-ubuntu 做一些修改即可和标准运行方式一样。

artifacts-ubuntu Docker Hub 地址:https://hub.docker.com/r/starrocks/artifacts-ubuntu/tags

allin1-ubuntu Docker Hub 地址:https://hub.docker.com/r/starrocks/allin1-ubuntu/tags

如果基于 artifacts-ubuntu 构建需要我们将镜像里面的安装文件拷贝出来,然后自己编写 Dockerfile 实现,例如:

FROM ubuntu:22.04

RUN sed -i "s@http://.*archive.ubuntu.com@http://mirrors.huaweicloud.com@g" /etc/apt/sources.list && sed -i "s@http://.*security.ubuntu.com@http://mirrors.huaweicloud.com@g" /etc/apt/sources.list
RUN apt update && apt install -y openjdk-11-jdk libbinutils

WORKDIR /opt/StarRocks-3.2.3

ADD starrocks-artifacts/ .

CMD ["/bin/bash", "-c", "echo \"StarRocks.\""]

而且这样 FE 和 BE 必须单独启动,也就是启动两个容器。另外这个镜像体积比较大,有 8 个多 GB,原因是 BE 包含了 debuginfo 符号表,这个是方便开发人员 GDB 调试的,正常运行不需要,所以我们最好删除 be/lib/starrocks_be.debuginfo 这个文件。

另外是使用 allin1-ubuntu 镜像,里面使用 Supervisor 来管理 FE 和 BE 等进程,这样比较合理,所以我们可以直接基于这个镜像做一些修改,首先运行镜像并进入容器:

docker run -it starrocks/allin1-ubuntu:3.2.3 /bin/bash

然后我们修改 Supervisor 配置文件 /etc/supervisor/supervisord.conf 在其中调大文件数限制:

[supervisord]
# 添加配置
minfds=1048576

然后查看脚本 entrypoint.sh 默认如下:

#!/bin/bash
# Copyright 2021-present StarRocks, Inc. All rights reserved.
#
# Licensed 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
#
#     https://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.

set -e

get_fe_http_port()
{
    source $SR_HOME/fe/bin/common.sh
    export_env_from_conf $SR_HOME/fe/conf/fe.conf
    echo ${http_port:-8030}
}

update_feproxy_config()
{
    # process fe http_port from a sub shell to avoid env var escalation
    fehttpport=`get_fe_http_port`
    cat $SR_HOME/feproxy/feproxy.conf.template | sed -e "s|{{feproxyhome}}|$SR_HOME/feproxy|g" -e "s|{{fewebport}}|${fehttpport}|g" > $SR_HOME/feproxy/feproxy.conf
}

setup_priority_networks()
{
    echo "priority_networks = 127.0.0.1/32" >> $SR_HOME/fe/conf/fe.conf
    echo "priority_networks = 127.0.0.1/32" >> $SR_HOME/be/conf/be.conf
}

# print banner
if [ -f $SR_HOME/../banner.txt ] ; then
    cat $SR_HOME/../banner.txt
fi

# setup log directories
mkdir -p $SR_HOME/{supervisor,fe,be,apache_hdfs_broker,feproxy}/log

update_feproxy_config
# use 127.0.0.1 for all the services, include fe/be/broker
setup_priority_networks

# setup supervisor and start
SUPERVISORD_HOME=$SR_HOME/supervisor
# allow supervisorctl to find the correct supervisord.conf
ln -sfT $SUPERVISORD_HOME/supervisord.conf /etc/supervisord.conf

cd $SUPERVISORD_HOME
exec supervisord -n -c $SUPERVISORD_HOME/supervisord.conf

这其中执行了 setup_priority_networks 函数,会将配置追加到 fe.confbe.conf ,但是我们需要将这个配置文件拷贝出来再映射进去,所以不需要每次都执行,我们将这行函数注释掉。

然后我们把容器内的配置文件拷贝到容器外面:

docker cp dddddbc9232a:/data/deploy/starrocks/fe/conf/fe.conf .
docker cp dddddbc9232a:/data/deploy/starrocks/be/conf/be.conf .

最后我们再编辑 /data/deploy/starrocks/supervisor/supervisord.conf,默认内容如下:

[unix_http_server]
file=%(ENV_SR_HOME)s/supervisor/supervisor.sock


[supervisord]
logfile=%(ENV_SR_HOME)s/supervisor/log/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=%(ENV_SR_HOME)s/supervisor/supervisord.pid
user=root
nodaemon=true


[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface


[supervisorctl]
serverurl=unix://%(ENV_SR_HOME)s/supervisor/supervisor.sock


[program:feservice]
command=%(ENV_SR_HOME)s/fe/bin/start_fe.sh
numprocs=1
directory=%(ENV_SR_HOME)s/fe
autostart=true
autorestart=true
startsecs=5
startretries=3
stopwaitsecs=15
stopasgroup=true
killasgroup=true
redirect_stderr=true
stdout_logfile=%(ENV_SR_HOME)s/fe/log/fe.out
stdout_logfile_maxbytes=200MB
stdout_logfile_backups=20


[program:beservice]
command=%(ENV_SR_HOME)s/be/bin/start_be.sh
numprocs=1
directory=%(ENV_SR_HOME)s/be
autostart=true
autorestart=true
startsecs=5
startretries=3
# do force kill before BE is good with graceful shutdown
stopsignal=KILL
stopwaitsecs=15
stopasgroup=true
killasgroup=true
redirect_stderr=true
stdout_logfile=%(ENV_SR_HOME)s/be/log/be.out
stdout_logfile_maxbytes=200MB
stdout_logfile_backups=20


[program:broker]
command=%(ENV_SR_HOME)s/apache_hdfs_broker/bin/start_broker.sh
numprocs=1
directory=%(ENV_SR_HOME)s/apache_hdfs_broker
autostart=true
autorestart=true
startsecs=5
startretries=3
stopwaitsecs=15
stopasgroup=true
killasgroup=true
redirect_stderr=true
stdout_logfile=%(ENV_SR_HOME)s/apache_hdfs_broker/log/apache_hdfs_broker.out
stdout_logfile_maxbytes=200MB
stdout_logfile_backups=20


[program:feproxy]
command=nginx -g "daemon off;" -c %(ENV_SR_HOME)s/feproxy/feproxy.conf
numprocs=1
directory=%(ENV_SR_HOME)s/feproxy
autostart=true
autorestart=true
startsecs=5
startretries=3
stopwaitsecs=15
redirect_stderr=true
stdout_logfile=%(ENV_SR_HOME)s/feproxy/log/feproxy.out
stdout_logfile_maxbytes=200MB
stdout_logfile_backups=20


[program:director]
command=%(ENV_SR_HOME)s/director/run.sh
numprocs=1
directory=%(ENV_SR_HOME)s/director
autostart=true
autorestart=true
startsecs=5
startretries=3
stopwaitsecs=15
redirect_stderr=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0

其中 brokerfeproxy 以及 director 的配置我们用不到,如果开启 director 由于集群配置了密码等还会导致报错重启,所以这个没必要开启,因此将这几个块直接删除掉即可,删除后保存配置文件。

最后我们清理历史命令:

history -c
# 退出容器
exit

然后我们将容器保存为镜像:

docker commit -m "StarRocks 3.2.3 from allin1-ubuntu:3.2.3" dddddbc9232a starrocks:3.2.3

然后我们使用 Docker Compose 管理 StarRocks 进程,创建 docker-compose.yml 配置如下:

version: '3'
services:
  starrocks:
    image: starrocks:3.2.3
    container_name: starrocks-container
    command: ./entrypoint.sh
    restart: always
    network_mode: "host"
    environment:
      - TZ=Asia/Shanghai
    volumes:
      - ./conf/fe.conf:/data/deploy/starrocks/fe/conf/fe.conf
      - ./conf/be.conf:/data/deploy/starrocks/be/conf/be.conf
      - /var/log/starrocks/fe:/data/deploy/starrocks/fe/log
      - /var/log/starrocks/be:/data/deploy/starrocks/be/log
      - /data/starrocks/meta:/data/deploy/starrocks/fe/meta
      - /data/starrocks/storage:/data/deploy/starrocks/be/storage

为了保证性能我们直接使用主机网络模式,这样我们只需要正常配置我们外部的配置文件即可,所有的端口都是直接在主机上监听,所以不要忘记修改 priority_networks 配置。另外我们分别映射了 StarRocks 的 FE 和 BE 日志目录,这个也无需修改内部的配置。最后就是数据目录,我们将外部自定义的数据目录映射到了内部默认位置,所以配置文件中的数据目录也无需修改,只需要修改我们映射的外部目录即可。但是我们要加上 command 指定容器启动的命令,因为我们后面进入容器的时候用了 /bin/bash 这样会将原有镜像默认的 CMD 覆盖掉,当我们提交镜像后默认就变成容器初次启动时的命令 /bin/bash 了,这个时候我们也可以用 entrypoint.sh 启动一次镜像再提交,或者是初次启动容器时用默认命令,我们再用 docker exec 进入容器这样也不会破坏原有镜像默认的入口。

另外注意如果是从之前手动部署的 StarRocks 集群上升级成容器化集群,那么需要设置容器的主机名,如果是 IP 地址访问那么需要将主机名设置为 IP:

version: '3'
services:
  starrocks:
    hostname: x.x.x.x

否则如果启用了主机名访问,那么需要设置为本机实际的主机名并且需要映射主机的 hosts 文件:

version: '3'
services:
  starrocks:
    hostname: host1

默认主机上的 /etc/hosts会自动映射进去可以无需其他配置。

经过上面的调整这样才可以正常启动,否则会报错:

Detect FE service hostname mismatch, FE service won't start.
This is probably caused by persisted fe/meta from outside container, but the container's hostname is not fixed. If running with docker engine, use '-h <hostname>' to assign a fixed hostname and restart.

因为原来的集群 meta 信息已经保存了原来的主机名,启动的时候 FE 会进行校验,不符合将会退出。如果是新部署集群则没有这个问题。

标签:容器,StarRocks,SR,starrocks,fe,conf,HOME,镜像,true
From: https://www.cnblogs.com/freeweb/p/18288761

相关文章

  • Python——习题练习 part2 数据容器
    本篇文章记录python数据容器章节的练习题。目录五,数据容器01列表1.列表的常用功能2.列表循环遍历02元组基本操作03字符串的分割04序列的切片05集合信息去重06字典五,数据容器01列表1.列表的常用功能题目如下:答案如下:#列表List的常用操作#定义列表......
  • pip国内镜像源
    使用方法pipinstall第三方库的名称-i镜像源pipinstall-rrequirements.txt-i镜像源镜像源1.1清华大学https://pypi.tuna.tsinghua.edu.cn/simple1.2阿里云https://mirrors.aliyun.com/pypi/simple/1.3网易https://mirrors.163.com/pypi/simple/1.4豆......
  • 力扣—盛水最大的容器—双指针
    文章目录题目解析解题思路代码实现题目解析解题思路利用单调性控制其中一个变量,使用双指针控制另一个变量。我们知道S1(面积)=h(高度)*w(宽度)。由于高度的大小是随机的不可控,所以我们可以尝试控制宽度,定义变量left和right分别指向数组第一个元素和最后一个元素......
  • Docker容器监控之CAdvisor+InfluxDB+Granfana
    1、编写docker-compose.ymlvolumes:grafana_data:{}services:influxdb:image:tutum/influxdbrestart:alwaysenvironment:-PRE_CREATE_DB=cadvisorports:-"8083:8083"-"8086:8086"volumes:-./data/influ......
  • 安装Nexus3和使用Nexus3搭建私有docker镜像仓库
    1、官网下载Nexus3:https://help.sonatype.com/en/download.html2、上传到服务器后解压:tar-xfnexus-3.69.0-02-java8-unix.tar.gz3、修改运行nexus配置【1】修运行nexus所使用的用户:vim/opt/nexus3/nexus-3.69.0-02/binexus.rc#修改默认登陆用户为admin#run_as_user=......
  • python数据容器(二)元组
    1.数据容器:tuple(元组)(1)定义t1=(1,"Hello",True)t2=()t3=tuple()print(f"t1的类型是:{type(t1)},内容是:{t1}")print(f"t2的类型是:{type(t2)},内容是:{t2}")print(f"t3的类型是:{type(t3)},内容是:{t3}")运行结果:(2)定义单个元素的元素t1=("hel......
  • python数据容器(一)列表list
    思维导图代码1.数据容器入门2.数据容器:list(列表)name_list=['itheima','itcast','python']print(name_list)print(type(name_list))运行结果: name_list=['itheima',666,True]print(name_list)print(type(name_list))运行结果: name_l......
  • 52-3 权限维持 - IFEO注入(镜像劫持)
    IFEO注入(映像劫持)介绍IFEO(ImageFileExecutionOptions)位于Windows注册表中的路径为:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\ImageFileExecutionOptionsIFEO最初设计用于为在默认系统环境下可能出现错误的程序提供特殊的调试和执行环境。通过......
  • Linux容器篇-使用kubeadm搭建一个kubernetes集群
    kubernetes集群架构和组件master节点组件kube-apiserver:KubernetesAPI,集群的统一入口,各组件的协调者,以RESTfulAPI提供接口服务,所有对象资源的增删改查和监听操作都交给APIserver处理后再交给Etcd存储。kube-controller-manager:处理集群中的常规后台事务,一个资源对应......
  • C++容器map的常见用法
    文章目录1.map和multimap容器1.map容器的构造和赋值1.构造函数2.赋值操作2.map容器的大小和交换1.获取大小2.交换内容3.map容器的插入和删除1.插入元素2.删除元素3.注意事项4.map容器的查找和统计1.查找元素2.统计元素3.示例5.map容器的排序1.自定义排序规则2.注意点......