第 1 步(1/3):下载启动脚本
#!/bin/bash# Default versionDORIS_QUICK_START_VERSION="latest"# Parse parameterswhilegetopts"v:"opt;docase$optinv)DORIS_QUICK_START_VERSION="$OPTARG";;\?)echo"Invalid option: -$OPTARG">&2exit1;;esacdone# Check system typeOS_TYPE=$(uname-s)if[["$OS_TYPE"!="Linux"&&"$OS_TYPE"!="Darwin"]];thenecho"Error: Unsupported operating system [$OS_TYPE], only Linux and Mac are supported"exit1fi# Check Docker environmentif!command-vdocker&>/dev/null;thenecho"Error: Docker environment not detected, please install Docker first"exit1fi# Check docker-composeCOMPOSE_CMD=""ifcommand-vdocker-compose&>/dev/null;thenCOMPOSE_CMD="docker-compose"elifdockercompose version&>/dev/null;thenCOMPOSE_CMD="docker compose"elseecho"Error: docker-compose plugin or docker-compose command is required"exit1fi# Generate docker-compose configuration for corresponding systemif[["$OS_TYPE"=="Linux"]];thencat>docker-compose-doris.yaml<<EOF version: "3" services: fe: image: apache/doris:fe-${DORIS_QUICK_START_VERSION}hostname: fe environment: - FE_SERVERS=fe1:127.0.0.1:9010 - FE_ID=1 network_mode: host be: image: apache/doris:be-${DORIS_QUICK_START_VERSION}hostname: be environment: - FE_SERVERS=fe1:127.0.0.1:9010 - BE_ADDR=127.0.0.1:9050 depends_on: - fe network_mode: host EOFelse# Mac systemcat>docker-compose-doris.yaml<<EOF version: "3" networks: custom_network: driver: bridge ipam: config: - subnet: 172.20.80.0/24 services: fe: image: apache/doris:fe-${DORIS_QUICK_START_VERSION}hostname: fe ports: - 8030:8030 - 9030:9030 - 9010:9010 environment: - FE_SERVERS=fe1:172.20.80.2:9010 - FE_ID=1 networks: custom_network: ipv4_address: 172.20.80.2 be: image: apache/doris:be-${DORIS_QUICK_START_VERSION}hostname: be ports: - 8040:8040 - 9050:9050 environment: - FE_SERVERS=fe1:172.20.80.2:9010 - BE_ADDR=172.20.80.3:9050 depends_on: - fe networks: custom_network: ipv4_address: 172.20.80.3 EOFfi# Start servicesif!$COMPOSE_CMD-fdocker-compose-doris.yaml up -d;thenecho"Error: Failed to start Doris cluster"exit1fiecho"Doris cluster started successfully, version:${DORIS_QUICK_START_VERSION}"echo"You can manage the cluster using the following commands:"echo" Stop cluster:$COMPOSE_CMD-f docker-compose-doris.yaml down"echo" View logs:$COMPOSE_CMD-f docker-compose-doris.yaml logs -f"echo" Connect to cluster: mysql -uroot -P9030 -h127.0.0.1"# Display connection information based on system typeif[["$OS_TYPE"=="Linux"]];thenecho-e"\nAccess FE/BE http ports (8030, 8040) using the following addresses (Linux system):"echo" http://127.0.0.1:8030"echo" http://127.0.0.1:8040"elif[["$OS_TYPE"=="Darwin"]];thenecho-e"\nAccess FE/BE http ports (8030, 8040) using the following addresses (Mac system):"echo" http://docker.for.mac.localhost:8030"echo" http://docker.for.mac.localhost:8040"echo"Note: If access fails, try using 127.0.0.1 address:"echo" http://127.0.0.1:8030"echo" http://127.0.0.1:8040"fi运行以下命令赋予执行权限:
chmod755start-doris.sh第 2 步(2/3):启动集群
运行脚本启动集群(默认使用 4.0.1 版本):
bashstart-doris.sh如需指定版本,使用 -v 参数:
bashstart-doris.sh-v4.1.0第 3 步(3/3):验证集群状态
使用 MySQL 客户端连接集群,检查 FE 和 BE 状态
-- 目的:验证 FE 节点是否正常加入集群 -- 期望:Join 和 Alive 列均为truemysql-uroot-P9030-h127.0.0.1-e'SELECT `host`, `join`, `alive` FROM frontends()'-- 目的:验证 BE 节点是否正常心跳 -- 期望:Alive 列为1mysql-uroot-P9030-h127.0.0.1-e'SELECT `host`, `alive` FROM backends()'输出解析: Alive=true(FE)或 Alive=1(BE)表示节点运行正常。