Thursday, May 5, 2016

Copy Archive log from ASM to File System (vice-versa)

Copy Archive log from ASM to File System (172.xx.xxx.60)
=================================
RMAN> copy archivelog '+fra/testbk/archivelog/2016_04_27/thread_1_seq_169.257.910279337' to '/u02/thread_1_seq_169.257.910279337';
RMAN> copy archivelog '+fra/testbk/archivelog/2016_04_27/thread_1_seq_170.377.910279543' to '/u02/thread_1_seq_170.377.910279543';
RMAN> copy archivelog '+fra/testbk/archivelog/2016_04_27/thread_1_seq_171.380.910287329' to '/u02/thread_1_seq_171.380.910287329';


Transfer 172.xx.xxx.60 to 172.xx.xx.45
==============================
oracle@testbk [/u02]$scp thread_1_seq_169.257.910279337 oracle@172.xx.xxx.45:/u02/seq_169.bak
Password:
thread_1_seq_169.257.910279337                                        100%  102KB 102.0KB/s 102.0KB/s   00:00
oracle@testbk [/u02]$scp thread_1_seq_170.377.910279543 oracle@172.xx.xxx.45:/u02/seq_170.bak
Password:
thread_1_seq_170.377.910279543                                        100%  492KB 492.0KB/s 492.0KB/s   00:00
oracle@testbk [/u02]$scp thread_1_seq_171.380.910287329 oracle@172.xx.xxx.45:/u02/seq_171.bak
Password:
thread_1_seq_171.380.910287329                                        100%   80MB  39.9MB/s  39.2MB/s   00:02
oracle@testbk [/u02]$


Copy Archive log from File System to ASM (172.xx.xxx.45)
=================================
ASMCMD> cp /u02/seq_169.bak +fra/dcstdb/archivelog/2016_04_27/seq_169.bak
copying /u02/seq_169.bak -> +fra/dcstdb/archivelog/2016_04_27/seq_169.bak
ASMCMD> cp /u02/seq_170.bak +fra/dcstdb/archivelog/2016_04_27/seq_170.bak
copying /u02/seq_170.bak -> +fra/dcstdb/archivelog/2016_04_27/seq_170.bak
ASMCMD> cp /u02/seq_171.bak +fra/dcstdb/archivelog/2016_04_27/seq_171.bak

copying /u02/seq_171.bak -> +fra/dcstdb/archivelog/2016_04_27/seq_171.bak

Monday, April 25, 2016

RMAN Backup in Disk

RMAN Backup in Disk

dt=`date '+%d%m%Y%H%M'`
rman target rman_bkp_user/password <<eof
sql 'alter system archive log current';
run{
allocate channel c1  type disk;
allocate channel c2  type disk;
allocate channel c3  type disk;
allocate channel c4  type disk;
allocate channel c5  type disk;
allocate channel c6  type disk;
allocate channel c7  type disk;
backup AS COMPRESSED BACKUPSET full database tag T24_DB_$dt format '/db_rmanbackup/t24_db_%p_%s_$dt.bkp';
sql 'alter system archive log current';
backup current controlfile tag T24_CTL_$dt format '/db_rmanbackup/t24_ctl_%p_%s_$dt.bkp';
backup spfile tag T24_SPF_$dt format '/db_rmanbackup/t24_spf_%p_%s_$dt.bkp'  ;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
release channel c7;
}
eof

Note: rman_bkp_user must have SYSDBA privilege to run RMAN backup.

Database DROP (Without DBCA)

Database DROP (Without DBCA)

TRY 1:
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

SQL>
SQL> drop database;
drop database
*
ERROR at line 1:
ORA-01586: database must be mounted EXCLUSIVE and not open for this operation


TRY 2:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount exclusive
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.

Total System Global Area 8551575552 bytes
Fixed Size                  2222664 bytes
Variable Size            4194305464 bytes
Database Buffers         4345298944 bytes
Redo Buffers                9748480 bytes
Database mounted.
SQL> drop database
  2  ;
drop database
*
ERROR at line 1:
ORA-12719: operation requires database is in RESTRICTED mode


TRY 3:
SQL> startup nomount;
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.

Total System Global Area 8551575552 bytes
Fixed Size                  2222664 bytes
Variable Size            4194305464 bytes
Database Buffers         4345298944 bytes
Redo Buffers                9748480 bytes
SQL> drop database;
drop database
*
ERROR at line 1:
ORA-01507: database not mounted


SQL> alter database mount;

