Pages

Saturday, November 14, 2009

To start up the ASM instance

To start up the ASM instance, I then simply issue the STARTUP MOUNT command. Here is how a successful ASM instance startup appears in the Linux environment:

$> export ORACLE_SID=+ASM

$> sqlplus "sys as sysdba"
SQL*Plus: Release 10.1.0.2.0 - Production on Tue Dec 13 16:58:17 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Enter password: ********

Connected to an idle instance.

SQL> startup mount;
ASM instance started

Total System Global Area 100663296 bytes
Fixed Size 787648 bytes
Variable Size 99875648 bytes
Database Buffers 0 bytes
Redo Buffers 0 bytes

ASM diskgroups mounted

Waiting for Oracle CSS service to be available before starting

Despite knowing the problem, I wasn't able to find a solution until I came across Jeff Hunter's Oracle blog. In it, he correctly noted that due to a known bug, the /etc/inittab file must be manually modified to support Oracle ASM auto-start on RHEL.
Specifically, the respawn line for the init.cssd process must fall between the wait for runlevel 2 and runlevel 3

l2:2:wait:/etc/rc.d/rc 2
h1:35:respawn:/etc/init.d/init.cssd run >/dev/null 2>&1 l3:3:wait:/etc/rc.d/rc 3


comment eny like
h1:35:respawn:/etc/init.d/init.cssd run >/dev/null 2>&1

Thursday, October 1, 2009

ASM Installation.

http://www.oracle-base.com/articles/10g/ASMUsingASMLibAndRawDevices.php

Sunday, August 30, 2009

Automating Database Startup and Shutdown on Linux

Automating Database Startup and Shutdown on Linux

With Oracle 10g, Oracle switched from recommending the "su" command to the "rsh" command. In Oracle 10g release 2, the dbstart command includes an automatic start of the listener, so there are some differences between the two versions, but the following represents the preferred method for Oracle 10g.

Once the instance is created, edit the "/etc/oratab" file setting the restart flag for each instance to 'Y'.
TSH1:/u01/app/oracle/product/9.2.0:Y
Next, create a file called "/etc/init.d/dbora" as the root user, containing the following.
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.

ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
#
# Change the value of ORACLE to the login name of the
# oracle owner at your site.
#
ORACLE=oracle

PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH
#
if [ ! "$2" = "ORA_DB" ] ; then
if [ "$PLATFORM" = "HP-UX" ] ; then
remsh $HOST -l $ORACLE -n "$0 $1 ORA_DB"
exit
else
rsh $HOST -l $ORACLE $0 $1 ORA_DB
exit
fi
fi
#
case $1 in
'start')
$ORACLE_HOME/bin/dbstart $ORACLE_HOME
;;
'stop')
$ORACLE_HOME/bin/dbshut $ORACLE_HOME
;;
*)
echo "usage: $0 {start|stop}"
exit
;;
esac
#
exit
Use the chmod command to set the privileges to 750.
chmod 750 /etc/init.d/dbora
Associate the dbora service with the appropriate run levels and set it to auto-start using the following command.
chkconfig --level 345 dbora on
The relevant instances should now startup/shutdown automatically at system startup/shutdown.

This method relies on the presence of an RSH server, which requires additional packages and configuration.
# Install the rhs and rsh-server packages from the OS CD/DVD.
rpm -Uvh --force rsh-*

# Enable rsh and rlogin.
chkconfig rsh on
chkconfig rlogin on
service xinetd reload
This can be quite problematic when attempting to use this method under FC5 and FC6, where rsh is deprecated. As a result, I prefer to use the "su" command method.

su $ORACLE $0 $1 ORA_DB

This method can also be used for 11g databases that are not using ASM or RAC.

Known Issues
When using Oracle 10g Release 2, calling dbstart might result in the following error message:

Failed to auto-start Oracle Net Listener using /ade/vikrkuma_new/oracle/bin/tnslsnr

This is due to a hard coded path in the dbstart script. To correct this, edit the "$ORACLE_HOME/bin/dbstart" script and replace the following line (approximately line 78):
ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
With this:
ORACLE_HOME_LISTNER=$ORACLE_HOME
The dbstart script shold now start the listener as expected.

For more information see:


my testing result for ORHEL4

#!/bin/sh
#kconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.

ORACLE_HOME=/u01/app/oracle/product/10.2.0/db
#
# Change the value of ORACLE to the login name of the
# oracle owner at your site.
#
ORACLE=oracle

PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME PATH

# set the asm device permission

chown oracle:dba /dev/hdb5
chown oracle:dba /dev/hdb6

case $1 in
'start')
su - oracle -c dbstart $ORACLE_HOME
;;
'stop')
su - oracle -c dbshut $ORACLE_HOME
;;
*)
echo "usage: $0 {start|stop}"
exit
;;
esac

