본문 바로가기
WAS/WEBLOGIC

7. 기동/중지 스크립트

by coldplayer83 2023. 7. 4.
728x90

startA.sh

USER_NAME=app
SERVER_NAME=AdminServer
SERVER_PORT=7001
DOMAIN_HOME=/sw/was/weblogic/12.2.1.4/domains/base_domain
LOG_DIR=${DOMAIN_HOME}/logs

# Check User Name
IAM=`id -un`
# Check Startup User Check
if [ $USER_NAME != $IAM ] ; then
echo "Error : This user is \"$IAM\". Please login as a \"$USER_NAME\" user."
exit
fi

# Check Process Check
PID=`ps -ef | grep java | grep ${SERVER_NAME} | grep ${SERVER_PORT} | awk '{print $2}'`
if [ "$PID" != "" ] ; then
echo "ERROR : \"${SERVER_NAME}\" server is already running!!"
exit
fi

USER_MEM_ARGS="-D${SERVER_NAME} -D${SERVER_PORT} -Xms512m -Xmx512m"
USER_MEM_ARGS="${USER_MEM_ARGS} -Djava.security.egd=file:///dev/urandom"
USER_MEM_ARGS="${USER_MEM_ARGS} -Dweblogic.system.BootIdentityFile=./boot.properties"
export USER_MEM_ARGS
mv ${LOG_DIR}/${SERVER_NAME}.out ${LOG_DIR}/${SERVER_NAME}.`date +'%y%m%d_%H%M%S'`

nohup ./startWebLogic.sh > ${LOG_DIR}/${SERVER_NAME}.out 2>&1 &
sleep 1

tail -f ${LOG_DIR}/${SERVER_NAME}.out

USER_NAME : 웹로직 계정

SERVER_NAME : 어드민 서버 이름

SERVER_PORT : 어드민 서버 포트

DOMAIN_HOME : 도메인 홈

LOG_DIR : 로그 경로

(별도로 작성하지 않는 경우 도메인 홈 밑에 logs 디렉토리를 생성해야 기동시 에러가 발생하지 않는다)

 

USER_MEM_ARGS="${USER_MEM_ARGS} -Djava.security.egd=file:///dev/urandom  

- 이 옵션은 고객사에서 서버 기동시 특정 구간에서 hang걸리면 추가

 


 

startA.sh (extended)

#!/bin/sh
DOMAIN_NAME=MEDIdomain
DOMAIN_HOME=/product/weblogic12c/domains/${DOMAIN_NAME}
SERVER_NAME=AdminServer
SERVER_PORT=7001
BOOT_PROPERTIES=${DOMAIN_HOME}/boot.properties
LOG_DIR=/logs/MEDI/weblogic_admin
GC_LOG_DIR=${LOG_DIR}/../gc/${SERVER_NAME}
LOG_TIME=`date +%y%m%d_%H%M`


## mkdir ##
if [ ! -f $GC_LOG_DIR ]; then
     mkdir -p $GC_LOG_DIR
fi
#############


## User Check ##
USER=weblogic
if [ "$USER" != `/usr/bin/whoami` ]; then
     echo "* you do not have permission. *"
     exit;
fi
################


## Process Check ##
WAS_PID=`ps -ef | grep java | grep -w "${SERVER_NAME}" | awk '{print $2}'`;
if [ "$WAS_PID" != "" ]; then
     echo "Server already Started... Please shutdown Server!!"
     exit;
fi
###################

##### gc log rotation #####
USER_MEM_ARGS="${USER_MEM_ARGS} -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:${GC_LOG_DIR}/gc_${SERVER_NAME}.out"
mv ${GC_LOG_DIR}/gc_${SERVER_NAME}.out ${GC_LOG_DIR}/gc_${SERVER_NAME}.out.${LOG_TIME}
######################


##### heap dump #####
USER_MEM_ARGS="${USER_MEM_ARGS} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOG_DIR}/heapdump"
######################


