diff --git a/docker/thirdparties/docker-compose/hive/hive-2x.yaml.tpl b/docker/thirdparties/docker-compose/hive/hive-2x.yaml.tpl index 6460111221..57521e214d 100644 --- a/docker/thirdparties/docker-compose/hive/hive-2x.yaml.tpl +++ b/docker/thirdparties/docker-compose/hive/hive-2x.yaml.tpl @@ -63,8 +63,10 @@ services: expose: - "${HS_PORT}" depends_on: - - datanode - - namenode + datanode: + condition: service_healthy + namenode: + condition: service_healthy healthcheck: test: beeline -u "jdbc:hive2://127.0.0.1:${HS_PORT}/default" -n health_check -e "show databases;" interval: 10s @@ -86,7 +88,8 @@ services: volumes: - ./scripts:/mnt/scripts depends_on: - - hive-metastore-postgresql + hive-metastore-postgresql: + condition: service_healthy healthcheck: test: ["CMD", "sh", "-c", "/mnt/scripts/healthy_check.sh"] interval: 20s diff --git a/docker/thirdparties/docker-compose/hive/hive-2x_settings.env b/docker/thirdparties/docker-compose/hive/hive-2x_settings.env index ddd4625aaa..9045bb9168 100644 --- a/docker/thirdparties/docker-compose/hive/hive-2x_settings.env +++ b/docker/thirdparties/docker-compose/hive/hive-2x_settings.env @@ -20,7 +20,7 @@ # Do not use "_" or other sepcial characters, only number and alphabeta. # NOTICE: change this uid will modify hive-*.yaml -export FS_PORT=8020 # should be same as hive3HmsPort in regression-conf.groovy +export FS_PORT=8020 # should be same as hive2HmsPort in regression-conf.groovy export HMS_PORT=9083 # should be same as hive2HmsPort in regression-conf.groovy export HS_PORT=10000 # should be same as hive2ServerPort in regression-conf.groovy export PG_PORT=5432 # should be same as hive2PgPort in regression-conf.groovy diff --git a/docker/thirdparties/docker-compose/hive/hive-3x.yaml.tpl b/docker/thirdparties/docker-compose/hive/hive-3x.yaml.tpl index e05e07c397..727b57050b 100644 --- a/docker/thirdparties/docker-compose/hive/hive-3x.yaml.tpl +++ b/docker/thirdparties/docker-compose/hive/hive-3x.yaml.tpl @@ -63,8 +63,10 @@ services: expose: - "${HS_PORT}" depends_on: - - datanode - - namenode + datanode: + condition: service_healthy + namenode: + condition: service_healthy healthcheck: test: beeline -u "jdbc:hive2://127.0.0.1:${HS_PORT}/default" -n health_check -e "show databases;" interval: 10s @@ -86,7 +88,8 @@ services: volumes: - ./scripts:/mnt/scripts depends_on: - - hive-metastore-postgresql + hive-metastore-postgresql: + condition: service_healthy healthcheck: test: ["CMD", "sh", "-c", "/mnt/scripts/healthy_check.sh"] interval: 20s diff --git a/docker/thirdparties/run-thirdparties-docker.sh b/docker/thirdparties/run-thirdparties-docker.sh index 72e980b75d..620f8c1c38 100755 --- a/docker/thirdparties/run-thirdparties-docker.sh +++ b/docker/thirdparties/run-thirdparties-docker.sh @@ -33,8 +33,9 @@ Usage: $0 [no option] start all components --help,-h show this usage -c mysql start MySQL - -c mysql,hive3 start MySQL and Hive3 + -c mysql,hive3 start MySQL and Hive3 --stop stop the specified components + --reserve-ports reserve host ports by setting 'net.ipv4.ip_local_reserved_ports' to avoid port already bind error All valid components: mysql,pg,oracle,sqlserver,clickhouse,es,hive2,hive3,iceberg,hudi,trino,kafka,mariadb,db2,kerberos,oceanbase @@ -47,6 +48,7 @@ if ! OPTS="$(getopt \ -o '' \ -l 'help' \ -l 'stop' \ + -l 'reserve-ports' \ -o 'hc:' \ -- "$@")"; then usage @@ -57,6 +59,7 @@ eval set -- "${OPTS}" COMPONENTS="" HELP=0 STOP=0 +NEED_RESERVE_PORTS=0 if [[ "$#" == 1 ]]; then # default @@ -80,6 +83,10 @@ else COMPONENTS=$2 shift 2 ;; + --reserve-ports) + NEED_RESERVE_PORTS=1 + shift + ;; --) shift break @@ -138,6 +145,8 @@ RUN_DB2=0 RUN_KERBEROS=0 RUN_OCENABASE=0 +RESERVED_PORTS="65535" + for element in "${COMPONENTS_ARR[@]}"; do if [[ "${element}"x == "mysql"x ]]; then RUN_MYSQL=1 @@ -153,6 +162,7 @@ for element in "${COMPONENTS_ARR[@]}"; do RUN_ES=1 elif [[ "${element}"x == "hive2"x ]]; then RUN_HIVE2=1 + RESERVED_PORTS="${RESERVED_PORTS},50070,50075" # namenode and datanode ports elif [[ "${element}"x == "hive3"x ]]; then RUN_HIVE3=1 elif [[ "${element}"x == "kafka"x ]]; then @@ -179,6 +189,17 @@ for element in "${COMPONENTS_ARR[@]}"; do fi done +reserve_ports() { + if [[ "${NEED_RESERVE_PORTS}" -eq 0 ]]; then + return + fi + + if [[ "${RESERVED_PORTS}"x != ""x ]]; then + echo "Reserve ports: ${RESERVED_PORTS}" + sudo sysctl -w net.ipv4.ip_local_reserved_ports="${RESERVED_PORTS}" + fi +} + start_es() { # elasticsearch cp "${ROOT}"/docker-compose/elasticsearch/es.yaml.tpl "${ROOT}"/docker-compose/elasticsearch/es.yaml @@ -609,6 +630,8 @@ start_kerberos() { echo "starting dockers in parrallel" +reserve_ports + declare -A pids if [[ "${RUN_ES}" -eq 1 ]]; then