Oracle release numbers consist of 5 digits - for example Oracle9i.9.2.0.1.0 means First digit is the major version number (8), second is the release number (1), third is the maintenance release number (7), fourth is the generic patch number (3) and fifth is the platform specific patch set number (2).
Monday, January 30, 2006
Meaning of Oracle Release Numbers
Oracle release numbers consist of 5 digits - for example Oracle9i.9.2.0.1.0 means First digit is the major version number (8), second is the release number (1), third is the maintenance release number (7), fourth is the generic patch number (3) and fifth is the platform specific patch set number (2).
Posted by tekmen at 4:48 PM 0 comments
Labels: General
Sunday, January 29, 2006
Report changes from alert.log file (unix server only)
The following commands will extract only the changes since the last time you have run the report:
# get the log filename
log=$ORACLE_BASE/admin/$ORACLE_SID/bdump/alert_${ORACLE_SID}.log
if [[ -f $log.last ]] then
#get the last reported line
today=`cat $log.last`
else
#find the last date in the file
lastdt=`tail $log|grep :|grep 200|tail -1|cut -c-11`
#get the first occurrence of that date
today=`grep -n "$lastdt" $log|head -1|tr ':' '\012'|head -1`
fi
#remember the last line:
echo `wc -l $log`>$log.last
#today's file
newlog=/tmp/mon_alert_${ORACLE_SID}.log
#extract only today's data
sed -n $today,'$'p $log|tr '\09' ' '>$newlog
# the rest is up to you.
Alternatively, you could run a cron job to get the number of lines:
# get the log filename
log=$ORACLE_BASE/admin/$ORACLE_SID/bdump/alert_${ORACLE_SID}.log
echo `wc -l $log`>$log.last
#In the morning you just report data from the file:
#today's file
newlog=/tmp/mon_alert_${ORACLE_SID}.log
#extract only today's data
sed -n $today,'$'p $log|tr '\09' ' '>$newlog
Look for anything of interest in the $newlog file
Posted by tekmen at 4:17 PM 0 comments
Labels: DBA
Friday, January 20, 2006
Unix Core Files
When you are running a program on a UNIX machine that terminates abnormally, possibly because it crashed, the operating system creates a core file in the current working directory. The system dumps information into the core file about what the program was doing at the time it crashed, e.g., which subroutine it was calling or what memory address it was accessing. The format of the information in this file is pretty cryptic, but the file can be post-processed by an appropriate debugging tool to give application developers useful information. If you are not trying to diagnose a bug in an application, the file contains no other useful information and can be safely deleted. In fact, it should be deleted because often it is quite large (>100 MB).
How can you prevent the core file from getting so large? One option is to create a directory named core in your current working directory. When the application crashes, the operating system cannot write the core file because a directory with the name already exists. A second option is to set a limit on how big the core file is allowed to grow using the command
limit coredumpize xxxx
xxxx is the maximum size in kB that the core file is allowed to be. In theory, the core file will never exceed the limit. However, in practice, some operating systems ignore it. This command has been incorporated into the standard NML .cshrc file.
Posted by tekmen at 4:20 PM 0 comments
Labels: DBA
Tuesday, January 17, 2006
oraenv and coraenv Utilities
The oraenv and coraenv utilities both aid in setting the Oracle environment on UNIX systems (other utilities exist on Windows platform that enable the Oracle Home to be set.) The coraenv utility is appropriate for the UNIX C Shell; oraenv should be used with either the Bourne or Korn shells.
Database operations require the ORACLE_HOME to be set before the user may access the database. If ORACLE_HOME is not set, commands such as sqlplus, exp, or any other utility for that matter, will not be found.
Both utilities are shell scripts that do the same thing in the different UNIX shells. They will prompt for a SID of the database unless ORAENV_ASK is set to N. The utility will also append the ORACLE_HOME value to the path, marking the location of the utility.
The oraenv command will prompt for the SID of the database that you wish $ORACLE_HOME to access.
$ . oraenv
ORACLE_SID = [] ? ASG920
The dbhome utility can now be used to verify that $ORACLE_HOME is correct.
$ dbhome
/usr/oracle/9.2.0
The “dot space” part of the command is required to make the environment change with the parent shell, as opposed to entering a command without it which would only affect the subshell running that process.
These commands can be used to avoid specifying the network service name when issuing commands. For instance, without using oraenv, an sqlplus command would look like:
$ sqlplus system/manager@nameofservice as sysdba
whereas after oraenv has been executed, the following command would work:
$ sqlplus system/manager as sysdba
Posted by tekmen at 4:03 PM 0 comments
Labels: DBA
Saturday, January 14, 2006
Starting and Stopping on Windows
The dbstart and dbstop shell scripts do not exist on Windows platforms. Consequently Oracle database startup and shutdown is implemented completely differently. The oradim utility is used on the Windows platform to perform these tasks.
C:\oracle9i\bin\oradim -startup -sid ORCL92 –usrpwd manager
-starttype SRVC,INST -pfile C:\oracle9i\admin\ORCL92\pfile\init.ora
- startup — Indicates that the specified instance should be started.
- sid — The SID of the database to start.
- usrpwd — The password for the database user.
- starttype — Specifies whether to start the instance, the service, or both (SRVC, INST).
The following command can be used to shutdown the instance with oradim:
C:\oracle9i\bin\oradim -shutdown -sid ORCL92 -shutttype SRVC,INST
–shutmode A
Notice that no password is needed to perform this task.
The shuttype parameter specifies what is to be stopped – the service (SRVC), the instance (INST), or both (SRVC, INST). The shutmode specifies the method that should perform the shutdown – (A)bort, (I)mmediate, or (N)ormal.
Each operation, regardless of success, is logged in the oradim log file (ORACLE_HOME\database\OraDim.Log). This file should be checked for errors after each oradim command is executed.
The oradim utility provides more than just the ability to start and stop Windows databases. oradim can create and edit databases. It also allows DBAs to configure script-based installation mechanisms, bypassing the Oracle Database Configuration Assistant’s graphical user interface (GUI).
For a reference of all oradim commands, use the oradim–help command.
Posted by tekmen at 4:05 PM 0 comments
Labels: DBA
Thursday, January 12, 2006
Automatic Startup & Shutdown
The following list summarizes the functions performed by the different Oracle startup and shutdown scripts (which are invoked during system startup and shutdown, respectively).
Script | Description | |
$ORACLE_HOME/bin/dbstart | Ensures a clean startup of database instance(s), even after system failure | |
$ORACLE_HOME/bin/dbshut | Ensures a clean shutdown for database instances | |
/var/opt/oracle/oratab | Contains a field that specifies whether a particular database instance should be brought up/down at system startup /shutdown time by specifying "Y" in this field, the "dbstart" and "dbshut" scripts bring this database and instance up or down. | |
/etc/inittab | Controls the initialization process | |
Relevant Files | Description |
/etc/init.d/dbstart | Script to call $ORACLE_HOME/bin/dbstart |
/etc/init.d/dbshut | Script to call $ORACLE_HOME/bin/dbshut |
/etc/rc2.d/S99dbstart | Link to the script /etc/init.d/dbstart |
/etc/rc0.d/K01dbshut | Link to the script /etc/init.d/dbshut |
$ORACLE_HOME/lsnr_start.sh | Script to start listener |
$ORACLE_HOME/lsnr_stop.sh | Script to stop listener |
System V initialization scripts are contained in /etc/rc
[K or S][two-digit number][descriptive filename]
Scripts containing larger numbers in their names are executed after those with lower numbers. Oracle startup scripts typically contain larger numbers in their names, such as "S99oracle", indicating that the script should be run after the system has been started up. Oracle shutdown script names, on the other hand, usually contain smaller numbers, such as "K01oracle" indicating that the script should be run before system shutdown.
Every Oracle installation has an 'oratab' file which contains an entry for every database in the system. You will need 'root' privileges to accomplish the following:
STEPS
1. Edit the 'oratab' file (/var/opt/oracle/oratab):
mlive:/export/home/app/oracle/product/8.1.6:Y
2. As oracle user, create the following shell script files “lsnr_start.sh” and “lsnr_stop.sh” in the $ORACLE_HOME directory and ensure that both files are executable by the oracle userid. Since all files “lsnrctl” needs are not in the default directory, those scripts that include the needed information have to be used to start listener:
lsnr_start :
PATH=/export/home/app/oracle/product/9.2.0.1.0/bin:.;
export PATH
ORATAB=/var/opt/oracle/oratab;
export ORATAB
ORACLE_HOME=/export/home/app/oracle/product/9.2.0.1.0;
export ORACLE_HOME
lsnrctl start
lsnr_stop :
PATH=/export/home/app/oracle/product/9.2.0.1.0/bin:.;
export PATH
ORATAB=/var/opt/oracle/oratab;
export ORATAB
ORACLE_HOME=/export/home/app/oracle/product/9.2.0.1.0;
export ORACLE_HOME
lsnrctl stop
3. As root, create the following OS script files dbstart and dbshut in the /etc/init.d directory and ensure that both files are executable by the oracle userid:
dbstart :
su oracle -c /export/home/app/oracle/product/9.2.0.1.0/bin/dbstart
su oracle -c /export/home/app/oracle/product/9.2.0.1.0/lsnr_start.sh
dbshut :
su oracle -c /export/home/app/oracle/product/9.2.0.1.0/bin/dbshut
su oracle -c /export/home/app/oracle/product/9.2.0.1.0/lsnr_stop.sh
4. As a root, link the dbshut and dbstart to /etc/rc*.d directory:
# ln -s /etc/init.d/dbshut /etc/rc0.d/K01dbshut
# ln -s /etc/init.d/dbstart /etc/rc2.d/S99dbstart
Relevant Oracle Metalink Documents
1005041.6 How to Automatically Start the Listener On UNIX
61333.1 Automatic startup and shutdown of oracle instances
105957.1 How to setup Oracle to startup automatically if system is restarted
1068670.6 Listener will not start autostart at boot time
1031930.6 Solaris RC&RC.D startup&shutdown scripts
91815.1 The Annotated dbstart Script
Posted by tekmen at 8:01 PM 0 comments
Labels: DBA
Thursday, January 05, 2006
Availability of the DB and listener
db_check.sh
#!/bin/sh
#
############################
# FUNCTION: IsListenerRunning
############################
#
IsListenerRunning()
{
ps -ef | egrep '/bin/tnslsnr' | egrep -v 'grep' > /dev/null 2>&1
}
############################
# FUNCTION: IsListenerUp
############################
#
IsListenerUp()
{
lsnrctl status > /dev/null 2>&1
}
############################
# MAIN PROGRAM
############################
#
CHECK_LISTENER=1
CHECK_LISTENER_IS_UP=1
SPOOLFILE=/export/tmscs/db_cron/db.log
#
# check if database is running
#
if [ `echo "select dummy||'OK' from dual;" | sqlplus -s system/manager | grep XOK` ]
then
IS_OK="XOK"
else
IS_OK="FALSE"
fi
#
# check if listener is running
#
IsListenerRunning || CHECK_LISTENER=0
#
# check if listener is up#
IsListenerUp || CHECK_LISTENER_IS_UP=0
date +"Date is %D %nTime is %T" > $SPOOLFILE
if [ $IS_OK = "XOK" ]
then
echo "SELECT 'Database has been up and running for '|| round(24*(SYSDATE-logon_time),1) || ' hour(s)' FROM sys.V_\$SESSION WHERE sid=1;" | sqlplus
-s system/manager | grep running >> $SPOOLFILE
else
echo "Database is down" >> $SPOOLFILE
fi
if [ $CHECK_LISTENER = 0 ]
then
echo "Listener is not Running" >> $SPOOLFILE
fi
if [ $CHECK_LISTENER_IS_UP = 0 ]
then
echo "Listener is down" >> $SPOOLFILE
lsnrctl start && echo "Listener is started succesfully" >> $SPOOLFILE
else
echo "Listener is up" >> $SPOOLFILE
fi
If listener is not running, script will start it. But if database is down, script will do nothing.
The crontab jobs executing this script is created under the user ROOT, and since ROOT user has already several crontab jobs, the new job line is added to the crontab file and then this file is submitted to the system (/var/spool/cron/crontabs/root);
15,30,45,01 * * * * su - oracle -c "/export/tmscs/db_cron/db_check.sh" > "/export/tmscs/db_cron/err.log"
And then to submit the file;
crontab crontab_filename
This job runs every fifteen minutes.
After running the script, the crontab job will produce 2 files (db.log and err.log) under the folder “/export/tmscs/db_cron”
db.log
If database and listener are running;
Date is 01/07/03
Time is 10:12:57
Database has been up and running for 119.4 hour(s)
Listener is up
If database is down and listener is running;
Date is 01/07/03
Time is 13:53:43
Database is down
Listener is up
If database is up and listener is down;
Date is 01/07/03
Time is 13:54:37
Database has been up and running for 0 hour(s)
Listener is up
If both database and listener is down;
Date is 01/07/03
Time is 13:45:01
Database is down
Listener is not Running
Listener is down
err.log
$ more err.log
PATH is /usr/bin:
PATH is
/export/home/app/oracle/product/
9.2.0.1.0/bin:.:/usr/bin:.:/usr/local/bin
Sun Microsystems Inc. SunOS 5.7 Generic October 1998
You have mail.
Running Oracle .login ...
It shows the log of last process and if an error occurs, what the error is can be seen in this file;
Configuration :
- Given Password for system user in db_check.sh file must be corrected (now system/manager)
- Given path for db_clean.sql and err.log files must be corrected (now /export/tmscs/db_cron/)
- All created scripts and folders must be owned by oracle:dba with the rights of “711”
Posted by tekmen at 8:10 PM 0 comments
Labels: DBA
Server and Database Naming
Server Naming Formula: application + function . domain
Database Naming Formula: application + function + geo specification
The following tables provide the recommended abbreviation standards to be used in naming servers and databases for global applications.
Examples :
FUNCTION ABBREVIATIONDisaster Recovery database DR
Disaster Recovery server DR or DBDR
Test database TST
Test server TST or TEST
Development DEV
Training TRN
Release REL
Test Reporting TRP
DBnet (off SWAN) DBX
Middle tier MT Middle tier (partner) MTP
Web server WS
GEO DOMAIN
APAC singapore; japan
EMEA holland; turkey
Americas central; east
Notes:
Oracle database names (SIDs) typically should be uppercase.
There is no hard limit to the length of a server name. It is recommended that server names no more than 8-14 characters, if possible.
Server names typically should be lower case.
Server names can include a hyphen to separate the application and function components of the server name. However, it has been discovered that a hyphen in the server name causes a problem when the Oracle database init.ora parameter global_names is set to TRUE and the db_domain parameter is set to the server name. To avoid this problem, do not use a hyphen in the server name.
The domain component of the server name will always be separated with a period ('.') from the application and function components.
In applications where there will be multiple servers of the same function, sequence numbers can be used. As an example, Radiance has 3 different servers hosting the middle tier. They are named rad-mt01.domain, rad-mt02.domain, rad-mt03.domain.-
Oracle database names (SIDs) are limited to 8 charactersApplication component of Oracle database name can be up to 3 characters
- Application component of Oracle database name can be up to 3 characters
- Function component of Oracle database name can be up to 3 characters
- GEO specification is limited to 2 characters
Posted by tekmen at 7:48 PM 0 comments
Labels: General