USER_MEM_ARGS="${USER_MEM_ARGS} -Xms512m -Xmx512m"
USER_MEM_ARGS="${USER_MEM_ARGS} -Dweblogic.threadpool.MinPoolSize=200 -Dweblogic.threadpool.MaxPoolSize=400"
USER_MEM_ARGS="${USER_MEM_ARGS} -Dweblogic.wsee.skip.async.response=true -Dserver.name=${SERVER_NAME} -Dserver.port=${SERVER_PORT}"
USER_MEM_ARGS="${USER_MEM_ARGS} -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv6Addresses=false"
USER_MEM_ARGS="${USER_MEM_ARGS} -D_Offline_FileDataArchive=true -Dweblogic.connector.ConnectionPoolProfilingEnabled=false -Dcom.bea.wlw.netui.disableInstrumentation=true"
export USER_MEM_ARGS


JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.system.BootIdentityFile=${BOOT_PROPERTIES}"
export JAVA_OPTIONS


mv ${LOG_DIR}/${SERVER_NAME}.out ${LOG_DIR}/${SERVER_NAME}.out.${LOG_TIME}
nohup ${DOMAIN_HOME}/bin/startWebLogic.sh > ${LOG_DIR}/${SERVER_NAME}.out 2>&1 &
sleep 1
tail -f $LOG_DIR/$SERVER_NAME.out

 

내용 변경이 필요한 부분)

DOMAIN_NAME

DOMAIN_HOME

SERVER_NAME

SERVER_PORT

BOOT_PROPERTIES

LOG_DIR

GC_LOG_DIR

USER


 

startM1.sh

USER_NAME=app
SERVER_NAME=M1
SERVER_PORT=7002
DOMAIN_HOME=/sw/was/weblogic/12.2.1.4/domains/base_domain
LOG_DIR=${DOMAIN_HOME}/logs
ADMIN_URL=t3://192.168.56.101:7001

# Check User Name
IAM=`id -un`
# Check Startup User Check
if [ $USER_NAME != $IAM ] ; then
echo "Error : This user is \"$IAM\". Please login as a \"$USER_NAME\" user."
exit
fi

# Check Process Check
PID=`ps -ef | grep java | grep ${SERVER_NAME} | grep ${SERVER_PORT} | awk '{print $2}'`
if [ "$PID" != "" ] ; then
echo "ERROR : \"${SERVER_NAME}\" server is already running!!"
exit
fi

USER_MEM_ARGS="-D${SERVER_NAME} -D${SERVER_PORT} -Xms1024m -Xmx1024m"
USER_MEM_ARGS="${USER_MEM_ARGS} -Djava.security.egd=file:///dev/urandom"
USER_MEM_ARGS="${USER_MEM_ARGS} -Dweblogic.system.BootIdentityFile=./boot.properties"
USER_MEM_ARGS="${USER_MEM_ARGS} -XX:+HeapDumpOnOutOfMemoryError"
export USER_MEM_ARGS

mv ${LOG_DIR}/${SERVER_NAME}.out ${LOG_DIR}/${SERVER_NAME}.`date +'%y%m%d_%H%M%S'`
nohup ./bin/startManagedWebLogic.sh ${SERVER_NAME} ${ADMIN_URL} > ${LOG_DIR}/${SERVER_NAME}.out 2>&1 &
sleep 1

tail -f ${LOG_DIR}/${SERVER_NAME}.out

 


 

startM1.sh (extended)

#!/bin/sh
DOMAIN_NAME=MEDIdomain
DOMAIN_HOME=/product/weblogic12c/domains/${DOMAIN_NAME}
SERVER_NAME=mediscm1
SERVER_PORT=9001
ADM_URL="t3://115.91.31.155:7001"
BOOT_PROPERTIES=${DOMAIN_HOME}/boot.properties
LOG_DIR=/logs/MEDI/weblogic_domain
GC_LOG_DIR=${LOG_DIR}/../gc/${SERVER_NAME}
LOG_TIME=`date +%y%m%d_%H%M`


#### mkdir ####
if [ ! -f $GC_LOG_DIR ]; then
     mkdir -p $GC_LOG_DIR
fi
#############


### User Check ###
USER=weblogic
if [ "$USER" != `/usr/bin/whoami` ]; then
     echo "* you do not have permission. *"
     exit;
fi
################


### Process Check ###
WAS_PID=`ps -ef | grep java | grep -w "$SERVER_NAME" | awk '{print $2}'`;
if [ "$WAS_PID" != "" ]; then
     echo "Server already Started... Please shutdown Server!!"
     exit;