exit

Create the Database Control Repository and setup the OC4J Application Server

Create the Database Control Repository and setup the OC4J Application Server

Make sure, that you can connect to the Repository Database (Test it with SQL*Plus). Examples for Setup Files can be found here:

Windows

Linux

LISTENER.ORA listener.ora
SQLNET.ORA sqlnet.ora
TNSNAMES.ORA tnsnames.ora

Now start the Oracle EM dbconsole Build Script ($ORACLE_HOME/bin/emca for Linux and $ORACLE_HOME\Bin\emca.bat for Windows).

$ emca -repos create
$ emca -config dbcontrol db

STARTED EMCA at Fri May 14 10:43:22 MEST 2004
Enter the following information about the database
to be configured.


Listener port number: 1521
Database SID:
AKI1
Service name:
AKI1.WORLD
Email address for notification:
martin dot zahn at akadia dot ch
Email gateway for notification:
mailhost
Password for dbsnmp:
xxxxxxx
Password for sysman:
xxxxxxx
Password for sys:
xxxxxxx

---------------------------------------------------------
You have specified the following settings

Database ORACLE_HOME: /opt/oracle/product/10.1.0
Enterprise Manager ORACLE_HOME: /opt/oracle/product/10.1.0

Database host name ..........: akira
Listener port number .........: 1521
Database SID .................: AKI1
Service name .................: AKI1
Email address for notification: martin dot zahn at akadia dot ch
Email gateway for notification: mailhost
---------------------------------------------------------
Do you wish to continue? [yes/no]: yes
AM oracle.sysman.emcp.EMConfig updateReposVars
INFO: Updating file ../config/repository.variables ...

Now wait about 10 Minutes to complete!

M oracle.sysman.emcp.EMConfig createRepository
INFO: Creating repository ...
M oracle.sysman.emcp.EMConfig perform
INFO: Repository was created successfully
M oracle.sysman.emcp.util.PortQuery findUsedPorts
INFO: Searching services file for used port
AM oracle.sysman.emcp.EMConfig getProperties
...........
...........
INFO: Starting the DBConsole ...
AM oracle.sysman.emcp.EMConfig perform
INFO: DBConsole is started successfully
INFO: >>>>>>>>>>> The Enterprise Manager URL is http://akira:5500/em <<<<<<<<<<<
Enterprise Manager configuration is completed successfully
FINISHED EMCA at Fri May 14 10:55:25 MEST 2004

Try to connect to the database Control

http://akira:5500/em

If you look at the installed schemas, you can now find the SYSMAN schema, which is the database Control Repository.

Troubleshooting

If you have troubles to connect, check your local configuration which can be found in $ORACLE_HOME/_. For Example our DbConsole Setup Directory looks as follows:

$ pwd
/opt/oracle/product/10.1.0/akira_AKI1/sysman/config

$
ls -l
-rw-r--r-- b64InternetCertificate.txt
-rw-r--r-- emagentlogging.properties
-rw-r--r-- emd.properties
-rw-r--r-- emomsintg.xml
-rw-r--r-- emomslogging.properties
-rw-r--r-- emoms.properties
-rw-r--r-- OUIinventories.add

The most important file is emoms.properties, where you can find all the configuration parameters.

#Fri May 14 10:54:49 CEST 2004
oracle.sysman.emSDK.svlt.ConsoleServerName=
akira_Management_Service
oracle.sysman.eml.mntr.emdRepPwd=0b878f6184e8319d
emdrep.ping.pingCommand=/bin/ping
oracle.sysman.eml.mntr.emdRepPort=1521
oracle.sysman.eml.mntr.emdRepDBName=AKI1.WORLD
oracle.sysman.emSDK.svlt.ConsoleMode=standalone
oracle.sysman.emRep.dbConn.statementCacheSize=30
oracle.sysman.db.isqlplusUrl=
http\://akira\:5560/isqlplus/dynamic
oracle.sysman.emSDK.svlt.ConsoleServerPort=5500
oracle.sysman.eml.mntr.emdRepRAC=FALSE
oracle.sysman.emSDK.emd.rt.useMonitoringCred=true
oracle.sysman.eml.mntr.emdRepPwdEncrypted=TRUE
oracle.sysman.db.isqlplusWebDBAUrl=
http\://akira\:5560/isqlplus/dba/dynamic
oracle.sysman.emSDK.svlt.ConsoleServerHost=akira
oracle.sysman.emSDK.svlt.ConsoleServerHTTPSPort=5500
oracle.sysman.eml.mntr.emdRepServer=akira
oracle.sysman.eml.mntr.emdRepSID=AKI1
oracle.sysman.emSDK.sec.ReuseLogonPassword=true
oracle.sysman.eml.mntr.emdRepConnectDescriptor=
(DESCRIPTION\=(ADDRESS_LIST\=
(ADDRESS\=(PROTOCOL\=TCP)(HOST\=akira)(PORT\
=1521)))(CONNECT_DATA\=(SERVICE_NAME\=AKI1)))
oracle.sysman.eml.mntr.emdRepUser=SYSMAN
oracle.sysman.db.adm.conn.statementCacheSize=2
oracle.sysman.db.perf.conn.statementCacheSize=30

