Total Pageviews

Friday, 21 December 2012

How to change system date in Linux

To change system date in REDHAT linux, first login using root user and type:-

$date MMDDhhmmYYYY

For example: i want to change my system date to Dec 21 2012, 9:35 AM i will type:-

$date 122109352012

Fri Dec 21 09:35:00 IST 2012

It’s simple

Note:
MM – month
DD – day
YYYY – year
hh – hour is based on 24 hour
mm – minutes

Wednesday, 19 December 2012

SWITCH LOGFILE vs ARCHIVELOG CURRENT

 Oracle has two ways to force a logfile switch, ALTER SYSTEM SWITCH LOGFILE and ALTER SYSTEM ARCHIVELOG CURRENT. 
What is the difference between ALTER SYSTEM SWITCH LOGFILE and ALTER SYSTEM ARCHIVELOG CURRENT, and when do I use each?

Yes, both ALTER SYSTEM SWITCH LOGFILE and ALTER SYSTEM ARCHIVELOG CURRENT will force a log switch, but they do it in different ways!   
Both the SWITCH LOGFILE and ARCHIVELOG CURRENT write a quiesce checkpoint, a firm place whereby that last redo log is a part of the hot backup, but ARCHIVELOG CURRENT waits for the writing to complete.  This can take several minutes for multi-gigabyte redo logs.  
Conversely, the ALTER SYSTEM SWITCH LOGFILE command is very fast and returns control to the caller in less than a second while ALTER SYSTEM ARCHIVELOG CURRENT pauses.  
As we see below, the ALTER SYSTEM SWITCH LOGFILE is fast because it does not wait for the archiver process (ARCH) to complete writing the online redo log to the archivelog log filesystem:
  1. It issues database checkpoint
  2.  It immediately starts writing to the next redo log
  3.  In the background, the “switch logfile” command tells the ARCH background process to copy the “old” redo log file to the redo log filesystem.  
Here are the important differences between ALTER SYSTEM SWITCH LOGFILE and ALTER SYSTEM ARCHIVELOG CURRENT:
  •  RAC:  If you are running RAC, the ALTER SYSTEM ARCHIVELOG CURRENTwill switch the logs on all RAC nodes (instances), whereas ALTER SYSTEM SWITCH LOGFILE will only switch he logfile on the instance where you issue the switch command.  Hence, ALTER SYSTEM ARCHIVELOG CURRENT is a best practice for RAC systems.
  • ALTER SYSTEM  SWITCH LOGFILE is asynchronous:  This command is fast to return to the invoking program because the writing of the redo log to the OS filesystem is done in the background.  There is a very small risk in cases where the ARCH process cannot complete writing the redo log, such as cases where the OS archivelog file directory is out of space.  It is also risky because the calling script may move on to a subsequent step, assuming that the redo has been written.  Some scripts will place a SLEEP 60 command in their backup script to allow time for the redo to complete writing, but this is not a best practice.  
  • ALTER SYSTEM ARCHIVELOG CURRENT is synchronous:  This is faster to return because this command waits until the online redo log has completed the writing of the redo log file to the filesystem.  This command is safer because it waits for the OS to acknowledge (ACK) that the redo log has been successfully written.  Hence, ALTER SYSTEM ARCHIVELOG CURRENT is the best practice for production backup scripts with RMAN.
  • Argument required:  The ALTER SYSTEM ARCHIVELOG CURRENTallows you to specify the thread to archive while the ALTER SYSTEM SWITCH LOGFILE archives only the current thread.  If you do not pass the thread parameter, Oracle will archive all full online redo logs.   

Tuesday, 18 December 2012

Convert MSSM to automatic segment space management (ASSM)?


The segment space management that you specify at tablespace creation time applies to all segments subsequently created in the tablespace.

You cannot change the segment space management mode of a existing tablespace.

You cannot alter a locally managed tablespace to a locally managed temporary tablespace, nor can you change its method of segment space management.

