Tuesday, May 4, 2010

How to shutdown and start Oracle with AIX OS

1019817.6 Automatic startup/ shutdown of Oracle instances on IBM AIX
244139.1
61333.1 Automatic startup and shutdown of Oracle database instances
207508.1 Dbstart does not work if using an spfile only
91815.1 Annotated dbstart script
1019790.6 Automatic startup/ shutdown of Oracle instances on HP-UX Unix
222813.1 Automatic startup/ shutdown of Oracle instances on Linux

Automating Database Startup and Shutdown for AIX:
http://download.oracle.com/docs/html/A96167_01/post-inst.htm#i1035384
Oracle Corporation recommends that you configure your system to automatically start Oracle databases when your system starts up, and to shut down Oracle databases when your system shuts down. Automatic database startup and shutdown protects against improper shutdown of the database.

Automating Database Startup
Perform the following tasks to set up the dbstart and dbshut scripts so that they are called at system startup. This process must be completed for every new database that you want to configure for automated startup:

1.Edit the /etc/oratab file.

Database entries in the oratab file appears in the following format:

ORACLE_SID:ORACLE_HOME:{Y|N}

In the preceding command, Y or N specifies whether you want the dbstart and dbshut scripts to start up and shut down the database.

For Oracle Real Application Clusters installation, this entry appears in the following format:

DB_NAME:ORACLE_HOME:{Y|N}

In the preceding command, DB_NAME is the cluster database name. Y or N specifies whether you want the dbstart and dbshut scripts to start up and shut down the database.

2.For each database that you want to start up, find the ORACLE_SID entry identified by the sid in the first field. Change the last field for each to Y.

3.Add the dbstart script to the /etc/inittab file:

# mkitab "oradb:2:wait:/bin/su oradb -c|/$ORACLE_HOMES/bin/dbstart"

In the preceding command, oradb is the identifier of the oracle user for which you want to start the database.

Automating Database Shutdown
Automate database and system shutdown by creating a script, shut, to start dbshut and the system executable /etc/shutdown. Complete the following steps to create the script:

1.If you have not already done so, edit the database entries of your /etc/oratab file to enable dbstart and dbshut, as described in step 1 of the dbstart instructions.

2.As root, create the shut shell script:

# cd /etc
cat > shut << EOF
? su oracle_owner -c /usr/oracle/bin/dbshut
? /etc/shutdown $* \
? [Ctrl-D]
# chmod u+x shut

3.Execute the following command to run the shut script and shut down the database:

# /etc/shut -h now

This closes Oracle databases and shuts down the system with the specified options.

Actual Step on AIX:
- make a backup copy of your existing dbstart script prior to proceeding

- edit the dbstart script

- add the following line:
SPFILE=${ORACLE_HOME}/dbs/spfile${ORACLE_SID}.ora
after this line: PFILE=${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora

- change:
if [ -f $PFILE ] ; then
to:
if [ -f $PFILE -o -f $SPFILE ] ; then

At the end of the file, make the following entry:
$ORACLE_HOME/bin/lsnrctl start

/etc/mkitab "oracle:2:wait:/bin/su oracle -c
<$ORACLE_HOME>/bin/dbstart > /dev/console 2>&1"

Make sure that the entry is made in /etc/inittab


Automating Database Startup and Shutdown for Linux:
http://download.oracle.com/docs/html/A96167_01/post-inst.htm#i1035370
Oracle Corporation recommends that you configure your system to automatically start Oracle databases when your system starts up, and to shut down Oracle databases when your system shuts down. Automatic database startup and shutdown protects against improper shutdown of the database.

The dbstart and dbshut scripts are located in the $ORACLE_HOME/bin directory and can be used to automate database startup and shutdown. The dbstart and dbshut scripts reference the same entries in the oratab file, so the scripts must apply to the same set of databases. For example, you cannot have the dbstart script automatically start up databases sid1, sid2, and sid3, and the dbshut script shut down only databases sid1 and sid2. You can, however, specify that the dbshut script shut down a set of databases while the dbstart script is not used at all. To do this, include a dbshut entry in the system shutdown file but omit the dbstart entry from the system startup files.


See Also:

init command in your UNIX system documentation for more information on system startup and shutdown procedures.


Perform the following tasks to set up the dbstart and dbshut scripts so that they are called at system startup. This process must be completed for every new database that you want to configure for automated startup and shutdown.

1.Edit the /var/opt/oracle/oratab file for Solaris and /etc/oratab file for HP and Linux.

Database entries in the oratab file appears in the following format:

ORACLE_SID:ORACLE_HOME:{Y|N}
In the preceding command, Y or N specifies whether you want the dbstart and dbshut scripts to start up and shut down the database. For each database that you want to start up, find the ORACLE_SID entry identified by the sid in the first field. Change the last field for each to Y.

For Oracle Real Application Clusters installation, this entry appears in the following format:

DB_NAME:ORACLE_HOME:{Y|N}

In the preceding command, DB_NAME is the cluster database name. Y or N specifies whether you want the dbstart and dbshut scripts to start up and shut down the database.

2.In the /etc/init.d directory, create a dbora script similar to the following, if it does not already exist. Be sure to give the full path of the dbstart utility.

#!/bin/sh

# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.

ORA_HOME=/u01/app/oracle/product/9.2.0.1.0
ORA_OWNER=oracle

if [! -f $ORA_HOME/bin/dbstart]
then
echo "Oracle startup: cannot start"
exit
fi

case "$1" in
'start')

# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values

su - $ORA_OWNER -c $ORA_HOME/bin/dbstart &
;;

'stop')

# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values

su - $ORA_OWNER -c $ORA_HOME/bin/dbshut &
;;

esac

3.Create symbolic links to the dbora script in the appropriate run-level script directories, as follows:

# ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora
# ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora


The system shutdown process in AIX involves only the /etc/shutdown script.
You can perform shutdown manually, or write a script which automatically
shuts down Oracle instances and then shuts down the system.

Here is a sample script that performs these actions. Make sure that the
script you write is owned and executable only by root.

#!/bin/sh

/bin/su oracle -c /bin/dbshut
/usr/sbin/shutdown $*

Note: we strongly recommend that you do not alter the system shutdown script

Save it and execute it as /etc/shut -h now

Wednesday, December 9, 2009

AIX - All about diagela

Go to smit
Select - Problem Determination
- Hardware Diagnostics
- Current Shell Diagnostics (smit diag fast path will bring us here)
- Enter
- Task Selection (Diagnostics, Advanced Diagnostics, Service Aids etc)
- Automatic Error log Analysis and Notification
- Enter
- Display the error notification Mailing List

AIX Clearing a Print Queue Backlog

Guide to Printers and Printing
Clearing a Print Queue Backlog
http://publib16.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixbman/printrgd/clrqueback.htm

To clear the queuing system, you must stop qdaemon and check if the /var file system is full. If so, use the following procedure to clear the queue directories and restart the qdaemon.

1. Make sure you are logged in as root.

2. If possible, let all current print jobs finish printing or cancel them. To cancel a print job, issue the lpstat command to get the print job number. Then use the enq command to cancel each job:

enq -x JobNumber

The lpstat command displays information about the current status of the line printer. The enq command enqueues a file.

3. Issue the following command to stop qdaemon:

stopsrc -s qdaemon

4. Issue the following commands to verify that qdaemon did not fork other processes:

ps -ef | grep qdaemon
ps -ef | grep pio

The ps command shows the current status of processes. The grep command searches a file for a pattern.

If you get one line back from each of the above grep commands, skip step 5 and go to step 6. If you get more than one line, go to step 5.

5. If other qdaemons or pios were returned by the ps -ef command, kill these processes by issuing the following command with each process ID:

kill -9 pid

The following example shows a qdaemon returned by ps -ef. The process ID is 3357.


root 3357 2288 0 13:32:21 - 0:04 dtterm

To kill this process ID, enter kill -9 3357 at the command line.

6. Perform this step only if it is necessary to save the current print jobs from being deleted. Otherwise, proceed to step 7. If your print job is queued in one of the following directories, make a copy of it, and place it in /tmp; you can print it when the queuing system is running again.

Note: In these directories, the files will have unfamiliar system names.

/var/spool/qdaemon
/var/spool/lpd

7. If the /var file system gets too full, you may experience problems with qdaemon or the spooler. Large print jobs may fail, or 00root files with zero lengths may appear in your qdir directory. Rebooting the system in this case may not clear out the files or restart qdaemon.

Enter the df command and look in the %used column for/var to see if the file system is too full. Free space in the file system as necessary.

The df command displays information about total space and available space on a file system.

8. Change the directory as follows:

cd /var/spool/lpd/qdir

9. Issue a pwd command to verify that you are in the proper directory. Then, remove all files in this directory using the rm command:

rm *

The pwd command writes to standard output the full path name of your current directory (from the root directory). The rm command removes the entries for the specified file or files from a directory.

10. Change the directory again:

cd /var/spool/lpd/stat

11. Issue a pwd command to verify that you are in the proper directory. Then, remove all files in this directory:

rm *

12. Change the directory again:

cd /var/spool/qdaemon

13. Issue a pwd command to verify that you are in the proper directory. Then, remove all files in this directory:

rm *

14. Follow this step if you are having trouble with the remote queue or lpd. Change the directory:

cd /var/spool/lpd

Issue a pwd to verify that you are in the proper directory. Then, remove all files in this directory using the rm command:

rm *

Note: The rm command will not remove the subdirectories.

15. Start qdaemon:

startsrc -s qdaemonThe queuing system should start normally. If some queues are still down, bring them up by entering:


enable QueueName

Thursday, September 24, 2009

AIX disks are raided?

lsdev -Cs scsi
hdisk0 Available 1S-08-00-8,0 16 Bit LVD SCSI Disk Drive
hdisk1 Available 1S-08-00-9,0 16 Bit LVD SCSI Disk Drive
hdisk2 Available 1S-08-00-10,0 16 Bit LVD SCSI Disk Drive
hdisk3 Available 1S-08-00-11,0 16 Bit LVD SCSI Disk Drive
hdisk4 Available 11-08-ff-0,0 SCSI RAID 5 Disk Array
pdisk0 Available 11-08-01-0,0 Physical SCSI Disk Drive
pdisk1 Available 11-08-01-1,0 Physical SCSI Disk Drive
pdisk2 Available 11-08-01-2,0 Physical SCSI Disk Drive
pdisk3 Available 11-08-01-3,0 Physical SCSI Disk Drive
rmt0 Available 1S-09-00-4,0 Other SCSI Tape Drive
rmt1 Available 1c-08-00-5,0 SCSI 8mm Tape Drive
ses0 Available 1S-08-00-15,0 SCSI Enclosure Services Device
ses1 Defined 11-08-00-15,0 SCSI Enclosure Services Device
ses2 Available 11-08-01-15,0 SCSI Enclosure Services Device

lsdev -Cc adapter

lspv

lscfg -v | pg

lsdev –p disk
lsdev -Cc disk

Parent of the disk will tell us whether they are raided or not.
lsparent -C -l hdisk1

lsdev -C | grep 1S-08

Wednesday, September 16, 2009

Trouble-shooting mail in AIX

Go to the edit page to see the hidden characters:
References:
AIX/HP-UX interoperability Guide
Google online books on AIX Administration by Randal K. Michael

Changed the mail server. emails stopped coming from ors0 server.

Edit /etc/mail/sendmail.cf for replacing smart relay host from mciexch1 to mciexch2 (Change the ip address) and save the file.

Edit /etc/hosts for replacing host from mciexch1 to mciexch2 (Change the ip address) and save the file.

If we update any of the configuration info while sendmail is running, refresh the sendmail subsystem by issue an SRC refresh command or by sending the daemon a SIGHUP as
#refresh -s sendmail
#kill -1 `head -1 /etc/mail/sendmail.pid`

#head -1 sendmail.pid
#more sendmail.pid
#kill -1 `head -1 sendmail.pid`
#more sendmail.pid
#ps -efgrep mail
#lssrc -s sendmail
#stopsrc -s sendmail
#ps -ef|grep mail
#lssrc -s sendmail
#startsrc -s sendmail -a'-bd -q30m'
#lssrc -s sendmail
#ls
# more sendmail.pid

Test the mail as follow:
log in as oracle
cp .profile temp
sendmail -v oracle
sendmail -v yada@yada.com
cat /dev/null > /var/spool/mail/jayp
cat /dev/null > /var/spool/mail/vogtb
cat /dev/null > /var/spool/mail/doanl
cat /dev/null > /var/spool/mail/root

To get emails if there is any hardware failure:
Nothing needs to be done to enable diagela as it is enabled by default.
/usr/lpp/diagnostics/bin/diagela ENABLE

Smit diag
Select current shell diagnostics
Enter
Task Selection (Diagnostics, Advanced Diagnostics, Service Aids etc.)
Automatic Error Log Analysis and Notification
Enter
Display the error notification mailing list

Wednesday, August 26, 2009

How to untar, unzip, uncompress Oracle software

1) Uncompress the downloaded patch set file into a new directory and extract the zip files using the following commands:

unzip p4163445_9207_AIX64-5l.zip

2) Uncompress the downloaded patch set file into a new directory and extract the cpio files using the following commands:

cpio -idcv < 9205_aix5164_release.cpio

3) Uncompress the downloaded patch set file into a new directory and extract the tar files using the following commands:

tar xvf 8174_aix32.tar

Wednesday, August 12, 2009

Moving directories and files recursively

I have a directory with 3 subdirectories.
for example dir1, dir2 and dir3

/home/mydirectory/
dir1
dir2
dir3

under these directory I have 3 subdirectories and I would like to move or copy all the subdirectories of

/home/mydirectory to /home/movehere/

Unfortenately a normal move moves also mydirectory to /home/movehere
and so I get /home/movehere/mydirectory

This is not what I want, I just want all the subdirectories of mydirectory.

This is what I need:

home/movehere/
dir1
dir2
dir3

Option#1
--------
#!/bin/sh

cd /home/mydirectory
echo dir* | while read LINE
do
if [ -d $LINE ]; then
mv $LINE /home/movehere
fi
done

Option#2 (Proper way)
--------
The proper way to do it, is to use tar to copy files from one directory to another:

# all on oneline
cd /home/mydir; tar cf - .|(cd /home/movehere; tar xf - )

You can also use cpio:

# all on oneline
cd /home/mydir; find . -depth -print|cpio -pd /home/movehere

Thanks to http://www.computing.net/answers/unix/moving-recursively-direcotries/6930.html