关于 oracle:weblogic.Server 创建域但不启动它(厨师食谱)

weblogic.Server to create domain but don't start it (Chef cookbook)

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

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

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

我正在使用它来创建域:

1
2
3
4
$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 的步骤并尝试在输出末尾创建一个新域(使用上一个命令),则会看到:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<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 分钟后继续?


如果您只是不想启动它,一种解决方案是使用 weblogic 配置 GUI 创建域"模板",例如/opt/ora/mw/wlserver_10.3/common/bin/config.sh。一旦有了模板 jar 文件,就可以从 Chef 调用以下命令:

1
2
`/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`

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

一个快速/简单的解决服务器问题的方法是后台调用创建域并将其发送到日志文件。然后通过 bach 脚本监控日志以确保 RUNNING 状态成功退出,例如:

1
2
3
4
5
6
7
8
9
10
11
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 将循环 X 时间,将日志文件搜索为 RUNNING 状态,然后在达到时退出,如果达到时间限制,则退出 exit 1

编辑

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