weblogic 參數設置、創建soa_server1啓動文件

創建soa_server1服務的啓動文件:

進到DOMAIN_HOME=C:\Oracle\Middleware\WLS\wls10361180\user_projects\domains\hgbpm_domain1

copy startWebLogic.cmd文件,重命名問startBPM.cmd

編輯startBPM.cmd文件中的call "%DOMAIN_HOME%\bin\startWebLogic.cmd" %*內容爲:

call "%DOMAIN_HOME%\bin\startManagedWebLogic.cmd" soa_server1 %*

之後點擊startBPM.cmd文件即可啓動soa_server1 服務

在weblogic用戶環境變量中加入export WLS_STDOUT_LOG=web.stdout.log  、export WLS_STDERR_LOG=web.stderr.log兩條,將weblogic控制檯和部署工程的全部日誌信息打印輸出到web.stdout.log文件,隨着時間的增長web.stdout.log文件越來越大。如何能實現將輸出的日誌文件回滾,或按大小重新保存,比如容量到50M後,重新生成新的文件名進行保存?


默認weblogic中控制檯啓動之後會在命令行中標準輸出一些信息,在沒有使用log4j的情況下,想要獲取在控制檯輸出的信息需要進行一些設置

打開C:\bea\user_projects\domains\域名\startWebLogic.cmd文件

set DOMAIN_HOME=C:\bea\user_projects\domains\base_domain_second

call "%DOMAIN_HOME%\bin\startWebLogic.cmd" %*

 修改call這行爲如下代碼

call "%DOMAIN_HOME%\bin\startWebLogic.cmd" 1> stdout.log   2> stderr.log%*

也可以這樣寫

call "%DOMAIN_HOME%\bin\startWebLogic.cmd" 1> c:\stdout.log   2> c:\stderr.log%*

重啓服務,控制檯信息就被轉移到你指定的文件中了。希望對大家有所幫助。 

使用過程中發現重啓服務會出現日誌覆蓋的情況

解決思路如下:
在startWebLogic.cmd文件中增加時間相關的字符串,拼接成文件名,保證每次重啓的時候文件不會重名

具體代碼如下:
// 設置 yyyy_mm_dd 格式的日期
set sbtmpdate=%date:~0,4%_%date:~5,2%_%date:~8,2%
// 設置 HHmmss 格式的時間
set sbtmptime=%time:~0,2%%time:~3,2%%time:~6,2%
// 隨機數
set randomtmp=%random%
set r=%sbtmpdate%_%sbtmptime%.%randomtmp%

// 將變量賦值到文件名中
call "%DOMAIN_HOME%\bin\startWebLogic.cmd" 1>stdMsg-%r%.log 2>stdErr-%r%.log%*

 

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

weblogic啓動文件的說明

 

情況一:單獨的應用服務器(只有一個服務器,這個服務器就是 adminServer)
startWebLogic.sh內容如下:
#!/bin/sh
 
# WARNING: This file is created by the Configuration Wizard.
# Any changes to this script may be lost when adding extensions to this configuration.
 
# *************************************************************************
# This script is used to start WebLogic Server for the domain in the
# current working directory. This script simply sets the SERVER_NAME
# variable and starts server.

# To create your own start script for your domain, all you need to set is
# SERVER_NAME, then starts the server.

# Other variables that startWLS takes are:

# WLS_USER     - cleartext user for server startup
# WLS_PW       - cleartext password for server startup
# PRODUCTION_MODE    - true for production mode servers, false for
#                development mode
# JAVA_OPTIONS - Java command-line options for running the server. (These
#                will be tagged on to the end of the JAVA_VM and MEM_ARGS)
# JAVA_VM      - The java arg specifying the VM to run. (i.e. -server,
#                -hotspot, etc.)
# MEM_ARGS     - The variable to override the standard memory arguments
#                passed to java

# For additional information, refer to the WebLogic Server Administration
# Console Online Help(/ConsoleHelp/startstop.html)
# *************************************************************************
 
# Initialize the common environment.
 
WL_HOME="/neusoft/bea/weblogic81"
 
PRODUCTION_MODE=""
 
JAVA_VENDOR="IBM"
 
JAVA_HOME="/bea/IBMJava2-ppc64-142"
 
JAVA_OPTIONS="-Dibm.stream.nio=true"
 
#指定weblogic的最小內存和最大內存
MEM_ARGS="-Xms1248m -Xmx1248m"
 
# Call commEnv here AFTER setting the java_vendor to get common environmental settings.
 
. ${WL_HOME}/common/bin/commEnv.sh
 
# Set SERVER_NAME to the name of the server you wish to start up.
 
SERVER_NAME="myserver"
 
CLASSPATH="${WEBLOGIC_CLASSPATH}:${POINTBASE_CLASSPATH}:${JAVA_HOME}/jre/lib/rt.jar:${WL_HOME}/server/lib/webservices.jar:${CLASSPATH}"
export CLASSPATH
 
# Call WebLogic Server
 
echo "."
echo "CLASSPATH=${CLASSPATH}"
echo "."
echo "PATH=${PATH}"
echo "."
echo "***************************************************"
echo "* To start WebLogic Server, use a username and   *"
echo "* password assigned to an admin-level user. For *"
echo "* server administration, use the WebLogic Server *"
echo "* console at http://[hostname]:[port]/console    *"
echo "***************************************************"
 
${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} -Dweblogic.Name=${SERVER_NAME} -Dweblogic.ProductionModeEnabled=${PRODUCTION_MODE} -Djava.security.policy="${WL_HOME}/server/lib/weblogic.policy" weblogic.Server
 
 

這個啓動文件會直接在控制檯窗口輸出weblogic的控制檯信息,當你退出是也會關閉weblogic。如果你希望退出控制檯不退出weblogic,則你只需要修改此文件的最後一段。在之前加上nohup,並指定輸入的日誌文件。如:
 
 
 
 
……………………….
nohup ${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} -Dweblogic.Name=${SERVER_NAME} -Dweblogic.ProductionModeEnabled=${PRODUCTION_MODE} -Djava.security.policy="${WL_HOME}/server/lib/weblogic.policy" weblogic.Server >cdsbserver_1.log &

 
 
情況二:當你的應用部署在羣集中無中或在被管理服務器上。
startAppServer.sh的文件內容如下:
#!/bin/sh
# ****************************************************************************
# This script is used to start a managed WebLogic Server for the domain in the 
# current working directory. This script reads in the SERVER_NAME and 
# ADMIN_URL as positional parameters, sets the SERVER_NAME variable, then 
# starts the server.
#
# Other variables that startWLS takes are:
#
# WLS_USER       - cleartext user for server startup
# WLS_PW         - cleartext password for server startup
# PRODUCTION_MODE      - Set to true for production mode servers, false for 
#                  development mode
# JAVA_OPTIONS   - Java command-line options for running the server. (These
#                  will be tagged on to the end of the JAVA_VM and MEM_ARGS)
# JAVA_VM        - The java arg specifying the VM to run. (i.e. -server, 
#                  -hotspot, etc.)
# MEM_ARGS       - The variable to override the standard memory arguments
#                  passed to java
#
# For additional information, refer to the WebLogic Server Administration Guide
# (/ConsoleHelp/startstop.html).
# ****************************************************************************
 
 
# set up WL_HOME, the root directory of your WebLogic installation
WL_HOME="/bea/bea814/weblogic81"
 
# set up common environment
# Set Production Mode. When this is set to true, the server starts up in
# production mode. When set to false, the server starts up in development
# mode. If it is not set, it will default to false.
# 指定爲產品模式
PRODUCTION_MODE="true"
 
# Set JAVA_VENDOR to java virtual machine you want to run on server side.
JAVA_VENDOR="IBM"
 
# Set JAVA_HOME to java virtual machine you want to run on server side.
JAVA_HOME="/bea/IBMJava2-ppc64-142"
 
. "${WL_HOME}/common/bin/commEnv.sh"
 
# Set SERVER_NAME to the name of the server you wish to start up. 
# 指定管理服務器的地址和端口
ADMIN_URL=http://172.16.6.1:7001
# 指定被管理服務器的名稱
SERVER_NAME=appServer5
 
# Set WLS_USER equal to your system username and WLS_PW equal 
# to your system password for no username and password prompt 
# during server startup. Both are required to bypass the startup
# prompt.
# 指定weblogic管理員的用戶名和密碼
WLS_USER=weblogic
WLS_PW=weblogic
 
# Set JAVA_VM to java virtual machine you want to run on server side.
# JAVA_VM=""
 
# Set JAVA_OPTIONS to the java flags you want to pass to the vm. If there 
# are more than one, include quotes around them. For instance: 
# JAVA_OPTIONS="-Dweblogic.attribute=value -Djava.attribute=value"
# 使用IBM的JDK有可能會出現IO錯誤和編碼錯誤,這裏將nio設爲true
JAVA_OPTIONS="-Dibm.stream.nio=true"
 
usage()
{
 echo "Need to set SERVER_NAME and ADMIN_URL environment variables or specify"
 echo "them in command line:"
 echo 'Usage: ./startManagedWebLogic.sh [SERVER_NAME] [ADMIN_URL]'
 echo "for example:"
 echo './startManagedWebLogic.sh managedserver1 http://localhost:7001'
 exit 1
}
 
# Check for variables SERVER_NAME and ADMIN_URL
# SERVER_NAME and ADMIN_URL must by specified before starting a managed server,
# detailed information can be found at /adminguide/startstop.html.
if [ ${#} = 0 ]; then
 if [ "x${SERVER_NAME}" = "x" -o "x${ADMIN_URL}" = "x" ]; then
    usage
 fi
elif [ ${#} = 1 ]; then
 SERVER_NAME=${1}
 if [ "x${ADMIN_URL}" = "x" ]; then
    usage
 fi
elif [ ${#} = 2 ]; then
 SERVER_NAME=${1}
 ADMIN_URL=${2}
else
    usage
fi
 
# Start WebLogic server
# Reset number of open file descriptors in the current process
# This function is defined in commEnv.sh
resetFd
 
 
#指定當用weblogic的最小內存和最大內存
MEM_ARGS="-Xms1248m -Xmx1536m"
 
CLASSPATH="${WEBLOGIC_CLASSPATH}${CLASSPATHSEP}${POINTBASE_CLASSPATH}${CLASSPATHSEP}${JAVA_HOME}/jre/lib/rt.jar${CLASSPATHSEP}${WL_HOME}/server/lib/webservices.jar${CLASSPATHSEP}${CLASSPATH}"
export CLASSPATH
 
# Start WebLogic server
echo CLASSPATH="${CLASSPATH}"
echo
echo PATH="${PATH}"
echo
echo "***************************************************"
echo "* To start WebLogic Server, use a username and   *"
echo "* password assigned to an admin-level user. For *"
echo "* server administration, use the WebLogic Server *"
echo "* console at http://<hostname>:<port>/console    *"
echo "***************************************************"
 
nohup "$JAVA_HOME/bin/java" ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS}     /
 -Dweblogic.Name=${SERVER_NAME}                                 /
 -Dweblogic.management.username=${WLS_USER}                     /
 -Dweblogic.management.password=${WLS_PW}                       /
 -Dweblogic.management.server=${ADMIN_URL}                      /
 -Djava.security.policy="${WL_HOME}/server/lib/weblogic.policy" /
 -Djava.awt.headless=true -verbose:gc                                      /
   weblogic.Server >appServer5.log &

 
注意:MEM_ARGS="-Xms1248m -Xmx1536m"
對於32位操作系統最大不能超過2G,在實際中一般最大內存配置1.5G
 
說明:
可以設置-Xms(最小使用內存) -Xmx(最大使用內存),-XX:MaxPermSize
最大使用內存:
對於UNIX而言,一般不應超過物理內存的75%;
對於Windows, 一般不應超過物理內存的50%;
 
-XX:MaxPermSize 一般應爲mx(最大使用內存)的一半;嘗試設置-XX:MaxPermSize=128m
注意:對於IBM的虛擬機沒有MaxPermSize設置,不然系統不能啓動


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章