fi
###################

##### gc log rotation #####
USER_MEM_ARGS="${USER_MEM_ARGS} -verbose:gc -Xloggc:${GC_LOG_DIR}/gc_${SERVER_NAME}.out"
mv ${GC_LOG_DIR}/gc_${SERVER_NAME}.out ${GC_LOG_DIR}/gc_${SERVER_NAME}.out.${LOG_TIME}
######################


##### heap dump #####
USER_MEM_ARGS="${USER_MEM_ARGS} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOG_DIR}/heapdump"
######################


USER_MEM_ARGS="${USER_MEM_ARGS} -Xms2048m -Xmx2048m"
USER_MEM_ARGS="${USER_MEM_ARGS} -Dweblogic.threadpool.MinPoolSize=200 -Dweblogic.threadpool.MaxPoolSize=400"
USER_MEM_ARGS="${USER_MEM_ARGS} -Dweblogic.wsee.skip.async.response=true -Dserver.name=${SERVER_NAME} -Dserver.port=${SERVER_PORT}"
USER_MEM_ARGS="${USER_MEM_ARGS} -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv6Addresses=false"
USER_MEM_ARGS="${USER_MEM_ARGS} -D_Offline_FileDataArchive=true -Dweblogic.connector.ConnectionPoolProfilingEnabled=false -Dcom.bea.wlw.netui.disableInstrumentation=true"
## scouter ##
USER_MEM_ARGS="${USER_MEM_ARGS} -javaagent:/product/scouter/agent.java/scouter.agent.jar -Dscouter.config=/product/scouter/agent.java/conf/MSCM1.conf"
#############

export USER_MEM_ARGS


JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.system.BootIdentityFile=${BOOT_PROPERTIES}"
export JAVA_OPTIONS


mv ${LOG_DIR}/${SERVER_NAME}.out ${LOG_DIR}/${SERVER_NAME}.out.${LOG_TIME}
nohup ${DOMAIN_HOME}/bin/startManagedWebLogic.sh ${SERVER_NAME} ${ADM_URL} > ${LOG_DIR}/${SERVER_NAME}.out 2>&1 &
sleep 1
tail -f $LOG_DIR/$SERVER_NAME.out

 

내용 변경이 필요한 부분)

DOMAIN_NAME

DOMAIN_HOME

SERVER_NAME

SERVER_PORT

ADM_URL

BOOT_PROPERTIES

LOG_DIR

GC_LOG_DIR

USER


 

stop.py

connect(url=sys.argv[1])
shutdown(force='true')
exit()

 


 

stop.py (graceful)

connect(url=sys.argv[1])
shutdown(force='false',timeOut=60)
exit()

 


 

stopA.sh

SERVER_URL=t3://testap1:7001
. ./bin/setDomainEnv.sh
java weblogic.WLST stop.py ${SERVER_URL}

 


 

stopM1.sh

SERVER_URL=t3://testap1:7002
. ./bin/setDomainEnv.sh
java weblogic.WLST stop.py ${SERVER_URL}

 


 

stop.sh

PID=`ps -ef | grep weblogic.Server | grep 8250 | awk '{print $2}'`
kill -9 ${PID}
echo WebLogic Server stopping.....

 


 

forceshutdown.sh

. ./bin/setDomainEnv.sh
java weblogic.Admin -url t3://193.1.8.174:21091 -username weblogic -password weblogic FORCESHUTDOWN

 


 

stop.py를 사용하지 않고 admin 통해서 stop 하는 방법)

 

https://docs.oracle.com/cd/E24329_01/web.1211/e21048/overview.htm#START140

 

Starting and Stopping Servers

5/9 2 Starting and Stopping Servers This chapter describes how to start and stop server instances in WebLogic Server. The method you choose depends on whether you prefer using the Administration Console or a command line, and on whether you are using Node

docs.oracle.com

 

 

참고) 

https://blueyikim.tistory.com/2573

'WAS > WEBLOGIC' 카테고리의 다른 글

9. 배치  (0) 2023.07.04
8. 자바 옵션 설정  (0) 2023.07.04
6. boot.properties  (0) 2023.07.04
5. Managed Server 구성  (0) 2023.07.03
4. 서버 환경 설정  (0) 2023.06.28