问题
As i'm working with Chef for automation, i'm required to create a cookbook for weblogic. The thing is that, when the cookbook is executed it hangs at the final step, and that's totally normal since that step runs weblogic.Server Java Class to create a new domain and then it runs the server. So, i want to run weblogic.Server to only create the domain and keep going with the last steps. Is there a way to do that?
I have tried with the argument weblogic.management.startupMode = SHUTDOWN
but it doesn't work. I know the argument where considered, since when do a tail -n 1000 | grep SHUTDOWN
in the log file, i see:
ip-addres-root:~ # tail -n 1000 -f /opt/middleware/weblogic/mydomain/servers/myserver/logs/myserver.log | grep SHUTDOW
weblogic.management.startupMode = SHUTDOWN
I'm using this to create the domain:
$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
If i do the steps to run weblogic and i try to create a new domain (with the previous command) at the end of the output it's seen:
<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>
Which makes me think the startupMode=SHUTDOWN is ignored since it says at the end <Server started in RUNNING mode>
Is there a way to create a domain but don't start it, or to tell chef, to keep going after i don't know, 15 minutes wating?
回答1:
If you simply don't want to start it, one solution is to create a domain "template" with the weblogic config GUI, e.g. /opt/ora/mw/wlserver_10.3/common/bin/config.sh. Once you have a template jar file, you can call the following from 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`
This will create the domain but not start the server.
A quick/easy solution to the problem of the server coming up would be to background the call to create the domain and send it to a log file. Then to monitor the log for the RUNNING state to exit successfully via a bach script like:
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
Where waitForRunning.sh
will loop for X amount of time grepping your log file for the RUNNING state and then exit when it was reached or exit 1
if the time limit is reached.
Edit
2>&1 &
is basically redirect standard error to stdout and both of them to a file so the process is completely backgrounded, this will cause Chef to move on to the next step. The next step, creating a script to monitor the log, you want to do a while loop and then explicitly exit out of the loop when a condition has been met, then Chef will know that step is done and move on as well.
来源:https://stackoverflow.com/questions/24592913/weblogic-server-to-create-domain-but-dont-start-it-chef-cookbook