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
异常情况:
- The domain edit lock … 编辑被锁定 ,登陆weblogic 控制台,查看当前使用的用户,是否点击“锁定并编辑” 了,只需点击释放配置即可
- 找到不到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