Database altered.

SQL> drop database;
drop database
*
ERROR at line 1:
ORA-12719: operation requires database is in RESTRICTED mode


TRY 4:
SQL> startup mount restrict;
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.

Total System Global Area 8551575552 bytes
Fixed Size                  2222664 bytes
Variable Size            4194305464 bytes
Database Buffers         4345298944 bytes
Redo Buffers                9748480 bytes
Database mounted.
SQL> drop database;

Database dropped.

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL>

Monday, March 14, 2016

ORA-10873:file 1 needs to be either taken out of backup mode or media recovered ORA-01110: data file 1: '+DATA / testbk/ datafile/ system.256.897496663'

ORA-10873:file 1 needs to be either taken out of backup mode or media recovered  ORA-01110: data file 1: '+DATA / testbk/ datafile/ system.256.897496663'

Cause: ORA-10873
In case you force fully trying to shutdown database with “shutdown abort” OR instance crashes for some reason OR database have not been shutdown gracefully than you would encountered “ORA-10873” error while next startup of your database.

SQL> startup
ORACLE instance started.

Total System Global Area 5127602176 bytes
Fixed Size                  2214432 bytes
Variable Size            4580181472 bytes
Database Buffers          536870912 bytes
Redo Buffers                8335360 bytes
Database mounted.
ORA-10873: file 1 needs to be either taken out of backup mode or media recovered
ORA-01110: data file 1: '+DATA/testbk/datafile/system.256.897496663'

Solution:  Issue following SQL command in order to move out database from hot backup mode:
SQL> alter database end backup;
alter database end backup
*
ERROR at line 1:
ORA-01260: warning: END BACKUP succeeded but some files found not to be in
backup mode

OR

SQL> alter tablespace system end backup;

Open database
SQL> alter database open;
Database altered.

ORA-01149: cannot shutdown - file 1 has online backup set, ORA-01110: data file 1: '+DATA / testbk/ datafile/ system.256.897496663'

ORA-01149: cannot shutdown - file 1 has online backup set, ORA-01110: data file 1: '+DATA / testbk/ datafile/ system.256.897496663'

Oracle Error: While shutdown your database you may encounter following oracle error.
SQL> shutdown immediate
ORA-01149: cannot shutdown - file 1 has online backup set
ORA-01110: data file 1: '+DATA/testbk/datafile/system.256.897496663'

Cause: If you try to shutdown database when database is in hot backup mode, you will encounter above mentioned error. Kindly verify with your team mates with hot backup activity, Oracle will not allow you to shut down your database in above scenario, i.e. shutdown, shutdown immediate, shutdown transactional OR startup force will be failed with ORA-01149 oracle error.

Root cause detection: 
Following query will help you to understand which oracle tablespace datafile is in hot backup mode.
SQL> select a.tablespace_name, b.status from dba_data_files a, v$backup b where a.file_id=b.file# order by tablespace_name;

TABLESPACE_NAME                STATUS
------------------------------ ------------------
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24INDEX                    NOT ACTIVE
SYSAUX                         NOT ACTIVE
SYSTEM                         ACTIVE
UNDOTBS1                       NOT ACTIVE
USERS                          NOT ACTIVE

10 rows selected.

Note: Status of the SYSTEM datafile seems to be active. i.e. hot backup mode.


Solution:
Issue following SQL command in order to move out database from hot backup mode:
SQL> alter database end backup;
alter database end backup
*
ERROR at line 1:
ORA-01260: warning: END BACKUP succeeded but some files found not to be in
backup mode

OR

SQL> alter tablespace system end backup;


Shutdown database
SQL> shutdown abort/immediate
ORACLE instance shut down.
SQL>

Open database
SQL> startup
ORACLE instance started.

Total System Global Area 5127602176 bytes
Fixed Size                  2214432 bytes
Variable Size            4580181472 bytes
Database Buffers          536870912 bytes
Redo Buffers                8335360 bytes
Database mounted.
Database opened.
SQL>
SQL> select a.tablespace_name, b.status from dba_data_files a, v$backup b where a.file_id=b.file# order by tablespace_name;

TABLESPACE_NAME                STATUS
------------------------------ ------------------
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24DATA                     NOT ACTIVE
NBLT24INDEX                    NOT ACTIVE
SYSAUX                         NOT ACTIVE
SYSTEM                         NOT ACTIVE
UNDOTBS1                       NOT ACTIVE
USERS                          NOT ACTIVE
10 rows selected.
SQL>