Automatically start and stop the DB-Console

$ emctl start dbconsole
$ emctl stop dbconsole
$ emctl status dbconsole

Oracle Enterprise Manager 10g Database
Control Release 10.1.0.2.0
Copyright (c) 1996, 2004 Oracle Corporation.
All rights reserved.
http://akira:5500/em/console/aboutApplication
Oracle Enterprise Manager 10g is running.
---------------------------------------------------
Logs are generated in directory
/opt/oracle/product/10.1.0/akira_AKI1/sysman/log

Friday, August 28, 2009

E-mail sending with authentication

SMTP with authentication

PROCEDURE TEST_MAIL
is
crlf VARCHAR2(2):= UTL_TCP.CRLF;
connection utl_smtp.connection;
mailhost VARCHAR2(30) := 'XX.XX.XX.XX';
header VARCHAR2(1000);
str_user_name VARCHAR2(200);
BEGIN
connection := utl_smtp.open_connection(mailhost,25);
header:= 'Date: 'TO_CHAR(SYSDATE - 19800/86400 ,'dd Mon yyyy hh24:mi:ss')crlf
'From: ''upul@dpmco.com'crlf
'Subject: ''Pending Progress Report(s) Notification - 'initcap(str_user_name)'.'crlf
'To: ''thiranagamage@gmail.com'crlf
'CC: ''upul@dpmco.com'crlf
'CC: ''pradeepi@dpmco.com';
--
-- Handshake with the SMTP server
--
utl_smtp.ehlo(connection, mailhost);
utl_smtp.command( connection, 'AUTH LOGIN');
utl_smtp.command( connection, utl_raw.cast_to_varchar2( utl_encode.base64_encode( utl_raw.cast_to_raw( 'upul@dpmco.com' ))) );
utl_smtp.command( connection, utl_raw.cast_to_varchar2( utl_encode.base64_encode( utl_raw.cast_to_raw( 'XXXX' ))) );


utl_smtp.mail(connection, 'upul@dpmco.com');
utl_smtp.rcpt(connection, 'thiranagamage@gmail.com');
utl_smtp.rcpt(connection, 'upul@dpmco.com');
utl_smtp.rcpt(connection, 'pradeepi@dpmco.com');
utl_smtp.open_data(connection);
--
-- Write the header
--
utl_smtp.write_data(connection, header);
--
-- The crlf is required to distinguish that what comes next is not simply part of the header..
--
utl_smtp.write_data(connection, crlf 'Please do not reply to this message. This is an unmonitored address for outgoing mail notification only.');
utl_smtp.close_data(connection);
utl_smtp.quit(connection);
commit;
END;

Tuesday, August 25, 2009

Enterprice manager configurationhapter

Getting Started with Oracle Enterprise Manager

Purpose

The Oracle Universal Installer installs Oracle Enterprise Manager Database Control when you install the Oracle software. Enterprise Manager Database Control provides a Web-based interface that you can use to manage your Oracle instance and database.

Topics

This chapter discusses the following:

Starting the Enterprise Manager dbconsole Process
Accessing Enterprise Manager Database Control
Granting EM Administrative Privileges to Other Users
Defining Blackout Periods
Setting Preferred Credentials

Starting the Enterprise Manager dbconsole Process


The dbconsole process must be started for you to access Oracle Enterprise Manager Database Control from a client browser. The dbconsole process is automatically started after installation. If the process is not started, you can manually start it at the command line as follows:

1.

Log on to the operating system as the oracle user. Issue the following command to start the dbconsole process:


emctl start dbconsole

Move your mouse over this icon to see the image

2.

You can check the status of the dbconsole process by issuing the following command:


emctl status dbconsole

Move your mouse over this icon to see the image



How to correct known errors

Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
Updating /u01/app/oracle/product/10.2.0/db/localhost.localdomain_dpg/sysman/config/emd.properties...resetTZ failed.
The agentTZRegion in:
/u01/app/oracle/product/10.2.0/db/localhost.localdomain_dpg/sysman/config/emd.properties
is not in agreement with what the agent thinks it should be.
Fix your environment.

Pick a TZ value that corresponds to time zone settings listed in:
/u01/app/oracle/product/10.2.0/db/sysman/admin/supportedtzs.lst