#!/bin/bash
# 定义 StarRocks 安装目录
STARROCKS_HOME="/path/to/starrocks"# 定义 FE 和 BE 节点列表
FE_NODES=("fe_node1_ip" "fe_node2_ip" "fe_node3_ip")
BE_NODES=("be_node1_ip" "be_node2_ip" "be_node3_ip")# 定义日志文件
LOG_FILE="starrocks_stop.log"# 记录日志函数
log() {
local timestamp=$(date +"%Y-%m-%d %H:%M:%S")
echo "$timestamp - $1" >> $LOG_FILE
}# 检查参数数量
if [ $# -ne 2 ]; then
log "Usage: $0 stop {fe|be}"
echo "Usage: $0 stop {fe|be}"
exit 1
fi# 检查操作是否为停止
if [ "$1" != "stop" ]; then
log "Invalid operation. Only 'stop' is supported."
echo "Invalid operation. Only 'stop' is supported."
exit 1
fi# 根据组件类型停止相应节点
case "$2" in
"fe")
log "Stopping Frontend (FE) nodes..."
for node in "${FE_NODES[@]}"; do
log "Stopping FE on $node..."
ssh $node "$STARROCKS_HOME/fe/bin/stop_fe.sh"
if [ $? -eq 0 ]; then
log "FE on $node stopped successfully."
else
log "Failed to stop FE on $node."
fi
done
;;
"be")
log "Stopping Backend (BE) nodes..."
for node in "${BE_NODES[@]}"; do
log "Stopping BE on $node..."
ssh $node "$STARROCKS_HOME/be/bin/stop_be.sh"
if [ $? -eq 0 ]; then
log "BE on $node stopped successfully."
else
log "Failed to stop BE on $node."
fi
done
;;
*)
log "Invalid component type. Please specify 'fe' or 'be'."
echo "Invalid component type. Please specify 'fe' or 'be'."
exit 1
;;
esaclog "Batch stop process completed."
echo "Batch stop process completed. Check $LOG_FILE for details."
#!/bin/bash
# 定义 StarRocks 安装目录
STARROCKS_HOME="/path/to/starrocks"# 定义 FE 和 BE 节点列表
FE_NODES=("fe_node1_ip" "fe_node2_ip" "fe_node3_ip")
BE_NODES=("be_node1_ip" "be_node2_ip" "be_node3_ip")# 定义日志文件
LOG_FILE="starrocks_stop.log"# 记录日志函数
log() {
local timestamp=$(date +"%Y-%m-%d %H:%M:%S")
echo "$timestamp - $1" >> $LOG_FILE
}# 检查参数数量
if [ $# -ne 2 ]; then
log "Usage: $0 stop {fe|be}"
echo "Usage: $0 stop {fe|be}"
exit 1
fi# 检查操作是否为停止
if [ "$1" != "stop" ]; then
log "Invalid operation. Only 'stop' is supported."
echo "Invalid operation. Only 'stop' is supported."
exit 1
fi# 根据组件类型停止相应节点
case "$2" in
"fe")
log "Stopping Frontend (FE) nodes..."
for node in "${FE_NODES[@]}"; do
log "Stopping FE on $node..."
ssh $node "$STARROCKS_HOME/fe/bin/stop_fe.sh"
if [ $? -eq 0 ]; then
log "FE on $node stopped successfully."
else
log "Failed to stop FE on $node."
fi
done
;;
"be")
log "Stopping Backend (BE) nodes..."
for node in "${BE_NODES[@]}"; do
log "Stopping BE on $node..."
ssh $node "$STARROCKS_HOME/be/bin/stop_be.sh"
if [ $? -eq 0 ]; then
log "BE on $node stopped successfully."
else
log "Failed to stop BE on $node."
fi
done
;;
*)
log "Invalid component type. Please specify 'fe' or 'be'."
echo "Invalid component type. Please specify 'fe' or 'be'."
exit 1
;;
esaclog "Batch stop process completed."
echo "Batch stop process completed. Check $LOG_FILE for details."