Uno script per lo start e stop dei componenti di Enterprise Manager Grid Control R1 su Linux x86_64
Pubblicato Novembre 2011
L'articolo si compone delle seguenti parti
- Lo script oraemgrid
- Avvio automatico allo startup della macchina
- Test di alcune funzionalità
- Conclusioni
Lo script oraemgrid
Come utente root nella directory /etc/init.d ho creato il seguente script che ho chiamato oraemgrid. Per facilitarne la lettura ho evidenziato i commenti, le funzioni e il file di log.#! /bin/sh
#
# oraemgrid Start/Stop of Enterprise Manager Grid Control component
#
# chkconfig: 345 80 70
# description: start e stop of all Enterprise Manager Grid Control component
# listener, repository, OMS e Agent
# processname: oraemgrid
# author: Andrea Trabucco (http://it.linkedin.com/in/andreatrabucco)
# include of functions
. /etc/init.d/functions
prog="oraemgrid"
parse_oratab()
{
# Parse oratab lines to identify component variables
echo -n "Parse ${ORATAB} file"
while read LINE
do
case ${LINE} in
\#*) ;; #comment-line in oratab
*)
DB=`echo ${LINE} | cut -d":" -f1`
if [ "${DB}" = '*' ] ; then
# lines with * are not related to repository
OMS=`echo ${LINE} | grep ${OMS_COMPONENT}`
AGENT=`echo ${LINE} | grep ${AGENT_COMPONENT}`
if [ -n "${OMS}" ]
then
ORACLE_OMS_HOME=`echo $LINE | cut -d":" -f2`
ORACLE_OMS_TOBESTARTED=`echo $LINE | cut -d":" -f3`
else
if [ -n "${AGENT}" ]
then
ORACLE_AGENT_HOME=`echo $LINE | cut -d":" -f2`
ORACLE_AGENT_TOBESTARTED=`echo $LINE | cut -d":" -f3`
else
# Add just for security reasons: if oratab is well -formed
# this command will never be executed
continue
fi
fi
else
ORACLE_DB_SID=`echo ${LINE} | cut -d":" -f1`
ORACLE_DB_HOME=`echo $LINE | cut -d":" -f2`
ORACLE_DB_TOBESTARTED=`echo $LINE | cut -d":" -f3`
fi
;;
esac
done < ${ORATAB}
echo_passed
echo
return 0
}
startdb()
{
echo -n "Starting database and listener"
if [ "${ORACLE_DB_TOBESTARTED}" = "Y" ]
then
su - ${ORACLE_OWNER} -c "${ORACLE_DB_HOME}/bin/dbstart ${ORACLE_DB_HOME}" >> ${LOGFILE} 2>&1
status=$?
if [ ${status} -eq 0 ]
then
echo_success
else
echo_failure
fi
else
status=1
echo_failure
echo
echo -n "Could not start EM repository due to oratab configuration."
echo_failure
fi
echo
return ${status}
}
startoms()
{
echo -n "Starting Oracle Management Server"
if [ "${ORACLE_OMS_TOBESTARTED}" = "Y" ]
then
su - ${ORACLE_OWNER} -c "${ORACLE_OMS_HOME}/bin/emctl start oms" >> ${LOGFILE} 2>&1
status=$?
if [ ${status} -eq 0 ]
then
echo_success
else
echo_failure
fi
else
status=1
echo_failure
echo
echo -n "Could not start Oracle Management Server due to oratab configuration."
echo_failure
fi
echo
return ${status}
}
startagent()
{
echo -n "Starting Oracle Agent"
if [ "${ORACLE_AGENT_TOBESTARTED}" = "Y" ]
then
su - ${ORACLE_OWNER} -c "${ORACLE_AGENT_HOME}/bin/emctl start agent" >> ${LOGFILE} 2>&1
status=$?
if [ ${status} -eq 0 ]
then
echo_success
else
echo_failure
fi
else
status=1
echo_failure
echo
echo -n "Could not start Oracle Agent due to oratab configuration."
echo_failure
fi
echo
return ${status}
}
stopdb()
{
echo -n "Stopping database and listener"
su - ${ORACLE_OWNER} -c "${ORACLE_DB_HOME}/bin/dbshut ${ORACLE_DB_HOME}" >> ${LOGFILE} 2>&1
status=$?
if [ ${status} -eq 0 ]
then
echo_success
else
echo_failure
fi
echo
return ${status}
}
stopoms()
{
echo -n "Stopping Oracle Management Server"
su - ${ORACLE_OWNER} -c "${ORACLE_OMS_HOME}/bin/emctl stop oms -all" >> ${LOGFILE} 2>&1
status=$?
if [ ${status} -eq 0 ]
then
echo_success
else
echo_failure
fi
echo
return ${status}
}
stopagent()
{
echo -n "Stopping Oracle Agent"
su - ${ORACLE_OWNER} -c "${ORACLE_AGENT_HOME}/bin/emctl stop agent" >> ${LOGFILE} 2>&1
status=$?
if [ ${status} -eq 0 ]
then
echo_success
else
echo_failure
fi
echo
return ${status}
}
start()
{
startdb
status=$?
# In case of error it's useless starting other components
if [ ${status} -eq 0 ]
then
startoms
status=$?
# In case of error it's useless starting other components
if [ ${status} -eq 0 ]
then
startagent
status=$?
fi
fi
if [ ${status} -ne 0 ]
then
echo -n "Starting $prog "
echo_failure
echo
fi
return ${status}
}
stop()
{
stopagent
status=`expr ${status} + $?`
stopoms
status=`expr ${status} + $?`
stopdb
status=`expr ${status} + $?`
if [ ${status} -ne 0 ]
then
echo -n "Stopping $prog "
echo_failure
echo
fi
}
rhstatusdb()
{
echo "################################################"
echo "# LISTENER STATUS #"
echo "################################################"
su - ${ORACLE_OWNER} -c "${ORACLE_DB_HOME}/bin/lsnrctl status"
echo
echo
echo "################################################"
echo "# REPOSITORY STATUS #"
echo "################################################"
su - ${ORACLE_OWNER} -c "${ORACLE_DB_HOME}/bin/sqlplus -S / as sysdba << EOF
set head off
select 'Instance: '||instance_name || ' - '|| VERSION || ' - Status: ' ||status||' - Archiver: ' || archiver FROM v\\\$instance;
exit
EOF"
echo
echo
}
rhstatusoms()
{
echo "################################################"
echo "# OMS STATUS #"
echo "################################################"
export ORACLE_HOME="${ORACLE_OMS_HOME}"
su - ${ORACLE_OWNER} -c "${ORACLE_OMS_HOME}/bin/emctl status oms"
echo
echo
}
rhstatusagent()
{
echo "################################################"
echo "# AGENT STATUS #"
echo "################################################"
export ORACLE_HOME="${ORACLE_AGENT_HOME}"
su - ${ORACLE_OWNER} -c "${ORACLE_AGENT_HOME}/bin/emctl status agent"
echo
echo
}
rhstatus()
{
rhstatusdb
rhstatusoms
rhstatusagent
}
restart()
{
stop
sleep 5
start
}
restartdb()
{
stopdb
sleep 5
startdb
}
restartoms()
{
stopoms
sleep 5
startoms
}
restartagent()
{
stopagent
sleep 5
startagent
}
ORACLE_OWNER=oracle
HOME=`cat /etc/passwd | grep ${ORACLE_OWNER} | cut -d":" -f6`
MYDATE=`date +%d/%m/%y-%H:%M:%S`
LOGFILE=${HOME}/startup.log
echo "${MYDATE} --> Manage Enterprise Manager Grid Control: received commmand is ($1)" >> ${LOGFILE}
OMS_COMPONENT="oms11g"
AGENT_COMPONENT="agent11g"
# oratab file MUST be correctly configured
ORATAB=/etc/oratab
if [ ! -f ${ORATAB} ]
then
echo -n "${ORATAB} not found"
failure "${ORATAB} not found"
echo
echo "${ORATAB} not found" >> ${LOGFILE}
exit 1;
fi
parse_oratab
status=$?
if [ ${status} -eq 0 ]
then
case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
restart)
restart
RETVAL=$?
;;
status)
rhstatus
RETVAL=$?
;;
startdb)
startdb
RETVAL=$?
;;
stopdb)
stopdb
RETVAL=$?
;;
restartdb)
restartdb
RETVAL=$?
;;
statusdb)
rhstatusdb
RETVAL=$?
;;
startoms)
startoms
RETVAL=$?
;;
stopoms)
stopoms
RETVAL=$?
;;
restartoms)
restartoms
RETVAL=$?
;;
statusoms)
rhstatusoms
RETVAL=$?
;;
startagent)
startagent
RETVAL=$?
;;
stopagent)
stopagent
RETVAL=$?
;;
restartagent)
restartagent
RETVAL=$?
;;
statusagent)
rhstatusagent
RETVAL=$?
;;
*)
echo
echo $"Usage for ALL components
$0 { start | stop | status | restart }
Usage for database only
$0 { startdb | stopdb | statusdb | restartdb }
Usage for OMS only
$0 { startoms | stopoms | statusoms | restartoms }
Usage for Agent only
$0 { startagent | stopagent | statusagent | restartagent}"
echo
exit 1
esac
fi
echo "${MYDATE} --> End of $0" >> ${LOGFILE}
exit ${RETVAL}
Lo script è un classico script di avvio di un servizio sotto Linux, personalizzato per la gestione dei componenti del Grid Control.
Avvio automatico allo startup della macchina
Vediamo ora come rendere automatico l'avvio dello script. Per prima cosa controllo che il file creato abbia i diritti di esecuzione:[root@barracuda ~]# ls -alpt /etc/init.d/oraemgrid
-rwxr-xr-x 1 root root 6210 Oct 19 15:12 /etc/init.d/oraemgrid
Nel nostro caso i diritti sono ok. Adesso aggiungiamo il servizio
[root@barracuda ~]# chkconfig --add oraemgrid
[root@barracuda ~]# chkconfig --list | grep ora
oraemgrid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
[root@barracuda ~]#
Vista la direttiva per il
chkconfig messa all'inizio dello script, il servizio è configurato per l'avvio in automatico per i livelli 3, 4 e 5. Al momento dell'avvio della macchina, il parametro di default che viene passato è start.Test di alcune funzionalità
I parametri che ho inserito e con cui potete chiamare lo script sono:| Parametro |
Uso |
start |
Avvio di tutti i componenti: listener, database, OMS e agent. |
stop |
Stop di tutti i componenti: listener, database, OMS e agent. |
status |
Status di tutti i componenti: listener, database, OMS e agent. |
restart |
Stop di tutti i componenti e successivo avvio di tutti i componenti. |
startdb |
Avvio di listener e database del grid control. |
stopdb |
Stop di listener e database del grid control. |
statusdb |
Status di listener e database del grid control. |
restartdb |
Stop di listener e database e successivo avvio di listener e database. |
startoms |
Avvio dell'OMS. |
stopoms |
Stop dell'OMS. |
statusoms |
Status dell'OMS. |
restartoms |
Stop dell'OMS e suo successivo avvio. |
startagent |
Avvio dell'agent. |
stopagent |
Stop dell'agent. |
statusagent |
Status dell'agent. |
restartagent |
Stop dell'agent e suo successivo avvio. |
Potete leggere come si usa lo script lanciandolo senza parametri
[root@barracuda ~]# service oraemgrid
Parse /etc/oratab file [PASSED]
Usage for ALL components
/etc/init.d/oraemgrid { start | stop | status | restart }
Usage for database only
/etc/init.d/oraemgrid { startdb | stopdb | statusdb | restartdb }
Usage for OMS only
/etc/init.d/oraemgrid { startoms | stopoms | statusoms | restartoms }
Usage for Agent only
/etc/init.d/oraemgrid { startagent | stopagent | statusagent | restartagent}
[root@barracuda ~]#
Proviamo a lanciarlo con vari parametri e vediamo cosa ci risponde.
status
Il nostro Grid Control al momento è attivo, quindi iniziamo a testare lostatus[root@barracuda ~]# service oraemgrid status
Parse /etc/oratab file [PASSED]
################################################
# LISTENER STATUS #
################################################
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 26-OCT-2011 18:21:43
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 19-OCT-2011 16:18:31
Uptime 7 days 2 hr. 3 min. 13 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/barracuda/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=barracuda)(PORT=1521)))
Services Summary...
Service "emgcdb.barracuda" has 1 instance(s).
Instance "emgcdb", status READY, has 1 handler(s) for this service...
Service "emgcdbXDB.barracuda" has 1 instance(s).
Instance "emgcdb", status READY, has 1 handler(s) for this service...
The command completed successfully
################################################
# REPOSITORY STATUS #
################################################
Instance: emgcdb - 11.2.0.2.0 - Status: OPEN - Archiver: STOPPED
################################################
# OMS STATUS #
################################################
Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
WebTier is Up
Oracle Management Server is Up
################################################
# AGENT STATUS #
################################################
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
---------------------------------------------------------------
Agent Version : 11.1.0.1.0
OMS Version : 11.1.0.1.0
Protocol Version : 11.1.0.0.0
Agent Home : /u01/app/oracle/Middleware/agent11g
Agent binaries : /u01/app/oracle/Middleware/agent11g
Agent Process ID : 3939
Parent Process ID : 3919
Agent URL : https://barracuda:3872/emd/main/
Repository URL : https://barracuda:4900/em/upload
Started at : 2011-10-19 16:22:08
Started by user : oracle
Last Reload : 2011-10-19 16:22:24
Last successful upload : 2011-10-26 18:18:21
Total Megabytes of XML files uploaded so far : 824.23
Number of XML files pending upload : 0
Size of XML files pending upload(MB) : 0.00
Available disk space on upload filesystem : 87.58%
Last successful heartbeat to OMS : 2011-10-26 18:21:00
---------------------------------------------------------------
Agent is Running and Ready
[root@barracuda ~]#
stop
Fermiamo adesso tutti i componenti[root@barracuda ~]# service oraemgrid stop
Parse /etc/oratab file [PASSED]
Stopping Oracle Agent [ OK ]
Stopping Oracle Management Server [ OK ]
Stopping database and listener [ OK ]
[root@barracuda ~]#
Ed eseguiamo di nuovo lo
status per vedere cosa ci risponde lo script:[root@barracuda ~]# service oraemgrid status
Parse /etc/oratab file [PASSED]
################################################
# LISTENER STATUS #
################################################
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 26-OCT-2011 18:36:02
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 2: No such file or directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=barracuda)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
################################################
# REPOSITORY STATUS #
################################################
select 'Instance: '||instance_name || ' - '|| VERSION || ' - Status: ' ||status||' - Archiver: ' || archiver FROM v$instance
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
################################################
# OMS STATUS #
################################################
Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
WebTier is Down
Oracle Management Server is Down
################################################
# AGENT STATUS #
################################################
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
---------------------------------------------------------------
Agent is Not Running
[root@barracuda ~]#
Come vedete i componenti sono tutti spenti.
start
Se tutti i componenti sono spenti, allora possiamo provare a riattivarli (impiegheranno un po' di tempo a seconda della potenza del server su cui avete installato il Grid Control):[root@barracuda ~]# service oraemgrid start
Parse /etc/oratab file [PASSED]
Starting database and listener [ OK ]
Starting Oracle Management Server [ OK ]
Starting Oracle Agent [ OK ]
[root@barracuda ~]#
E potete facilmente controllare che tutti i componenti sono stati avviati con successo eseguendo di nuovo lo
status
[root@barracuda ~]# service oraemgrid status
Parse /etc/oratab file [PASSED]
################################################
# LISTENER STATUS #
################################################
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 26-OCT-2011 18:39:37
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 26-OCT-2011 18:37:53
Uptime 0 days 0 hr. 1 min. 44 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/barracuda/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=barracuda)(PORT=1521)))
Services Summary...
Service "emgcdb.barracuda" has 1 instance(s).
Instance "emgcdb", status READY, has 1 handler(s) for this service...
Service "emgcdbXDB.barracuda" has 1 instance(s).
Instance "emgcdb", status READY, has 1 handler(s) for this service...
The command completed successfully
################################################
# REPOSITORY STATUS #
################################################
Instance: emgcdb - 11.2.0.2.0 - Status: OPEN - Archiver: STOPPED
################################################
# OMS STATUS #
################################################
Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
WebTier is Up
Oracle Management Server is Up
################################################
# AGENT STATUS #
################################################
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
---------------------------------------------------------------
Agent Version : 11.1.0.1.0
OMS Version : 11.1.0.1.0
Protocol Version : 11.1.0.0.0
Agent Home : /u01/app/oracle/Middleware/agent11g
Agent binaries : /u01/app/oracle/Middleware/agent11g
Agent Process ID : 30005
Parent Process ID : 29985
Agent URL : https://barracuda:3872/emd/main/
Repository URL : https://barracuda:4900/em/upload
Started at : 2011-10-26 18:38:17
Started by user : oracle
Last Reload : 2011-10-26 18:38:17
Last successful upload : 2011-10-26 18:39:40
Total Megabytes of XML files uploaded so far : 0.09
Number of XML files pending upload : 11
Size of XML files pending upload(MB) : 2.45
Available disk space on upload filesystem : 87.58%
Last successful heartbeat to OMS : 2011-10-26 18:39:30
---------------------------------------------------------------
Agent is Running and Ready
[root@barracuda ~]#
Facendo
start con i componenti già attivi non hanno ottengo alcun errore:[root@barracuda ~]# service oraemgrid start
Parse /etc/oratab file [PASSED]
Starting database and listener [ OK ]
Starting Oracle Management Server [ OK ]
Starting Oracle Agent [ OK ]
[root@barracuda ~]#
Diamo un occhiata al log
/home/oracle/startup.log e vediamo che messaggi abbiamo avuto: 27/10/11-11:01:15 --> Manage Enterprise Manager Grid Control: received commmand is (start)
Processing Database instance "emgcdb": log file /u01/app/oracle/product/11.2.0/dbhome_1/startup.log
Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Starting WebTier...
WebTier Successfully Started
Starting Oracle Management Server...
Oracle Management Server Already Started
Oracle Management Server is Up
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Agent is already running
27/10/11-11:01:15 --> End of /etc/init.d/oraemgrid
Quindi sia per l'agent (
Agent is already running) che per l'OMS (Oracle Management Server Already Started) Oracle si è accorto che erano già in esecuzione. Per il database dobbiamo controllare il log /u01/app/oracle/product/11.2.0/dbhome_1/startup.log: /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart: Starting up database "emgcdb"
Thu Oct 27 11:01:15 CEST 2011
logger: Warning: Database instance "emgcdb" already started.
logger: Warning: Database instance "emgcdb" possibly left running when system went down (system crash?).
logger: Action: Notify Database Administrator.
SQL*Plus: Release 11.2.0.2.0 Production on Thu Oct 27 11:01:15 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL> Connected.
SQL> ORACLE instance shut down.
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL*Plus: Release 11.2.0.2.0 Production on Thu Oct 27 11:01:16 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL> Connected to an idle instance.
SQL> ORACLE instance started.
Total System Global Area 1653518336 bytes
Fixed Size 2227032 bytes
Variable Size 1241515176 bytes
Database Buffers 385875968 bytes
Redo Buffers 23900160 bytes
Database mounted.
Database opened.
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
/u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart: Database instance "emgcdb" warm started.
Quindi per il database il comportamento è un po' diverso: il db viene comunque spento e riacceso. Questo è dovuto a come è scritto lo script di avvio di Oracle
${ORACLE_DB_HOME}/bin/dbstart. Questo è un comportamento a cui quindi dobbiamo stare attenti: non è detto che sia sempre corretto per il nostro sistema riavviare il repository che ospita il Grid Control (ad esempio sullo stesso db potrebbe esserci qualche altro servizio). Nel listener.log invece troviamo un comportamento corretto:/u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart: Starting Oracle Net Listener
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 27-OCT-2011 11:01:15
Copyright (c) 1991, 2010, Oracle. All rights reserved.
TNS-01106: Listener using listener name LISTENER has already been started
restart
Il parametro restart esegue in sequenza il comandostop e dopo 5 secondi il comando di start. Vediamo come si comporta supponendo che i nostri componenti siano tutti attivi:[root@barracuda ~]# service oraemgrid restart
Parse /etc/oratab file [PASSED]
Stopping Oracle Agent [ OK ]
Stopping Oracle Management Server [ OK ]
Stopping database and listener [ OK ]
Starting database and listener [ OK ]
Starting Oracle Management Server [ OK ]
Starting Oracle Agent [ OK ]
[root@barracuda ~]#
Il comando funziona anche nel caso in cui i componenti siano tutti spenti (farà molto prima ad eseguire lo
stop, ma darà comunque OK come risultato):[root@barracuda ~]# service oraemgrid stop
Parse /etc/oratab file [PASSED]
Stopping Oracle Agent [ OK ]
Stopping Oracle Management Server [ OK ]
Stopping database and listener [ OK ]
[root@barracuda ~]# service oraemgrid restart
Parse /etc/oratab file [PASSED]
Stopping Oracle Agent [ OK ]
Stopping Oracle Management Server [ OK ]
Stopping database and listener [ OK ]
Starting database and listener [ OK ]
Starting Oracle Management Server [ OK ]
Starting Oracle Agent [ OK ]
[root@barracuda ~]#
Verifichiamo però attentamente nel file di log quello che è successo:
26/10/11-18:50:35 --> Manage Enterprise Manager Grid Control: received commmand is (stop)
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Stopping agent ... stopped.
Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Stopping WebTier...
WebTier Successfully Stopped
Stopping Oracle Management Server...
Oracle Management Server Successfully Stopped
Oracle Management Server is Down
Processing Database instance "emgcdb": log file /u01/app/oracle/product/11.2.0/dbhome_1/shutdown.log
26/10/11-18:50:35 --> End of /etc/init.d/oraemgrid
26/10/11-18:51:31 --> Manage Enterprise Manager Grid Control: received commmand is (restart)
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Agent is Not RunningOracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Stopping WebTier...
WebTier Successfully Stopped
Stopping Oracle Management Server...
Node Manager Not Running
Oracle Management Server is Down
Processing Database instance "emgcdb": log file /u01/app/oracle/product/11.2.0/dbhome_1/shutdown.log
Processing Database instance "emgcdb": log file /u01/app/oracle/product/11.2.0/dbhome_1/startup.log
Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Starting WebTier...
WebTier Successfully Started
Starting Oracle Management Server...
Oracle Management Server Successfully Started
Oracle Management Server is Up
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Starting agent ........ started.
26/10/11-18:51:31 --> End of /etc/init.d/oraemgrid
Quindi Oracle ci avverte sia che l'agent non è attivo (
Agent is Not Running) sia che l'OMS non è attivo (Node Manager Not Running). Il messaggio di errore per lo stop del database (che era però già fermo) lo troviamo nel file /u01/app/oracle/product/11.2.0/dbhome_1/shutdown.log SQL*Plus: Release 11.2.0.2.0 Production on Wed Oct 26 18:51:39 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL> Connected to an idle instance.
SQL> ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
SQL> Disconnected
Database instance "emgcdb" shut down.
Il comando
restart funziona anche se solo alcuni componenti e non tutti sono attivi. Proviamo ad esempio a spengere solo l'agent e ad eseguire il restart:[root@barracuda ~]# service oraemgrid stopagent
Parse /etc/oratab file [PASSED]
Stopping Oracle Agent [ OK ]
[root@barracuda ~]# service oraemgrid restart
Parse /etc/oratab file [PASSED]
Stopping Oracle Agent [ OK ]
Stopping Oracle Management Server [ OK ]
Stopping database and listener [ OK ]
Starting database and listener [ OK ]
Starting Oracle Management Server [ OK ]
Starting Oracle Agent [ OK ]
[root@barracuda ~]#
Controlliamo nel file di log quello che è successo:
26/10/11-18:55:12 --> Manage Enterprise Manager Grid Control: received commmand is (stopagent)
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Stopping agent ... stopped.
26/10/11-18:55:12 --> End of /etc/init.d/oraemgrid
26/10/11-18:55:25 --> Manage Enterprise Manager Grid Control: received commmand is (restart)
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Agent is Not Running
Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Stopping WebTier...
WebTier Successfully Stopped
Stopping Oracle Management Server...
Oracle Management Server Successfully Stopped
Oracle Management Server is Down
Processing Database instance "emgcdb": log file /u01/app/oracle/product/11.2.0/dbhome_1/shutdown.log
Processing Database instance "emgcdb": log file /u01/app/oracle/product/11.2.0/dbhome_1/startup.log
Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Starting WebTier...
WebTier Successfully Started
Starting Oracle Management Server...
Oracle Management Server Successfully Started
Oracle Management Server is Up
Oracle Enterprise Manager 11g Release 1 Grid Control 11.1.0.1.0
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Starting agent ........ started.
26/10/11-18:55:25 --> End of /etc/init.d/oraemgrid
Come vedete Oracle si è accorto che l'agent non era attivo e al momento dello stop dell'agent abbiamo semplicemente avuto il messaggio "
Agent is Not Running".Tutti gli altri parametri sono solo sotto-casi di quelli che vi ho mostrato, quindi potete provarli singolarmente con facilità seguendo le indicazioni qui sopra.





