weblogic.Server创建域但不启动它(Chef cookbook)

时间:2014-07-06 05:13:09

标签: oracle weblogic chef appserver

当我与Chef合作进行自动化时,我需要为weblogic创建一本食谱。问题是,当菜谱被执行时,它会在最后一步挂起,这是完全正常的,因为该步骤运行weblogic.Server Java Class来创建一个新域然后它运行服务器。所以,我想运行weblogic.Server只创建域并继续执行最后的步骤。有没有办法做到这一点?

我尝试使用参数weblogic.management.startupMode = SHUTDOWN,但它没有用。我知道所考虑的论点,因为在日志文件中执行tail -n 1000 | grep SHUTDOWN时,我看到:

ip-addres-root:~ # tail -n 1000 -f /opt/middleware/weblogic/mydomain/servers/myserver/logs/myserver.log | grep SHUTDOW
weblogic.management.startupMode = SHUTDOWN

我用这个来创建域名:

$JAVA_HOME/bin/java $JAVA_OPTIONS -Xmx1024m -Dweblogic.management.username=myuser \ 
-Dweblogic.management.password=mypassword1 \
-Dweblogic.management.GenerateDefaultConfig=true \
-Dweblogic.management.startupMode=SHUTDOWN weblogic.Server

如果我执行了运行weblogic的步骤,并且我尝试在输出结尾处创建一个新域(使用上一个命令),那么:

<06-jul-2014 04H35' UTC> <Notice> <Security> <BEA-090082> <Security initializing using security realm myrealm.> 
<06-jul-2014 04H35' UTC> <Warning> <Store> <BEA-280101> <The persistent file store "_WLS_myserver" is forced to use buffered I/O and so may have significantly degraded performance. Either the OS/hardware environment does not support the chosen write policy or the native wlfileio library is missing. See store open log messages for the requested and final write policies. See the documentation on store synchronous write policy configuration for advice.> 
<06-jul-2014 04H35' UTC> <Warning> <HTTP> <BEA-101296> <Unable to load the default compiler class "com.sun.tools.javac.Main". Using the default javac compiler to compile JSPs.> 
<06-jul-2014 04H35' UTC> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STANDBY> 
<06-jul-2014 04H35' UTC> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING> 
<06-jul-2014 04H35' UTC> <Notice> <Log Management> <BEA-170027> <The Server has established connection with the Domain level Diagnostic Service successfully.> 
<06-jul-2014 04H35' UTC> <Notice> <Server> <BEA-002613> <Channel "Default[2]" is now listening on 127.0.0.2:7001 for protocols iiop, t3, ldap, snmp, http.> 
<06-jul-2014 04H35' UTC> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 10.101.1.63:7001 for protocols iiop, t3, ldap, snmp, http.> 
<06-jul-2014 04H35' UTC> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on 127.0.0.1:7001 for protocols iiop, t3, ldap, snmp, http.> 
<06-jul-2014 04H35' UTC> <Notice> <WebLogicServer> <BEA-000331> <Started WebLogic Admin Server "myserver" for domain "mydomain" running in Development Mode> 
<06-jul-2014 04H35' UTC> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN> 
<06-jul-2014 04H35' UTC> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING> 
<06-jul-2014 04H35' UTC> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING> 
<06-jul-2014 04H35' UTC> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>

这让我觉得startupMode = SHUTDOWN被忽略了,因为它最后说<Server started in RUNNING mode>

有没有办法创建一个域名,但是不要启动它,或者告诉大厨,在我不知道的情况下继续前进,15分钟就可以了?

1 个答案:

答案 0 :(得分:3)

如果您只是不想启动它,一个解决方案就是创建一个域&#34;模板&#34;使用weblogic配置GUI,例如/opt/ora/mw/wlserver_10.3/common/bin/config.sh。获得模板jar文件后,可以从Chef调用以下内容:

`/opt/ora/mw/wlserver_10.3/common/bin/unpack.sh -template=<path to your template.jar>
-domain=<path to where you want to install the domain`

这将创建域但不启动服务器。

解决服务器出现问题的快速/简单解决方案是对创建域的调用进行后台处理并将其发送到日志文件。然后监视RUNNING状态的日志,通过bach脚本成功退出,如:

execute "start weblogic in #{weblogic_home}/WLSDomains/#{node[:som][:domain_name]}" do
  command "$JAVA_HOME/bin/java $JAVA_OPTIONS ... weblogic.Server > /tmp/start-weblogic.log 2>&1 &"
  action :run
end

execute "waitForRunning -- #{weblogic_bin}/waitForRunning.sh" do
    Chef::Log.debug("Waiting for WebLogic server to start")
    command "waitForRunning.sh"
    cwd "#{weblogic_bin}"
    action :run
end

其中waitForRunning.sh将循环播放RUNNING状态的日志文件的X时间,然后在到达时退出,或者如果达到时间限制则exit 1

修改


2>&1 &基本上是将标准错误重定向到stdout,并将它们都重定向到一个文件,因此该过程完全落后,这将导致Chef继续下一步。下一步,创建一个监视日志的脚本,你想做一个while循环,然后在满足条件时显式退出循环,然后Chef会知道步骤已经完成并继续前进。