Flink Data스트림 에러 해결 및, 실행/ 중지를 스크립트를 통해 관리하게 하였다.
boot.sh
######parameter#######
HBASE_HOME="/opt/hbase-1.4.6/bin"
HBASE_LOG="/opt/hbase-1.4.6/logs"
FLINK_HOME="/opt/flink-1.6.3/bin"
PINPOINT_HOME="/opt/pinpoint/pinpoint"
PINPOINT_VERSION="2.3.3"
###parameter for log dir
CURRENT_TIME=$(TZ="Asia/Seoul" date +"%Y%m%d_%H%M")
FLINK_JOB_DIR="/opt/script/logs/flink_job"
PINPOINT_WEB_DIR="/opt/script/logs/pinpoint_web"
PINPOINT_COL_DIR="/opt/script/logs/pinpoint_col"
set_timer() {
REMAIN_TIME=${1}
WAIT_TIME=0
while [ ${WAIT_TIME} -lt ${REMAIN_TIME} ]; do
WAIT_TIME=$((WAIT_TIME + 2))
echo "[Timer]wait ... ${WAIT_TIME} / ${REMAIN_TIME} sec"
sleep 2 # 2초 대기
done
}
## 1. start hbase
echo "1. start hbase"
echo "1-1. Start hbase shell"
sudo ${HBASE_HOME}/start-hbase.sh
echo "Waiting for booting Hbase Server..."
set_timer "20"
## 2. start Flink
sleep 1
echo "2-1. Start Flink Cluster"
sudo ${FLINK_HOME}/start-cluster.sh
echo "Waiting for booting Flink Server..."
set_timer "10"
echo "2-2. Start pinpoint-flink-job"
sudo nohup ${FLINK_HOME}/flink run ${FLINK_HOME}/pinpoint-flink-job-2.3.3.jar -Dspring.profiles.active=release > "$FLINK_JOB_DIR/pinpoint_flink_job_${CURRENT_TIME}.log" 2>&1 &
set_timer "5"
## 3. start Pinpoint
echo "3-1. Pinpoint Web Load.."
sudo nohup /opt/java/openlogic-openjdk-8u392-b08-linux-x64/bin/java -jar -Dpinpoint.zookeeper.address=localhost ${PINPOINT_HOME}-web-boot-${PINPOINT_VERSION}.jar --server.port=8180 > "$PINPOINT_WEB_DIR/pinpoint_web_${CURRENT_TIME}.log" 2>&1 &
set_timer "4"
echo "3-2. Pinpoint Collector Load.."
sudo nohup /opt/java/openlogic-openjdk-8u392-b08-linux-x64/bin/java -jar -Dpinpoint.zookeeper.address=localhost ${PINPOINT_HOME}-collector-boot-${PINPOINT_VERSION}.jar --server.port=8181 > "$PINPOINT_COL_DIR/pinpoint_col_${CURRENT_TIME}.log" 2>&1 &
set_timer "4"
## 4. end
echo "4. Find Hbase Web UI Port"
#grep, tail로 마지막 줄 탐색 후 ,awk 사용.
LAST_PORT=$(grep "Jetty bound to port" $HBASE_LOG/*.log | tail -n 1 | awk '{print $NF}')
echo "Hbase Web UI Port(Last Jetty) : $LAST_PORT"
echo "Boot Well Done, now Time = ${CURRENT_TIME}"
close.sh
#Close service
######parameter#######
HBASE_HOME="/opt/hbase-1.4.6/bin"
FLINK_HOME="/opt/flink-1.6.3/bin"
close_process() {
PROCESS_NAME=${@}
while true; do
PID=$(pgrep -f "$PROCESS_NAME")
if ! pgrep -f $PROCESS_NAME > /dev/null; then
echo "No more ${PROCESS_NAME} is running."
break
else
echo "close ${PID}, find more ${PROCESS_NAME}..."
sudo kill -9 $PID
sleep 2
fi
done
}
##1. pinpoint web, collector
echo "1. Close Pinpoint"
close_process "pinpoint"
##2. flink job, cluster
echo "2-1. Close Flink Job"
JOB_ID=$(timeout 10s $FLINK_HOME/flink list | grep " : " | awk '{print $4}')
if [ ! -z "$JOB_ID" ]; then
echo "Cancelling Flink job with ID: $JOB_ID"
$FLINK_HOME/flink cancel $JOB_ID
else
echo "No running Flink jobs found."
fi
echo "2-2. Close Flink"
close_process "flink"
##3. hbase
echo "3. Close Hbase"
sudo ${HBASE_HOME}/stop-hbase.sh
##4.end
echo "Close Well Done"
'프로젝트 > Pinpoint, Scouter 구축(APM)' 카테고리의 다른 글
Pinpoint와 Scouter 주요 기능 분석 (0) | 2024.01.24 |
---|---|
[Pinpoint]startTimestamp must be less than endTimestamp 에러 (1) | 2024.01.24 |
Scouter 설치와 적용 (0) | 2024.01.23 |
Pinpoint - flink 연동 2 (0) | 2024.01.22 |
Pinpoint - Application Inspector 기능 적용 (Flink 연동) (0) | 2024.01.19 |