设为首页 收藏本站
查看: 466|回复: 0

[经验分享] WebLogic 11g start and stop automation

[复制链接]

尚未签到

发表于 2017-2-16 06:10:41 | 显示全部楼层 |阅读模式

WebLogic 11g start and stop automation

There are many ways of starting and stopping your Oracle WebLogic 11g ? environments, You can stop your Admin and Managed Server Instances through the Adminsitration console, use the the start and stop scripts shipped with the Oracle WebLogic software and domaincreation, or use a tool like WLST to manipulate your entire environment.

In this blog I will ? use the different kinds of techniques to stop and start your Oracle WebLogic Server environment, even in case of a physical host reboot (planned or unplanned)

For this I used the common UNIX shell scripting in combination with WLST

The bundle consists of the following components:

weblogic_rc.sh start|stop|status –> Overall shellscript which calls the different scripts for stopping and starting. This can be added to the bootsequence of the physical host, which varies per O/S ( Linux-init.d, AIX- rc) Ask you O/S admin how to implementit). Your OS profile needs to be set as well, so set some variables like MW_HOME. WL_DOMAIN and WL_DOMAIN_DIR, and ORACLE_HOME
nodemgrstart and nodemgrstop –> python/WLST scripts for starting the Node Manager. Can be invoked with or without the overall script. First set the setWLSEnv.sh or the setDomainEnv.sh to issue the correct environmentsettings. Execute:

java weblogic.WLST nodemanagerstart / nodemanagerstop

wl11gstart and wl11gstop > python/WLST scripts for starting the WebLogic Server Instances. Can be invoked with or without the overall script. First set the setWLSEnv.sh or the setDomainEnv.sh to issue the correct environmentsettings. Execute:

java weblogic.WLST wl11gstart / wl11gstop

See the scripts below:

weblogic_rc.sh:

#!/bin/sh
#
# Start and stop script for an entire Oracle FMW Forms 11g environment
# Tobe added to the rebootsequence of the AIX LPAR.
#
#

#
#
PWD=`pwd`
if [ "$USER" != 'root' -a "$USER" != 'orawl' -a "$USER" != '' ]; then echo $BAD_USER && exit 1;fi
if [ "$USER" == 'root' -o "$USER" == '' ]; then WL_DOMAIN_DIR=`su - orawl -c 'echo $WL_DOMAIN_DIR'`;fi
if [ "$USER" == 'root' -o "$USER" == '' ]; then WL_NM_PORT=`su - orawl -c 'echo $WL_NM_PORT'`;fi
if [ "$USER" == 'root' -o "$USER" == '' ]; then WL_HOME=`su - orawl -c 'echo $WL_HOME'`;fi
. ~/.profile
case "$1" in
start)
echo Starting the Nodemanager
java weblogic.WLST $PWD/nodemgrstart
sleep 20
echo ? Starting AdminServer on WebLogic Domain $DOMAIN
nohup $WL_DOMAIN_DIR/startWebLogic.sh & > /dev/null 2>&1 &
sleep 120
#
echo Starting the the Managed Server Instances on WebLogic Domain $DOMAIN
java weblogic.WLST $PWD/wl11gstart
;;
stop)
echo WebLogic Server instances
java weblogic.WLST $PWD/wl11gstop
sleep 60
echo ? Stopping AdminServer on WebLogic Domain $DOMAIN
$WL_DOMAIN_DIR/bin/stopWebLogic.sh
echo Stopping the Nodemanager
java weblogic.WLST $PWD/nodemgrstop
;;
status)
echo checking runtime status
java weblogic.WLST $PWD/chkwlsrvr
;;
* )
echo "Usage: $0 (start | stop | status)"
exit 1
esac

nodemanager start

#### Created by Michel Schildmeijer
# Credentials and constants
username = 'weblogic'
password = '<passwd>'
import socket
localhost = socket.getaddrinfo(socket.gethostname(), None)[0][4][0]
import os
domain = os.getenv('WL_DOMAIN')
mwHome = os.getenv('MW_HOME')
print mwHome
#
# Derived constants
url = 't3://' + localhost + ':7001'
domain_dir = mwHome + '/user_projects/domains/' + domain
nmhome = mwHome + '/wlserver_10.3/common/nodemanager'
nmpfile = mwHome + '/wlserver_10.3/common/nodemanager/nodemanager.properties'
nmPort='5556'
# Loop through the managed servers and stop all servers running on localhost
print '-- CONNECT TO NODE MANAGER AND START IT --';
nmConnect(username, password, localhost, nmPort, domain, domain_dir)
#Start the nodemanager
startNodeManager(NodeManagerHome=nmhome,PropertiesFile=nmpfile)

nodemanager stop

