윈도우에 설치된 웹로직의 경우 OS 재기동시 자동으로 서버가 시작 수 있도록 서비스에 등록하는 것을 권장함
서비스 등록
1. {WL_HOME}\server\bin 디렉토리에 있는 두 개의 파일을 {DOMAIN_HOME}\svc로 복사
(svc는 임의로 만든 폴더 이름임)
- installSvc.cmd
- uninstallSvc.cmd
2. ${DOMAIN_HOME}\svc 디렉토리에 Admin_svc.cmd 파일 생성
@echo off
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_291
set JAVA_VM=-server
set CLASSPATH=%CLASSPATH%
set DOMAIN_NAME=base_domain
set MW_HOME=D:\weblogic\12.2.1.4
set USERDOMAIN_HOME=D:\weblogic\12.2.1.4\user_projects\domains\base_domain
set SERVER_NAME=AdminServer
set WLS_USER=weblogic
set WLS_PW=weblogic1
set PRODUCTION_MODE=true
set LOG_HOME=D:\weblogic\12.2.1.4\user_projects\domains\base_domain
set NOHUP_LOG_HOME=D:\weblogic\12.2.1.4\user_projects\domains\base_domain\logs
set GC_LOG_HOME=D:\weblogic\12.2.1.4\user_projects\domains\base_domain\logs\gc
set NOHUP_LOG=nohup_%SERVER_NAME%_out.log
set GC_LOG=gc_%SERVER_NAME%.log
set MEM_ARGS=-D%SERVER_NAME% -Xms512m -Xmx512m
set MEM_ARGS=%MEM_ARGS% -XX:NewSize=192m -XX:MaxNewSize=192m
set MEM_ARGS=%MEM_ARGS% -XX:MetaspaceSize=192m -XX:MaxMetaspaceSize=192m
set MEM_ARGS=%MEM_ARGS% -XX:+HeapDumpOnOutOfMemoryError
set MEM_ARGS=%MEM_ARGS% -XX:HeapDumpPath=D:\weblogic\12.2.1.4\user_projects\domains\base_domain\logs
set MEM_ARGS=%MEM_ARGS% -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -Xloggc:%GC_LOG_HOME%\%GC_LOG%
set MEM_ARGS=%MEM_ARGS% -Dweblogic.system.BootIdentiryFile=%USERDOMAIN_HOME%\boot.properties
각 항목을 해당 환경에 맞게 작성
자바 옵션의 경우 필요한 내용 선택 및 추가하여 작성
매니지드 서버 등록시에는 아래 내용 추가
Write the below line if you want to register managed servers.
set ADMIN_URL=t3://172.16.4.157:7001
3. 1에서 복사해온 installSvc.cmd 파일을 열어 상단과 하단에 다음을 추가
1) call %1
AdminSvc.cmd에 미리 선언한 변수값들을 적용
2) -log:"%USERDOMAIN_HOME%\logs\%SERVER_NAME%.out"
로그남기기
4. 관리자 권한의 cmd로 윈도우 서비스 등록해주기
cd D:\weblogic\12.2.1.4\user_projects\domains\base_domain\svc
installSvc.cmd Admin_svc.cmd
5. 서비스 확인
11g의 경우 wlsvc가 아닌 beasvc로 시작하는 이름으로 등록됨
서비스 삭제
1에서 복사한 uninstallSvc.cmd 파일 상단에 call %1을 추가하고 동일하게 관리자권한 cmd로 삭제 가능
!! 위의 AdminSvc.cmd 파일을 별도로 생성하여 호출하는 방법은 서버 환경변수 및 자바옵션 관련 파일을 별도로 생성하여 관리상의 이점이 있지만 제대로 동작하지 않는 경우도 있음
이 경우 installSvc.cmd, uninstallSvc.cmd 파일 중간에 환경변수 내용을 작성하여 해당 파일만 동작시켜 등록할 수도 있음
(@rem start_script ~ @rem stop_script 부분)
installSvc.cmd
@rem *************************************************************************
@rem This script is used to install WebLogic Server as a Windows Service.
@rem
@rem To create your own start script for your domain, simply set the
@rem SERVER_NAME variable to your server name then call this script from your
@rem domain directory.
@rem
@rem This script sets the following variables before installing
@rem WebLogic Server as a Windows Service:
@rem
@rem WL_HOME - The root directory of your WebLogic installation
@rem JAVA_HOME - Location of the version of Java used to start WebLogic
@rem Server. This variable must point to the root directory of a
@rem JDK installation and will be set for you by the installer.
@rem See the Oracle Fusion Middleware Supported System Configurations page
@rem (http://www.oracle.com/technology/software/products/ias/files/fusion_certification.html)
@rem for an up-to-date list of supported JVMs.
@rem PATH - Adds the JDK and WebLogic directories to the system path.
@rem CLASSPATH - Adds the JDK and WebLogic jars to the classpath.
@rem
@rem Other variables that installSvc takes are:
@rem
@rem WLS_USER - admin username for server startup
@rem WLS_PW - cleartext password for server startup
@rem ADMIN_URL - if this variable is set, the server started will be a
@rem managed server, and will look to the url specified (i.e.
@rem http://localhost:7001) as the admin server.
@rem PRODUCTION_MODE - set to true for production mode servers, false for
@rem development mode
@rem JAVA_OPTIONS - Java command-line options for running the server. (These
@rem will be tagged on to the end of the JAVA_VM and MEM_ARGS)
@rem JAVA_VM - The java arg specifying the VM to run. (i.e. -server,
@rem -client, etc.)
@rem MEM_ARGS - The variable to override the standard memory arguments
@rem passed to java
@rem
@rem
@rem MAX_CONNECT_RETRIES - Number of attempts the Windows Service will make to check
@rem if the Weblogic Server is started. If this variable
@rem is specified along with HOST and PORT, the Windows Service will
@rem wait until the Weblogic Server is started.
@rem HOST - IP address of the Weblogic Server
@rem PORT - Port number where the WebLogic Server is listening for requests
@rem
@rem jDriver for Oracle users: This script assumes that native libraries
@rem required for jDriver for Oracle have been installed in the proper
@rem location and that your system PATH variable has been set appropriately.
@rem
@rem For additional information, refer to "Managing Server Startup and Shutdown for Oracle WebLogic Server"
@rem (@DOCSWEBROOT/START/overview.htm).
@rem *************************************************************************
@echo off
SETLOCAL
@rem start_script
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_291
set JAVA_VM=-server
set JAVA_VENDOR=Sun
set CLASSPATH=%CLASSPATH%
set DOMAIN_NAME=base_domain
set MW_HOME=D:\weblogic\12.2.1.4
set USERDOMAIN_HOME=D:\weblogic\12.2.1.4\user_projects\domains\base_domain
set SERVER_NAME=AdminServer
set WLS_USER=weblogic
set WLS_PW=weblogic1
set PRODUCTION_MODE=true
set LOG_HOME=D:\weblogic\12.2.1.4\user_projects\domains\base_domain
set NOHUP_LOG_HOME=D:\weblogic\12.2.1.4\user_projects\domains\base_domain\logs
set GC_LOG_HOME=D:\weblogic\12.2.1.4\user_projects\domains\base_domain\logs\gc
set NOHUP_LOG=nohup_%SERVER_NAME%_out.log
set GC_LOG=gc_%SERVER_NAME%.log
set MEM_ARGS=-D%SERVER_NAME% -Xms512m -Xmx512m
set MEM_ARGS=%MEM_ARGS% -XX:NewSize=192m -XX:MaxNewSize=192m
set MEM_ARGS=%MEM_ARGS% -XX:MetaspaceSize=192m -XX:MaxMetaspaceSize=192m
set MEM_ARGS=%MEM_ARGS% -XX:+HeapDumpOnOutOfMemoryError
set MEM_ARGS=%MEM_ARGS% -XX:HeapDumpPath=D:\weblogic\12.2.1.4\user_projects\domains\base_domain\logs
set MEM_ARGS=%MEM_ARGS% -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -Xloggc:%GC_LOG_HOME%\%GC_LOG%
set MEM_ARGS=%MEM_ARGS% -Dweblogic.system.BootIdentiryFile=%USERDOMAIN_HOME%\boot.properties
@rem stop_script
@rem Check if SERVER_NAME is set
: check_server_name
if not defined SERVER_NAME (
@echo You need to set SERVER_NAME before
@echo installing WebLogic Server as a Windows Service
exit /b 1
)
@rem Check if DOMAIN_NAME is set
: check_domain_name
if not defined DOMAIN_NAME (
@echo You need to set DOMAIN_NAME before
@echo installing WebLogic Server as a Windows Service
exit /b 1
)
@rem Check if USERDOMAIN_NAME is set
: check_userdomain_home
if not defined USERDOMAIN_HOME (
@echo You need to set USERDOMAIN_HOME before
@echo installing WebLogic Server as a Windows Service
exit /b 1
)
@rem Check if SERVICE_DESCRIPTION is set
: check_server_name
if not defined SERVICE_DESCRIPTION (
set SERVICE_DESCRIPTION="WebLogicServer"
)
set WL_HOME=%MW_HOME%\wlserver
if not "%MEM_ARGS%" == "" (
set BACKUP_MEM_ARGS=%MEM_ARGS%
)
call "%WL_HOME%\..\oracle_common\common\bin\commEnv.cmd"
if not "%BACKUP_MEM_ARGS%" == "" (
set MEM_ARGS=%BACKUP_MEM_ARGS%
)
@rem Check that the WebLogic classes are where we expect them to be
:checkWLS
if exist "%WL_HOME%\server\lib\weblogic.jar" goto checkJava
echo The WebLogic Server wasn't found in directory %WL_HOME%\server.
echo Please edit your script so that the WL_HOME variable points
echo to the WebLogic installation directory.
goto finish
@rem Check that java is where we expect it to be
:checkJava
if exist "%JAVA_HOME%\bin\java.exe" goto runWebLogic
echo The JDK wasn't found in directory %JAVA_HOME%.
echo Please edit your script so that the JAVA_HOME variable
echo points to the location of your JDK.
goto finish
:runWebLogic
@rem the service loads dll file, so the JAVA_VM *must* be correct
if exist %JRE_HOME%\bin\client (
set JAVA_VM=-client
) else if exist %JRE_HOME%\bin\server (
set JAVA_VM=-server
) else if exist %JRE_HOME%\bin\jrockit (
set JAVA_VM=-jrockit
)
:noResetJavaVM
if not "%MEM_ARGS%" == "" goto noResetMemArgs
set MEM_ARGS=-Xms32m -Xmx200m
:noResetMemArgs
@echo on
set CLASSPATH=%WEBLOGIC_CLASSPATH%;%CLASSPATH%
@echo ***************************************************
@echo * To start WebLogic Server, use the password *
@echo * assigned to the system user. The system *
@echo * username and password must also be used to *
@echo * access the WebLogic Server console from a web *
@echo * browser. *
@echo ***************************************************
rem *** Set Command Line for service to execute within created JVM
@echo off
if "%ADMIN_URL%" == "" goto runAdmin
@echo on
set CMDLINE="%JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS% -classpath \"%CLASSPATH%\" -Dweblogic.Name=%SERVER_NAME% -Dweblogic.management.username=%WLS_USER% -Dweblogic.management.server=\"%ADMIN_URL%\" -Dweblogic.ProductionModeEnabled=%PRODUCTION_MODE% -Djava.security.policy=\"%WL_HOME%\server\lib\weblogic.policy\" weblogic.Server"
goto finish
:runAdmin
@echo on
set CMDLINE="%JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS% -classpath \"%CLASSPATH%\" -Dweblogic.Name=%SERVER_NAME% -Dweblogic.management.username=%WLS_USER% -Dweblogic.ProductionModeEnabled=%PRODUCTION_MODE% -Djava.security.policy=\"%WL_HOME%\server\lib\weblogic.policy\" weblogic.Server"
:finish
rem *** Set up extrapath for win32 and win64 platform separately
set WLSVC_EXE_TO_USE=wlsvcx64
if "%WL_USE_X86DLL%" == "true" (
set EXTRAPATH=%WL_HOME%\server\native\win\32;%WL_HOME%\server\bin;%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%WL_HOME%\server\native\win\32\oci920_8
set WLSVC_EXE_TO_USE=wlsvc
)
if "%WL_USE_IA64DLL%" == "true" (
set EXTRAPATH=%WL_HOME%\server\native\win\64\;%WL_HOME%\server\bin;%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%WL_HOME%\server\native\win\64\oci920_8
set WLSVC_EXE_TO_USE=wlsvc64
)
if "%WL_USE_AMD64DLL%" == "true" (
set EXTRAPATH=%WL_HOME%\server\native\win\x64\;%WL_HOME%\server\bin;%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%WL_HOME%\server\native\win\x64\oci920_8
set WLSVC_EXE_TO_USE=wlsvcx64
)
rem *** Install the service
"%WL_HOME%\server\bin\%WLSVC_EXE_TO_USE%" -install -svcname:"wlsvc %DOMAIN_NAME%_%SERVER_NAME%" -svcdescription:"%SERVICE_DESCRIPTION%" -javahome:"%JAVA_HOME%" -execdir:"%USERDOMAIN_HOME%" -maxconnectretries:"%MAX_CONNECT_RETRIES%" -host:"%HOST%" -port:"%PORT%" -extrapath:"%EXTRAPATH%" -password:"%WLS_PW%" -cmdline:%CMDLINE%
ENDLOCAL
uninstallSvc.cmd
@rem *************************************************************************
@rem This script is used to uninstall a WebLogic Server Windows Service.
@rem
@rem To create your own start script for your domain, simply set the
@rem SERVER_NAME variable to your server name then call this script from your
@rem domain directory.
@rem
@rem This script sets the following variables before uninstalling
@rem the Windows Service:
@rem
@rem WL_HOME - The root directory of your WebLogic installation
@rem
@rem For additional information, refer to "Managing Server Startup and Shutdown for Oracle WebLogic Server"
@rem (@DOCSWEBROOT/START/overview.htm).
@rem *************************************************************************
@echo off
SETLOCAL
@rem start_script
set MW_HOME=D:\weblogic\12.2.1.4
set DOMAIN_NAME=base_domain
set SERVER_NAME=AdminServer
@rem stop_script
set WL_HOME=%MW_HOME%\wlserver
rem *** Uninstall the service
"%WL_HOME%\server\bin\wlsvc" -remove -svcname:"wlsvc %DOMAIN_NAME%_%SERVER_NAME%"
ENDLOCAL
'WAS > WEBLOGIC' 카테고리의 다른 글
27. window 스크립트 (0) | 2024.05.08 |
---|---|
26. weblogic 윈도우 서비스 네트워크 드라이브 인식 오류 (0) | 2024.05.08 |
0. weblogic 개념 및 구성요소 (0) | 2024.05.07 |
24. 12c window 설치 및 구성(GUI) (0) | 2024.03.07 |
23. 12c 마이너 버전 도메인 업그레이드 (0) | 2024.03.07 |