This is a discussion on chkconfig within the Linux Operating System forums, part of the Unix Operating Systems category; --> Hi to all. I need to add a new service so i 've used a script found on /etc/init.d ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi to all. I need to add a new service so i 've used a script found on /etc/init.d and modified with my options. Then i've used chkconfig to add my script to start and stop on each runlevel. chkconfig --add em (em is my script) : #!/bin/sh # # chkconfig: 2345 99 35 # description: Starts and stops the EM (Oracle 10G) # # # script: /opt/oracle/app/oracle/product/EM10G/SH/EM.SH (root) # script: /opt/oracle/app/oracle/product/EM10G/SH/em.SH (em10g) so on level 3,4,5 i 've a S99 link and 0,1,6 i've a K35. My question is: why when server start, my em script run but when i do a reboot (i suppose init 6) my script doesn't ? Thanks Mike |
| |||
| Mike wrote: > > My question is: > > why when server start, my em script run but when i do a reboot (i > suppose init 6) my script doesn't ? Yes it will run during a reboot. You will find a S99em and a K35em in /etc/rc.d/rcX.d pointing to /etc/init.d/em. When rebooting all K-scripts for your current runlevel will run, so your service will stop during shutdown and then start during startup. -- Regards, ToreS |
| |||
| > When rebooting all K-scripts for your current runlevel will run, so your > service will stop during shutdown and then start during startup. > > -- > Regards, > ToreS Hi ToreS, thanks for your reply. Unfortunately it doesn't run. Maybe, all script Kxx on /etc/rc6.d are launched but my script doesn't run. Do you think that the script is launched but for some reason it fails ? how can i check it ? I'm sure that the script doesn't run succesfully because in ORACLE DB alert.log there's no info about shutdown Mike |
| |||
| On 7 Nov 2006 07:20:18 -0800, mbrugo@gmail.com wrote: > Do you think that the script is launched but for some reason it fails ? > > how can i check it ? If you created the script correctly (assuming /em/ is your script) service em stop service em start service em restart service em status service em reload I would use /etc/init.d/network for a working example for the command case statement and use the sourced functions for actions and printing so information shows up in /var/log/messages. |
| |||
| mbrugo@gmail.com wrote: > > > Hi ToreS, thanks for your reply. > Unfortunately it doesn't run. > Maybe, all script Kxx on /etc/rc6.d are launched but my script doesn't > run. > > Do you think that the script is launched but for some reason it fails ? > > how can i check it ? > > I'm sure that the script doesn't run succesfully because in ORACLE DB > alert.log there's no info about shutdown > Hi Mike, I'm sorry I didn't read your first posting as thorough as I should have. Have you tried to perform the 'stop' sequence in your em script manually to see if you get any error messages? When I test scripts like these i usually make them write to stdout to identify any errors. -- Regards, Tore |
| |||
| On Tue, 07 Nov 2006 21:02:30 +0100, Tore Skogly <tore.skogly@c2i.net> wrote: >mbrugo@gmail.com wrote: >Hi Mike, > >I'm sorry I didn't read your first posting as thorough as I should have. >Have you tried to perform the 'stop' sequence in your em script manually to >see if you get any error messages? >When I test scripts like these i usually make them write to stdout to >identify any errors. Hi to all Firstable thanks for your reply. I can succesfully run my script from command line. servie start/status/stop em are working It's very strange. Mike |
| |||
| Hi to all, i upload some check and my script. ================================================== ================================================== == [root@webdru2ux log]# chkconfig --list em em 0 ================================================== ================================================== == [root@webdru2ux init.d]# ll em -rwxr-xr-x 1 root root 1417 Nov 7 11:28 em ================================================== ================================================== == root@webdru2ux etc]# find . -name *em -exec ls -la {} \; lrwxrwxrwx 1 root root 12 Nov 7 11:28 ./rc.d/rc2.d/K10em -> .../init.d/em lrwxrwxrwx 1 root root 12 Nov 7 11:28 ./rc.d/rc3.d/S99em -> .../init.d/em lrwxrwxrwx 1 root root 12 Nov 7 11:28 ./rc.d/rc0.d/K10em -> .../init.d/em lrwxrwxrwx 1 root root 12 Nov 7 11:28 ./rc.d/rc4.d/S99em -> .../init.d/em lrwxrwxrwx 1 root root 12 Nov 7 11:28 ./rc.d/rc1.d/K10em -> .../init.d/em lrwxrwxrwx 1 root root 12 Nov 7 11:28 ./rc.d/rc5.d/S99em -> .../init.d/em -rwxr-xr-x 1 root root 1417 Nov 7 11:28 ./rc.d/init.d/em lrwxrwxrwx 1 root root 12 Nov 7 11:28 ./rc.d/rc6.d/K10em -> .../init.d/em ================================================== ================================================== == [root@webdru2ux etc]# service status -em status: unrecognized service [root@webdru2ux etc]# service em status ================================================== ================================================== == Status EM Oracle 10G services: Status Agent Oracle Enterprise Manager 10g Release 10.2.0.1.0. Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved. --------------------------------------------------------------- Agent Version : 10.2.0.1.0 OMS Version : 10.2.0.1.0 Protocol Version : 10.2.0.0.0 Agent Home : /opt/oracle/app/oracle/product/EM10G/agent10g Agent binaries : /opt/oracle/app/oracle/product/EM10G/agent10g Agent Process ID : 5244 Parent Process ID : 5229 Agent URL : http://webdru2ux.sede.corp.sanpaoloi...3872/emd/main/ Repository URL : http://webdru2ux.sede.corp.sanpaoloi...889/em/upload/ Started at : 2006-11-07 11:36:37 Started by user : em10g Last Reload : 2006-11-07 11:36:37 Last successful upload : (none) Last attempted upload : (none) Total Megabytes of XML files uploaded so far : 0.00 Number of XML files pending upload : 1907 Size of XML files pending upload(MB) : 51.11 Available disk space on upload filesystem : 90.68% Collection Status : Disabled by Upload Manager Last successful heartbeat to OMS : 2006-11-08 08:47:31 --------------------------------------------------------------- Agent is Running and Ready Status IasConsole Oracle Enterprise Manager 10g Release 10.2.0.1.0 Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved. Oracle 10g Application Server Control is running. ------------------------------------------------------------------ Logs are generated in directory /opt/oracle/app/oracle/product/EM10G/oms10g/sysman/log Status Opmn Processes in Instance: EnterpriseManager0.webdru2ux.sede.corp.sanpaoloimi .com -------------------+--------------------+---------+--------- ias-component | process-type | pid | status -------------------+--------------------+---------+--------- DSA | DSA | N/A | Down HTTP_Server | HTTP_Server | 4037 | Alive LogLoader | logloaderd | N/A | Down dcm-daemon | dcm-daemon | 4035 | Alive OC4J | home | 4038 | Alive OC4J | OC4J_EMPROV | 4039 | Alive OC4J | OC4J_EM | 4040 | Alive WebCache | WebCache | 4047 | Alive WebCache | WebCacheAdmin | 4034 | Alive Status Listener LSNRCTL for Linux: Version 10.1.0.4.0 - Production on 08-NOV-2006 08:47:42 Copyright (c) 1991, 2004, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)) ) STATUS of the LISTENER ------------------------ Alias lsn_emrep Version TNSLSNR for Linux: Version 10.1.0.4.0 - Production Start Date 07-NOV-2006 11:35:58 Uptime 0 days 21 hr. 11 min. 43 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /opt/oracle/app/oracle/product/EM10G/db10g/network/admin/listener.ora Listener Log File /opt/oracle/app/oracle/product/EM10G/db10g/network/log/lsn_emrep.log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)) ) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=webdru2u x.sede.corp.sanpaoloimi.com)(PORT=1526))) Services Summary... Service "EMREP" has 1 instance(s). Instance "EMREP", status UNKNOWN, has 1 handler(s) for this service... Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully Status DB SQL*Plus: Release 10.1.0.4.0 - Production on Wed Nov 8 08:47:42 2006 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production With the Partitioning, OLAP and Data Mining options SQL> STATUS DATABASE_STATUS ACTIVE_ST ------------ ----------------- --------- OPEN ACTIVE NORMAL SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production With the Partitioning, OLAP and Data Mining options ================================================== ================================================== == #!/bin/sh # # chkconfig: 345 99 10 # description: Starts and stops the EM (Oracle 10G) # # # script: /opt/oracle/app/oracle/product/EM10G/SH/EM.SH (root) # script: /opt/oracle/app/oracle/product/EM10G/SH/em.SH (em10g) # Source function library. if [ -f /etc/init.d/functions ] ; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ] ; then . /etc/rc.d/init.d/functions else exit 0 fi # Avoid using root's TMPDIR unset TMPDIR # Check that em.sh exists. [ -f /opt/oracle/app/oracle/product/EM10G/SH/em.sh ] || exit 0 RETVAL=0 ORACLE_HOME=/opt/oracle/app/oracle/product/EM10G start() { KIND="EM Oracle 10G" echo -n $"Starting $KIND services: " $ORACLE_HOME/SH/EM.sh start RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/em10g || RETVAL=1 return $RETVAL } stop() { KIND="EM Oracle 10G" echo -n $"Shutting down $KIND services: " $ORACLE_HOME/SH/EM.sh stop RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/em10g return $RETVAL } restart() { stop start } status() { echo KIND="EM Oracle 10G" echo -n $"Status $KIND services: " $ORACLE_HOME/SH/EM.sh status RETVAL=$? echo "" return $RETVAL } case "$1" in start) start ;; stop) stop ;; restart) restart ;; status) status ;; *) echo $"Usage: $0 {start|stop|restart|status}" exit 1 esac exit $? ================================================== ================================================== == Mike |
| |||
| mbrugo@gmail.com wrote: > Hi to all, > i upload some check and my script. What does $ORACLE_HOME/SH/EM.sh look like? -- Regards, Tore |
| |||
| Tore Skogly wrote: > What does $ORACLE_HOME/SH/EM.sh look like? > [root@webdru2ux SH]# pwd /opt/oracle/app/oracle/product/EM10G/SH [root@webdru2ux SH]# ll total 24 -rwx------ 1 em10g dba 3891 Nov 3 14:24 em.sh -rwx------ 1 root root 612 Nov 3 11:35 EM.sh [root@webdru2ux SH]# ================================================== ==== EM.sh #!/bin/bash # #Script per lo start/stop di IAS Infrastructure #set -x export USER=em10g case "$1" in start) su - $USER -c "cd /opt/oracle/app/oracle/product/EM10G/SH;./em.sh start" ;; stop) su - $USER -c "cd /opt/oracle/app/oracle/product/EM10G/SH;./em.sh stop" ;; restart) su - $USER -c "cd /opt/oracle/app/oracle/product/EM10G/SH;./em.sh restart" ;; status) su - $USER -c "cd /opt/oracle/app/oracle/product/EM10G/SH;./em.sh status" ;; *) echo "Usage: $0 { start | stop | restart | status} " exit 1 ;; esac exit 0 ================================================== ==== em.sh #!/bin/bash # #Script per lo start/stop di EM # Michele Brugo # Pic informatica 14 Giugno 2006 #set -x export DISPLAY=webdru2ux:0 export LOG_DIR=/tmp export LOG_FILE_START=$LOG_DIR/em_start.log export LOG_FILE_STOP=$LOG_DIR/em_stop.log export ORACLE_BASE=/opt/oracle/app/oracle export TERM=vt100 export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P15 export ORACLE_TERM=vt100 export TMPDIR=/tmp export LD_ASSUME_KERNEL=2.4.21 db() { export ORACLE_HOME=$ORACLE_BASE/product/EM10G/db10g export TNS_DIR=$ORACLE_HOME/network/admin export SHLIB_PATH=$ORACLE_HOME/lib:/usr/lib export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data export PATH=$ORACLE_HOME/bin:/usr/ccs/bin:/usr/local/bin:/usr/sbin/:$PATH export CLASSPATH=$ORACLE_HOME/jdbc/lib/classes12.zip:$ORACLE_HOME/jdbc/lib/jndi.zip:$ORACLE_HOME/jdbc/lib/jta.zip export ORACLE_SID=EMREP } agent() { export ORACLE_HOME=$ORACLE_BASE/product/EM10G/agent10g export TNS_DIR=$ORACLE_HOME/network/admin export SHLIB_PATH=$ORACLE_HOME/lib:/usr/lib export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data export PATH=$ORACLE_HOME/bin:/usr/ccs/bin:/usr/local/bin:/usr/sbin/:$PATH export CLASSPATH=$ORACLE_HOME/jdbc/lib/classes12.zip:$ORACLE_HOME/jdbc/lib/jndi.zip:$ORACLE_HOME/jdbc/lib/jta.zip } oms() { export ORACLE_HOME=$ORACLE_BASE/product/EM10G/oms10g export OPMN_HOME=$ORACLE_BASE/product/EM10G/oms10g/opmn export TNS_DIR=$ORACLE_HOME/network/admin export SHLIB_PATH=$ORACLE_HOME/lib:/usr/lib export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data export PATH=$ORACLE_HOME/bin:/usr/ccs/bin:/usr/local/bin:/usr/sbin/:$PATH export CLASSPATH=$ORACLE_HOME/jdbc/lib/classes12.zip:$ORACLE_HOME/jdbc/lib/jndi.zip:$ORACLE_HOME/jdbc/lib/jta.zip } start_p() { db echo "Starting DB" > $LOG_FILE_START $ORACLE_HOME/bin/sqlplus "/ as sysdba" << EOF >> $LOG_FILE_START startup EOF echo "Starting Listener" >> $LOG_FILE_START $ORACLE_HOME/bin/lsnrctl start lsn_emrep >> $LOG_FILE_START oms echo "Starting Opmn" >> $LOG_FILE_START $OPMN_HOME/bin/opmnctl startall >> $LOG_FILE_START echo "Starting IasConsole" >> $LOG_FILE_START $ORACLE_HOME/bin/emctl start iasconsole >> $LOG_FILE_START agent echo "Starting Agent" >> $LOG_FILE_START $ORACLE_HOME/bin/emctl start agent >> $LOG_FILE_START } stop_p() { agent echo "Stopping Agent" > $LOG_FILE_STOP $ORACLE_HOME/bin/emctl stop agent >> $LOG_FILE_STOP oms echo "Stopping IasConsole" >> $LOG_FILE_STOP $ORACLE_HOME/bin/emctl stop iasconsole >> $LOG_FILE_STOP echo "Stopping Opmn" >> $LOG_FILE_STOP $OPMN_HOME/bin/opmnctl stopall >> $LOG_FILE_STOP db echo "Stopping Listener" >> $LOG_FILE_STOP $ORACLE_HOME/bin/lsnrctl stop lsn_emrep >> $LOG_FILE_STOP echo "Stopping DB" >> $LOG_FILE_STOP $ORACLE_HOME/bin/sqlplus "/ as sysdba" << EOF >> $LOG_FILE_STOP shutdown immediate EOF } restart_p() { stop_p start_p } status_p() { agent echo "Status Agent" $ORACLE_HOME/bin/emctl status agent oms echo "Status IasConsole" $ORACLE_HOME/bin/emctl status iasconsole echo "Status Opmn" $OPMN_HOME/bin/opmnctl status db echo "Status Listener" $ORACLE_HOME/bin/lsnrctl status lsn_emrep echo "Status DB" $ORACLE_HOME/bin/sqlplus "/ as sysdba" << EOF select status, database_status, active_state from v\$instance; EOF } case "$1" in start) start_p ;; stop) stop_p ;; restart) restart_p ;; status) status_p ;; *) echo "Usage: $0 { start | stop | restart | status} " exit 1 ;; esac exit 0 ================================================== c'ya MIke |
| ||||
| On Tue, 07 Nov 2006 10:54:19 -0600, Bit Twister wrote: > On 7 Nov 2006 07:20:18 -0800, mbrugo@gmail.com wrote: >> Do you think that the script is launched but for some reason it fails ? >> >> how can i check it ? > > If you created the script correctly (assuming /em/ is your script) > > service em stop > service em start > service em restart > service em status > service em reload > > I would use /etc/init.d/network for a working example for the command > case statement and use the sourced functions for actions and printing > so information shows up in /var/log/messages. I have often resorted to logging tricks to see if things are actually running and what happened. Add a log file... so you can see what it's trying to do, then you can figure out if it's getting that far. echo `date` $0 $* >> /tmp/em.init.d.log An old favorite...log it ALL. exec >> /tmp/em.init.d.log 2>&1 set -x Maybe your environment? You never know what you're gonna find out there... I also like to add set just to print my environment (with the exec above) If it seems to really not be running your script then go up a level... add logging to /etc/rc.d/rc BE CAREFUL, MAKE A BACKUP FILE, EDIT A COPY FIRST TEST THE COPY WITH "bash -n" BEFORE YOU INSTALL IT! .... and have a rescue disk on hand that you know how to use Because you could make your system un-bootable! Fewer changes are better... just add some logging? ... and for the more knowledgeable... HPUX (that I cant quite get rid of) logs the system boot rc to /etc/rc.log, and I like it a lot... why does linux (Redhat) not log this? /var/log/rc/rc.log.1 ... ? Or is that what boot.log is supposed to be (mine are empty) bash(1) -n Read commands but do not execute them. This may be used to check a shell script for syntax errors. This is ignored by interactive shells. |
| Thread Tools | |
| Display Modes | |
|
|