<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;"><span style="line-height: 19px;">
</span></span>#### Created by Michel Schildmeijer
# Function to get server state
def serverStatus(server):
cd('/ServerLifeCycleRuntimes/' + server.getName() )
return cmo.getState()
#
def stopAdminserver():
nmConnect(username, password, 'localhost', 5556, domain, domain_dir)
nmStop('AdminServer')
nmDisconnect()
# End of functions
# Credentials and constants
username = 'weblogic'
password = '&lt;passwd&gt;'
import socket
localhost = socket.getaddrinfo(socket.gethostname(), None)[0][4][0]
import os
domain = os.getenv('WL_DOMAIN')
mwHome = os.getenv('MW_HOME')
print mwHome
#
# Derived constants
url = 't3://' + localhost + ':7001'
domain_dir = mwHome + '/user_projects/domains/' + domain
nmhome = mwHome + '/wlserver_10.3/common/nodemanager'
nmpfile = mwHome + '/wlserver_10.3/common/nodemanager/nodemanager.properties'
nmPort='5556'
# Loop through the managed servers and stop all servers running on localhost
print '-- CONNECT TO NODE MANAGER AND STOP IT --';
nmConnect(username, password, localhost, nmPort, domain, domain_dir)
#stop the nodemanager if running
stopNodeManager()

wl11gstart

#### Generic Oracle WebLogic 11g Start Script
#### Created by Michel Schildmeijer
# Credentials and constants
username='weblogic'
password='&lt;passwd&gt;'
import socket
localhost = socket.getaddrinfo(socket.gethostname(), None)[0][4][0]
import os
domain = os.getenv('WL_DOMAIN')
domaindir= os.getenv('WL_DOMAIN_DIR')
mwHome = os.getenv('MW_HOME')
url = 't3://' + localhost + ':7001'
domain_dir = mwHome + '/user_projects/domains/' + domain
nmhome = mwHome + '/wlserver_10.3/common/nodemanager'
nmpfile = mwHome + '/wlserver_10.3/common/nodemanager/nodemanager.properties'
# Function to get server state
def serverStatus(server):
cd('/ServerLifeCycleRuntimes/' + server.getName() )
return cmo.getState()
#
def startAdminserver():
nmConnect(username, password, localhost, 5556, domain, domain_dir)
nmStart('AdminServer')
nmDisconnect()
# End of functions
# Connect to the AdminServer
try:
connect(username, password, url)
except:
# AdminServer is not running. Start it now and retry
startAdminserver()
connect(username, password, url)
# Loop through the managed servers and start all servers running on localhost
svrs = cmo.getServers()
domainRuntime()
for server in svrs:
# Do not start the adminserver, it's already running
if server.getName() != 'AdminServer':
# Get state and machine
serverState = serverStatus(server)
machine = server.getListenAddress()
print server.getName() + " has now the status " + serverState + " on " + machine
#
# startup if needed
if serverState == "SHUTDOWN":
if machine == localhost:
start(server.getName(),'Server')
serverState = serverStatus(server)
print "Now " + server.getName() + " is " + serverState + " on " + machine
disconnect()
exit()

wl11gstop

#### Created by Michel Schildmeijer

# Function to get server state

def serverStatus(server):

cd('/ServerLifeCycleRuntimes/' + server.getName() )
return cmo.getState()
#
def stopAdminserver():
nmConnect(username, password, 'localhost', 5556, domain, domain_dir)
nmStop('AdminServer')
nmDisconnect()
# End of functions
#

# credentials and constants

username = 'weblogic'
password = '&lt;passwd&gt;'
import socket
localhost = socket.getaddrinfo(socket.gethostname(), None)[0][4][0]
import os
domain = os.getenv('WL_DOMAIN')
mwHome = os.getenv('MW_HOME')
print mwHome

#

# Derived constants
url = 't3://' + localhost + ':7001'
domain_dir = mwHome + '/user_projects/domains/' + domain
nmhome = mwHome + '/wlserver_10.3/common/nodemanager'
nmpfile = mwHome + '/wlserver_10.3/common/nodemanager/nodemanager.properties'
nmPort='5556'

## Connect to the AdminServer

try:
connect(username, password,url)
except:
# AdminServer is not running. Start it now and retry
#stopAdminserver()
connect(username, password,url)
# Loop through the managed servers and stop all servers running on localhost
print '-- CONNECT TO NODE MANAGER AND ADMINSERVER --';
nmConnect(username, password, localhost, nmPort, domain, domain_dir)
domainRuntime()
serverLifeCycles = cmo.getServerLifeCycleRuntimes()
for serverLifeCycle in serverLifeCycles:
if (serverLifeCycle.getState() == 'RUNNING') and (serverLifeCycle.getName() != 'AdminServer' ):
print 'Stopping Server: ' + serverLifeCycle.getName()
shutdown(serverLifeCycle.getName())

disconnect()

exit()

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-342637-1-1.html 上篇帖子: 部署 web 项目到weblogic时的错误二 下篇帖子: 解决一个weblogic的jar包冲突问题
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表