To Convert the segment space management mode of a tablespace , you have to re-create the tablespace :
  1. Export the contents of the tablespace
  2. Drop the Tablespace which needed to be converted
  3. Create tablespace with the desired segment space management mode
  4. Import the contents of the the dump file to the newly created tablespace

Friday, 7 December 2012

ORA-01102: cannot mount database in EXCLUSIVE mode

SQL> Alter database mount;
Alter database mount
*
ERROR at line 1:
ORA-01102: cannot mount database in EXCLUSIVE mode
SQL>


Cause: An instance tried to mount the database in exclusive mode, but some other instance has already mounted the database in exclusive or parallel mode. 

Action: Either mount the database in parallel mode or shut down all other instances before mounting the database in exclusive mode. 
database is started in EXCLUSIVE mode by default. Therefore, the 
ORA-01102 error is misleading and may have occurred due to one of the 
following reasons: 
  • - there is still an "sgadef<sid>.dbf" file in the "ORACLE_HOME/dbs" directory 
  • - the processes for Oracle (pmon, smon, lgwr and dbwr) still exist 
  • - shared memory segments and semaphores still exist even though the database has been shutdown 
  • - there is a "ORACLE_HOME/dbs/lk<sid>" file 
The "lk<sid>" and "sgadef<sid>.dbf" files are used for locking shared memory.  It seems that even though no memory is allocated, Oracle thinks memory is  still locked. By removing the "sgadef" and "lk" files you remove any knowledge oracle has of shared memory that is in use. Now the database can start.

Solution:

SQL> shu immediate;
ORA-01507: database not mounted

ORACLE instance shut down.
SQL> exit;
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

[oracle@DBA-RHEL4-10G ~]$ ps -ef | grep ora_ | grep $ORACLE_SID

oracle 13123 1 0 02:29 ? 00:00:00 ora_pmon_test85
oracle 13125 1 0 02:29 ? 00:00:01 ora_psp0_test85
oracle 13127 1 0 02:29 ? 00:00:00 ora_mman_test85
oracle 13129 1 0 02:29 ? 00:00:22 ora_dbw0_test85
oracle 13131 1 0 02:29 ? 00:00:19 ora_lgwr_test85
oracle 13133 1 0 02:29 ? 00:02:07 ora_ckpt_test85
oracle 13135 1 0 02:29 ? 00:00:02 ora_smon_test85
oracle 13137 1 0 02:29 ? 00:00:00 ora_reco_test85
oracle 13139 1 0 02:29 ? 00:00:00 ora_cjq0_test85
oracle 13141 1 0 02:29 ? 00:00:01 ora_mmon_test85
oracle 13143 1 0 02:29 ? 00:00:02 ora_mmnl_test85
oracle 13145 1 0 02:29 ? 00:00:00 ora_d000_test85
oracle 13147 1 0 02:29 ? 00:00:00 ora_s000_test85
oracle 13151 1 0 02:29 ? 00:00:00 ora_qmnc_test85
oracle 13218 1 0 02:29 ? 00:00:00 ora_q001_test85
oracle 13220 1 0 02:29 ? 00:00:00 ora_q002_test85
oracle 18163 1 0 21:29 ? 00:00:00 ora_j000_test85
[oracle@DBA-RHEL4-10G ~]$
[oracle@DBA-RHEL4-10G ~]$ kill -9 <process-list>
[oracle@DBA-RHEL4-10G ~]$

Verify that the "$ORACLE_HOME/dbs/lk<sid>" file does not exist .If it is present copy it to some temp location for safety and delete it from the location  $ORACLE_HOME/dbs/

Now start the instance.

[oracle@DBA-RHEL4-11G dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 6 21:32:46 2012

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 587202560 bytes
Fixed Size 2022504 bytes
Variable Size 163578776 bytes
Database Buffers 415236096 bytes
Redo Buffers 6365184 bytes
Database mounted.
SQL> Alter database open;

Database altered.

SQL>