合 使用Dockerfile部署StarRocks单机环境
Tags: 安装部署StarRocksdockerfile
前提条件
分类 | 描述 |
---|---|
硬件要求 | CPU 需支持 AVX2 指令集建议配置 8 核 或以上 CPU,16GB 或以上内存。 |
操作系统 | Linux kernel 3.10 以上。 |
软件要求 | DockerMySQL 客户端(5.5 或以上) |
创建 Dockerfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | mkdir /StarRocks cd /StarRocks cat > /StarRocks/Dockerfile <<"EOF" FROM centos:centos7 # Prepare StarRocks Installer. Replace the "2.5.3" below with the StarRocks version that you want to deploy. ENV StarRocks_version=2.5.3 # Create directory for deployment. ENV StarRocks_home=/data/deploy # Replace the "<url_to_download_specific_ver_of_starrocks>" below with the download path of the StarRocks that you want to deploy. ENV StarRocks_url=wget https://releases.mirrorship.cn/starrocks/StarRocks-2.5.3.tar.gz # Install StarRocks. RUN yum -y install wget RUN mkdir -p $StarRocks_home RUN wget -SO $StarRocks_home/StarRocks-${StarRocks_version}.tar.gz $StarRocks_url RUN cd $StarRocks_home && tar zxf StarRocks-${StarRocks_version}.tar.gz # Install Java JDK. RUN yum -y install java-1.8.0-openjdk-devel.x86_64 RUN rpm -ql java-1.8.0-openjdk-devel.x86_64 | grep bin$ # Create directory for FE meta and BE storage in StarRocks. RUN mkdir -p $StarRocks_home/StarRocks-${StarRocks_version}/fe/meta RUN mkdir -p $StarRocks_home/StarRocks-${StarRocks_version}/be/storage # Install relevant tools. RUN yum -y install mysql net-tools telnet # Run Setup script. COPY run_script.sh $StarRocks_home/run_script.sh RUN chmod +x $StarRocks_home/run_script.sh CMD $StarRocks_home/run_script.sh EOF |
注意:
1、修改StarRocks_version为具体版本号
2、将以上 StarRocks_url
替换为实际下载地址: https://www.mirrorship.cn/zh-CN/download/community
创建脚本文件
构建脚本文件 run_script.sh
以配置并启动 StarRocks。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | cat > /StarRocks/run_script.sh <<"EOF" #!/bin/bash # Set JAVA_HOME. JAVA_INSTALL_DIR=/usr/lib/jvm/$(rpm -aq | grep java-1.8.0-openjdk-1.8.0) export JAVA_HOME=$JAVA_INSTALL_DIR # Start FE. cd $StarRocks_home/StarRocks-$StarRocks_version/fe/bin/ ./start_fe.sh --daemon # Start BE. cd $StarRocks_home/StarRocks-$StarRocks_version/be/bin/ ./start_be.sh --daemon # Sleep until the cluster starts. sleep 30; # Set BE server IP. IP=$(ifconfig eth0 | grep 'inet' | cut -d: -f2 | awk '{print $2}') mysql -uroot -h${IP} -P 9030 -e "alter system add backend '${IP}:9050';" # Loop to detect the process. while sleep 60; do ps aux | grep starrocks | grep -q -v grep PROCESS_STATUS=$? if [ ${PROCESS_STATUS} -ne 0 ]; then echo "one of the starrocks process already exit." exit 1; fi done EOF |
搭建 Docker 镜像
运行以下命令搭建 Docker 镜像。
1 | docker build --no-cache --progress=plain -t starrocks:2.5.3 . |
启动 Docker 容器
运行以下命令启动 Docker 容器。