Saturday, November 18, 2006
Oracle RAC 10G -- Learning to know
I found few of the books which helped me a lot,
1. Oracle Online Documenation
2. Oracle 10g Grid & Real Application Clusters
Tuesday, October 17, 2006
Killing a User’s Session
2* WHERE username='user_name';
SID SERIAL#
----------------
10 32
SQL> ALTER SYSTEM KILL SESSION '10, 32’;
System altered.
If the session you want to kill is involved in a long operation, such as a lengthy rollback, Oracle will inform you that the session is marked for kill and it will be killed after the operation is completed.
When Oracle kills a session, it rolls back all ongoing transactions and releases all session locks.
If the UNIX process of the user is killed, the Oracle session will most likely be killed also, but that isn’t the most graceful way to end a session.
OS Level - If you want to End the section - USE KILL
If you think you must kill a user’s UNIX session, and the Oracle KILL SESSION command isn’t working, or it’s taking a long time, you can terminate the session rather abruptly by using the UNIX kill command as follows.
$ kill -9 345678
Use the SQL Syntax - to find the - USER
SQL> SELECT process,sid,serial# FROM v$session
WHERE username='&user';
Enter value for user: SOMEUSER
old 2: username='&user'
new 2: username='SOMEUSER'
PROCESS SID SERIAL#
-----------------------------------
2920:2836 10 34
How about working with WINDOWS?
ORAKILL - Utility
Oracle user’s session on Windows, can use the ORAKILL utility, which will kill a specific thread under the Oracle .exe process.
How do you find out what that user’s thread is?
SQL> SELECT sid, spid as thread, osuser, s.program
2 FROM v$process p, v$session s
3* WHERE p.addr = s.paddr;
SID THREAD OSUSER PROGRAM
-------------------------------------------------------------
1 1192 SYSTEM ORACLE.EXE
2 1420 SYSTEM ORACLE.EXE
3 1524 SYSTEM ORACLE.EXE
4 1552 SYSTEM ORACLE.EXE
5 1528 SYSTEM ORACLE.EXE
6 1540 SYSTEM ORACLE.EXE
7 1580 SYSTEM ORACLE.EXE
8 1680 SYSTEM ORACLE.EXE
9 2948 NETBSA\user sqlplusw.exe
10 4072 NETBSA\user sqlplusw.exe
10 rows selected.
Find the thread number where you want to kill...
C:> orakill 2948
Tuesday, May 23, 2006
Unix Commands that always usefull
ps -ef grep lsnr
glance -j 1
du -k sort -n
du -sk * sort -nrhead
df -k grep /bkdump
ifconfig -a
du -sh *
ipcs -m grep ora
Sunday, April 23, 2006
What is blocking at the DB Level
***************************************************
SQL> select s1.username '@' s1.machine
2 ' ( SID=' s1.sid ' ) is blocking '
3 s2.username '@' s2.machine ' ( SID=' s2.sid ' ) ' AS blocking_status
4 from v$lock l1, v$session s1, v$lock l2, v$session s2
5 where s1.sid=l1.sid and s2.sid=l2.sid
6 and l1.BLOCK=1 and l2.request > 0
7 and l1.id1 = l2.id1
8 and l2.id2 = l2.id2 ;
BLOCKING_STATUS
--------------------------------------------------------------------------------
NAMECH@amsig4c ( SID=88 ) is blocking KDD_WEB@amsig4c ( SID=32 )
NAMECH@amsig4c ( SID=88 ) is blocking KDD_WEB@amsig4c ( SID=36 )
NAMECH@amsig4c ( SID=88 ) is blocking KDD_WEB@amsig4c ( SID=45 )
NAMECH@amsig4c ( SID=88 ) is blocking KDD_WEB@amsig4c ( SID=49 )
NAMECH@amsig4c ( SID=88 ) is blocking KDD_WEB@amsig4c ( SID=72 )
NAMECH@amsig4c ( SID=88 ) is blocking KDD_WEB@amsig4c ( SID=86 )
NAMECH@amsig4c ( SID=88 ) is blocking KDD_WEB@amsig4c ( SID=90 )
NAMECH@amsig4c ( SID=88 ) is blocking KDD_WEB@amsig4c ( SID=99 )
NAMECH@amsig4c ( SID=88 ) is blocking KDD_WEB@amsig4c ( SID=123 )
NAMECH@amsig4c ( SID=88 ) is blocking KDD_WEB@amsig4c ( SID=141 )
10 rows selected.
SQL> alter system kill session '88,24356';
System altered.
SQL> select * from v$lock where block <> 0 or request <> 0;
no rows selected
************************************
Please let me know your experience in handling this issue.
Thursday, March 16, 2006
Logging In As a Different User – When you don’t know the Password
In a case like this, you can change the password of a user temporarily and use the new password to get in as that user. Before you change a user’s password, get the original encrypted password, which you can use to reset the user’s password back after you’re done. Here’s an example:
SQL> SELECT 'alter user tester identified by values 'password';'
2 FROM dba_users
3* WHERE username='TESTER';
'ALTERUSERTESTERIDENTIFIED
---------------------------------------------------------
alter user tester identified by values 1825ACAA229030F1;
SQL>
Now change the password of user tester so you can log in as that user:
SQL> ALTER USER tester IDENTIFIED BY newpassword;
When you’re done using the tester user account, use the ALTER USER statement again to change user tester’s password back to its original value. Make sure you enclose the encrypted password in single quotes.
SQL> ALTER USER tester IDENTIFIED BY VALUES '1825ACAA229030F1';
User altered.
Friday, February 24, 2006
What would be the first thing you would do if an end user complains that performance is poor?
As for the answer to the question, one should touch upon all these points:
- Check alert log, for any errors and UN even entries
- Check for archive log destination/file system full
- Check for database locks # Click here for a notes on locks
- Check server performance (CPU/IO)
- Check network performance
- Check if statistics is up to date
- If new SQL, then tune SQL (maybe take trace)
- Check if any parameters have been modified recently
- Check if any new updates as been done from the Application team.
And few more from Oracle Online Documentation as well
1) Identifying and Gathering Data on Resource-Intensive SQL # Oracle Doc
2) Oracle9i Database Performance Tuning Guide and Reference # Oracle Doc
I recommend reading the documents from Oracle, which give clear understanding of all the above. Please add lines if you I miss something which is useful.
Saturday, February 18, 2006
Some SQL Statements - For Day to Day tasks
select 'drop 'object_type' 'object_namedecode(object_type,'TABLE','
cascade constraints;',';')
from user_objects
where object_type!='INDEX'/
********************************************************************
PCT_FREE, PCT_USED
SQL> select TABLE_NAME, PCT_FREE, PCT_USED, EMPTY_BLOCKS, CHAIN_CNT from dba_tables
2 where CHAIN_CNT > 0;
TABLE_NAME PCT_FREE PCT_USED EMPTY_BLOCKS CHAIN_CNT
------------------------------ ---------- ---------- ------------ ----------
BBN_MAS_LIQ_DET_TSY_TMP 10 40 1977 392
ORD_LEDGER 10 40 1982 6609
************************************************************************
SQL> select object_name,object_type from user_objects where status='INVALID';
******************************************************************************
Friday, February 10, 2006
Oracle Applications DBA (Apps DBA)
In my searches I found this reliable site for Applications http://www.appsdba.com/ hope this will be very useful for Apps DBA.
I always found of increasing my errands and promoting myself with the market. But what Apps DBA does? Is this the question I always asks myself and hope this is the most common question for a core DBA who wants to upgrade for Apps? Yes! Hope so! :- )
I want to solve this in my blog – hope it helps to know the responsibilities of being an Apps DBA.
What duties, if any, are different for an Apps DBA versus those of an Oracle 8/9i DBA?
Oracle APPS DBA's duties are almost same as of Oracle DBA but your work will be more specific to the Architecture (or I should say Environment) and OFA of Oracle Application. Apart from that there are few more things you should know like applying patches or adadmin utility and some basic functionality of SYSADMIN responsibility of APPS.
An APPs DBA knows all that a regular DBA knows plus the following:
These are two core answers I found for being a Apps DBA.
Resolving a Database Failure
Phase I: Diagnose the problem
Phase II: Restore appropriate files
Phase III: Recover the database
Phase IV: Back up the database
Phase I: Diagnose the problem
The first phase is to research the nature of the failure. Use V$ views, data dictionary views, trace and log files, basic operating system commands and Oracle Enterprise Manager to diagnose the problem.
- Open database, offline tablespace recovery
- Open database, offline tablespace, individual datafile recovery
- Cancel-based recovery
- Time-based recovery
- Change-based recovery
Phase II: Restore Appropriate Files
Before you perform a recovery scenario, determine what files to restore and what state the instance and database must be in to perform the recovery. Remember that the objective is to minimize down time and loss of data, so do not restore files if it is not necessary.
Phase III: Recover the Database
Once the appropriate files are restored, initiate your recovery operation. After completing the recovery, note any proactive measures that can be taken to prevent that type of failure in the future.
Phase IV: Back up the Database
Not all recovery operations require a database backup when they are complete. However, determine whether your database needs to backed up and, if so, perform another backup.
Sunday, February 05, 2006
Archive Log
sql/>shutdown normal/immediate/transactional (You can use any value)
sql/>startup mount
sql/>alter database archivelog
sql/>alter database open
Go for Full Database backup
Keep in mind a user must have ALTER SYSTEM PRIVILEGE to alter the archivelog mode of the database.
Setting the database in Archivelog mode doesnot enable the Archiver (ARCN) process!
AUTOMATIC & MANUAL Archiving
Set the parameter file for LOG_ARCHIVE_START=TRUE
Hmm mean while you can do multiple arcn process
LOG_ARCHIVE_MAX_PROCESSES
And a maximum of ten ARCN processes can be specified and its dynamic
Sql/>alter system set LOG_ARCHIVE_MAX_PROCESSES=3;
Well if you find more about this let me know.
Thursday, February 02, 2006
Team Oracle
http://www.oracle.com/cluboracle/teamoracle/index.html
Are you with Oracle Team ???
Flying High with Team Oracle
RMAN Recovery Manager - Oracle 9i
Step 1 :
Create A Seperate Database Or Tablespace For Storing RMAN Catalog.
In This Case We Are Storing The Recovery Catalog In The Same Database.
SQL> Create Tablespace Rman_Tablespace Datafile
2 'C:\Sql\Junept\Datafile\Rman01.dbf' Size 20m Autoextend On Next 1m;
Tablespace created.
Step 2 :
Create A Rman Repository Schema.
SQL> Create User Rman_User Identified By Rman Default Tablespace Rman_Tablespace
2 Temporary Tablespace Temp Quota Unlimited On Rman_Tablespace;
User created.
Step 3 :
Grant Privileges To The Rman User Setting The Default Tablespace To The One Create In Step 1
SQL> Grant Connect,Resource To Rman_User;
Grant succeeded.
SQL> Grant Recovery_Catalog_Owner To Rman_User;
Grant succeeded.
Step 4 :
Create The Catalog Using RMAN
Invoke Rman Utility As Below :
$ORACLE_HOME\Bin> RMAN Catalog Rman_User/Rman@Service
Recovery Manager: Release 9.2.0.1.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
connected to recovery catalog database
recovery catalog is not installed
RMAN>
Now At The Rman Prompt Create The Catalog Into Tablespace Created In Step 1
RMAN> Create Catalog Tablespace Rman_Tablespace;
recovery catalog created
Note : The Execution Of The Above Command Will Create Several Base Tables, View, Synonyms ,
Packages, Etc .
RMAN> Exit
Step 5 :
Now Register Your Database Into The Recovery Catalog.
RMAN_USER SQL> Select * From DB_Database;
no rows selected
The Above Statement Proves That Your Database Is Not Yet Registered Into The Recovery Catalog.
C:\>Rman Target /
Recovery Manager: Release 9.2.0.1.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
connected to target database: JUNEPT (DBID=1185895820)
RMAN> Connect Catalog Rman_User/Rman@Service
connected to recovery catalog database
RMAN> Register Database;
database registered in recovery catalog (A)
starting full resync of recovery catalog
full resync complete
Note : The Above Command Updates All The Base Tables For Storing The Database Information Which Is Resistered.
To Prove The Above Said Issue The Following Commands :
RMAN_User SQL> Select Name From Rc_Database;
RMAN_User SQL> Select Tablespace_Name,Name From Rc_Datafile;
RMAN_User SQL> Select Name From Rc_Redo_Log;
/* The Configuration Of Recovery Catalog Is Completed. */
Tuesday, January 24, 2006
Oracle Interview Questions: Level 1
About Interview Questions on Oracle.
http://get-best.com/IT_Interview_Questions/dbaQA1.htm
http://get-best.com/IT_Interview_Questions/dbaQA2.htm
http://get-best.com/IT_Interview_Questions/dbaQA3.htm
http://get-best.com/IT_Interview_Questions/dbaQA4.htm
For more Technical Questions
http://blogs.ittoolbox.com/database/solutions/archives/006260.asp
Click the above link
Oracle Certification: OCP
Database Administrator: Database Administrators are responsible for administrative activities like installing database, taking backups, managing and fine-tuning performance over the network, and data recovery. They have the knowledge of basic architecture of the Oracle database. Visit Oracle DBA Certification Track page to gain detailed information about the exam, its details, types of questions, and how to prepare for the exam, if you are interested in taking the OCP-DBA certification.
http://www.whizlabs.com/ocp/oracle-dba.html
Oracle 9i DBA Path Details
Oracle Administrator track for Oracle 9i has been divided into the following three levels.
1.Associate Level (2 Exams). You need to clear the following exams:
Introduction to Oracle: SQL and PL/SQL OR
Introduction to Oracle 9i: SQL (online also)
Oracle 9i Database: Fundamentals I
Oracle 9i Database: Fundamentals II
Oracle 9i Database: Performance Tuning
*** To get OCP - Professional Level (2 Exams and one Oracle University hands-on course within the Oracle 9i DBA learning path). You need to clear the following exams:
How to check any deadlock and other locking issues
What a Oracle DBA can be?
"DBA is a Database Administrator who logs onto the multi-user operating system as internal or system with the appropriate password is recognized by the operating system as the rightful owner of resources on the Hard disk drive. This person then becomes the Oracle DBA". --- IVAN BAYROSS
For this I did not get right answer when I premeditated to take this line of work, but latter with perceptive of Oracle’s Workgroup I could able to learn that DBA’s are not only do backup, recover & tune the database but they design the database and more deeper I go I learned the depths of being a DBA. 10 months of expertise of mine and certification from Oracle made me to know the depths of being what a DBA holds.This is the first question always comes when we take up a new vocation – what I can, if I took up this line of work?So i put my solutions in this web log with the various works a DBA can handle.
There are DBAs who focus on logical design and DBAs who focus on physical design; DBAs who specialize in building systems and DBAs who specialize in maintaining and tuning systems; specialty DBAs and general-purpose DBAs.
Indeed, the job of system DBA usually exists only if the organization does not have an official
system administration or systems programming department.
Want to Become an Oracle DBA
Thursday, January 19, 2006
File System re-organization: Oracle Internal Error
Oracle Internal Error:
As a Oracle database administrator, we must keep the file system perfect, to make accessible for end users. Well this augments my issue for the internal error which kept me on toe. So I started to work on this to try with this and almost absolute and reasonable.
Unused columns (Why disorganized & what creates them to drop):- Refer my previous post
SQL> Alter table
SQL>Alter table
Before SQL Statement sets the columns and the next statement drops the columns, but make sure about the constraints on those columns – well why don’t we use cascade option to do this.
SQL>Alter table
And one more important thing must me noted - when you are doing these things, the table is not available to the users.
SQL>Alter index index_name monitoring usage;
SQL>Alter index index_name nomonitoring usage;
SQL>Select * from v$object_usage
Oracle 9.2 on Microsoft Windows 2003 (32 Bit OS)
Internal Error ORA-600[QXIDMACLOB]
We have automated script running daily to do export database for the development server, but to my strange I find Internal Error ORA-600[QXIDMACLOB].
Well this case is repeating from couple of days and I could not able to identify this but latter followed up to metal ink where I could find the correct solution for this
Cause
The error is related to Bug:1805146 and is caused by a data dictionary inconsistency left by the ALTER TABLE SET UNUSED statement.This statement mark/delete entries in the col$ table related to that object but, miss or fail to mark/delete rows in some tables called coltype$, lob$ and partlog$.Causing the inconsistency.
Solution
Use the following workaround:After drop a column, this is marked as UNUSED.In order to avoid this error, customer must drop al unused columns executing the following command:ALTER TABLE DROP UNUSED COLUMNS;If the table is really big, this statement can potentially use a lot of UNDO space.In order to avoid UNDO space errors, customer must use the following statement:ALTER TABLE DROP UNUSED COLUMNS checkpoint 100;Checkpointing cuts down the amount of undo logs accumulated during the drop column operation to avoid running out of rollback segment space.If you do not specify a number (integer) , Oracle sets the default of 512.
*** I tried working on this and could able to solve the problem.
Wednesday, January 18, 2006
Statspack Installation - Steps
Definition made simple: -
The Statspack package is a set of SQL, PL/SQL, and SQL*Plus scripts that allow the collection, automation, storage, and viewing of performance data. Statspack stores the performance statistics permanently in Oracle tables, which can later be used for reporting and analysis. The data collected can be analyzed using Statspack reports, which includes an instance health and load summary page, high resource SQL statements, and the traditional wait events and initialization parameters.
Approximately 64MB is required to install Statspack.
If you install the package in a dictionary-managed tablespace, then you should monitor the space used by the objects created and, if required, adjust the storage clauses of the segments.
*** If you install the package in a locally managed tablespace, then storage clauses are not required, because the storage characteristics are automatically managed.
Start SQL*Plus.
You need to enter default tablespace “Which Oracle recommends ‘TOOLS’
And its asks you to enter Temporary tablespace and that is your “TEMP” and within few minutes your Statspack ready to use.
PERSONALITY TRAITS OF A DBA
This indicates the a DBA should exhibit the following traits:
Self Confidence
Curiosity
Tenacity
Tactful
Self-starter
Detail oriented