使用Linux脚本更新Weblogic部署的应用程序

本文详细介绍了在WebLogic服务器上进行热部署的方法,包括使用控制台界面和shell脚本进行热部署的操作步骤,以及如何通过配置环境变量解决类加载问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

weblogic 部署项目时
如果没有使用weblogic 自动部署的功能
如未将 部署包 放在autodeploy 文件夹下,则在部署包 被替换后,需要热部署一下 用来更新缓存

界面操作热部署,就是直接登录控制台,更新应用即可

使用shell 脚本 更加方便

可以使用weblogic.jar包中的weblogic.Deployer这个class 。
命令如下:

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

1.t3://192.168.1.17001 是我管理服务(即AdminServer)的的IP地址和端口
2.weblogic 是我登录weblogic控制台的用户名
3.weblogic123是密码
4.session是部署的应用名称
5.sysmanm 是托管服务名,我的session应用就部署在这个服务上。

另在使用命令之前,可以shell脚本中加上weblogic的环境变量,否则可能报找不到CLASS的错误。

更新脚本如下:updateWeblogic.sh

##导入环境变量
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$WLS_HOME/server/lib/weblogic.jar
echo "running updateWeblogic.sh"
##获取当前服务器IP
currlocalIP=`ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d : -f2 | awk '{print $1}'`
##执行
java weblogic.Deployer -adminurl t3://${currlocalIP}:7001 -user weblogic -password weblogic123  -name testPro-targets AdminServer-redeploy

currlocalIP:当前服务器IP
weblogic —weblogic 用户名(登录控制台的用户名)
weblogic123 —weblogic 用户密码(登录控制台的用户密码)
testPro — 部署的应用名称
AdminServer – weblogic 的服务器名称(控制台–>环境—>服务器 就能看到)

sh updateWeblogic.sh
执行结果如下
weblogic.Deployer invoked with options: -adminurl t3://192.168.1.17001 -user weblogic -name session -targets sysmanm -redeploy<Nov 24, 2016 11:50:31 AM CST>
<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

异常情况:

  1. The domain edit lock … 编辑被锁定 ,登陆weblogic 控制台,查看当前使用的用户,是否点击“锁定并编辑” 了,只需点击释放配置即可
  2. 找到不到class 类 找不到weblogic.Deployer 需要配置CLASSPATH,使用 echo $CLASSPATH 查看
    a.在脚本中 CLASSPATH 加上 weblogic的环境变量(这个亲测可用)
    b.在etc/profile 里CLASSPATH (需要root 用户 )
    加上weblogic的环境变量~
    3.Could not find or load main class weblogic.Deployer
    在控制台
    echo $JAVA_HOME
    echo $WLS_HOME
    看这两个地址对不对,不对的话,可以直接使用绝对路径
    export CLASSPATH=.:/home/weblogic/java…/lib/dt.jar:/home/weblogic/Oracle/Middleware/wlserver_10_3/server/lib/weblogic.jar

附上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 <😕/:> [option] Administration
server URL: default t3://localhost:7001
-username [option] user name
-password [option] password for the user
-userconfigfile [option] The user config file
contains the user security credentials; it
is administered by the weblogic.Admin tool
-userkeyfile [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 [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 [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.~

https://www.cnblogs.com/wuyida/p/6300278.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值