使用Linux腳本更新Weblogic部署的應用程序


在利用Jenkins實現Weblogic應用自動部署的功能時,如何通過Shell 腳本自動更新Weblogic部署的應用程序呢?

可以使用weblogic.jar包中的weblogic.Deployer這個class 。

命令如下:

java weblogic.Deployer -adminurl t3://192.168.142.136:47001 -user weblogic -password weblogic123  -name session -targets sysmanm  -redeploy

其中t3://192.168.142.136:7001 是我管理服務(即AdminServer)的的IP地址和端口,weblogic 是我登錄weblogic控制台的用戶名,weblogic123是密碼 , session是部署的應用名稱,sysmanm 是托管服務名,我的session應用就部署在這個服務上。

另在使用命令之前,可以shell腳本中加上weblogic的環境變量,否則可能報找不到CLASS的錯誤。

完成的sysmanm_redeploy.sh腳本如下:

export CLASSPATH=/usr/java/1.8.0_111/lib/tools.jar:/home/hadoop/Oracle/Middleware/Oracle_Home/wlserver/server/lib/weblogic_sp.jar:/home/hadoop/Oracle/Middleware/Oracle_Home/wlserver/server/lib/weblogic.jar:/home/hadoop/Oracle/Middleware/Oracle_Home/wlserver/server/lib/webservices.jar:/home/hadoop/Oracle/Middleware/Oracle_Home/wlserver/../oracle_common/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/home/hadoop/Oracle/Middleware/Oracle_Home/wlserver/../oracle_common/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar:/home/hadoop/Oracle/Middleware/Oracle_Home/wlserver/modules/features/oracle.wls.common.nodemanager_1.0.0.0.jar:.:/usr/java/1.8.0_111/lib/dt.jar:/usr/java/1.8.0_111/lib/tools.jar
#java weblogic.WLST testWeblogicStart.py $1 $2 $3 $4 $5
java weblogic.Deployer -adminurl t3://192.168.142.136:7001 -user weblogic -password weblogic123  -name session -targets sysmanm  -redeploy

使用sh sysmanm_redeploy.sh執行腳本

[hadoop@localhost shell]$ sh sysmanm_redeploy.sh 
weblogic.Deployer invoked with options:  -adminurl t3://192.168.142.136:7001 -user weblogic -name session -targets sysmanm -redeploy
<Nov 24, 2016 11:50:31 AM CST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating redeploy operation for application, session [archive: null], to sysmanm .> 
Task 4 initiated: [Deployer:149026]redeploy application session on sysmanm.
Task 4 completed: [Deployer:149026]redeploy application session on sysmanm.
Target state: redeploy completed on Server sysmanm

如下是我本地weblogic服務的簡單配置,大家可以參考:




附上weblogic.Deployer的幫助信息,如下:

Usage: java weblogic.Deployer [options] [action] [Deployment units(s)]
where options include:
-help Print the standard usage message.
-version Print version information.
-adminurl <<protocol>://<server>:<port>> [option] Administration
server URL: default t3://localhost:7001
-username <username> [option] user name
-password <password> [option] password for the user
-userconfigfile <userconfigfile> [option] The user config file
contains the user security credentials; it
is administered by the weblogic.Admin tool
-userkeyfile <keyConfigFile> [option] The users key file; it is
administered by the weblogic.Admin tool.
-distribute [action] Distribute application to the
targets.
-start [action] Makes an already distributed
application available on a target.
-stop [action] Makes an application unavailable on
targets.
-redeploy [action] Replace a running application
partially or entirely.
-undeploy [action] Take an application out of service.
-deploy [action] Make an application available for
service.
-update [action] Update an application configuration
in place.
-examples [option] Displays example usage of this tool.
-name <application name> [option] Defaults to the basename of the
deployment file or directory.
-targets <<target(s)>> [option] A comma separated list of targets
for the current operation. If not specified,
all configured targets are used. For a new
application, the default target is the
administration server.
-plan <Deployment plan path> [option] Specifies location of
deployment plan
-library [option] Indicates that the unit being
deployed is a library. This option is
required when the application is a library.
-advanced Print advanced usage options.

The optional trailing arguments are deployment units and may
represent the archive being deployed, the name of a previously
deployed application or a list of files for a partial redeploy operation.

更多信息請參考:http://docs.oracle.com/middleware/1213/wls/wls-developdeploy.htm




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM