Sunday, 17 June 2018

How to Duplicate a database using RMAN backup

Dear DBA-Mates,
Hope you all doing Good!!!
We are back with RMAN database backup and RMAN duplicate database command which we were promised in our last post OracleRMAN Interview Questions and Answers.
Here, simply we are proving the commands for How to take RMAN back and then how to restore as RMAN Duplicate database.
Many of us think how to take rman backup and rman duplicate the database in real scenario because still there are some organizations where RMAN is not
using. But now a day RMAN is very necessary.

RMAN Important Terms:

DEVICE TYPE --> disk or tape or SBT
IMAGE COPIES -- simple copy of databse as cp command in linux
BACKUPSET --> backupsets is a logical entity to backup pieces as a tablespace to data files. Backup pieces are in an RMAN specific binary format.

Note: You cannot perform incremental backups with image copies but you can do so with backup sets.

FORMAT --> to store backup at specific location/speciafic format (date/time).

TAG --> to identify/alias name for backup.

AS COMPRESSED BACKUPSET --> binary( Oracle database files) compression of backupsets, performance overhead during backups and restores.

Steps to take RMAN Backup from database either PROD or STANDBY:
We should use STANDBY because performance will not effect on PROD.

RMAN BACKUP STEPS:
sql "alter session set nls_date_format=''dd.mm.yyyy hh24:mi:ss''";
RUN
{
configure controlfile autobackup on;
set command id to 'DBOnlineBackupFull';
ALLOCATE CHANNEL c1 DEVICE TYPE disk;
ALLOCATE CHANNEL c2 DEVICE TYPE disk;
ALLOCATE CHANNEL c3 DEVICE TYPE disk;
ALLOCATE CHANNEL c4 DEVICE TYPE disk;
ALLOCATE CHANNEL c5 DEVICE TYPE disk;

backup AS COMPRESSED BACKUPSET full database 
tag <backup_name_full
format '< backup location with format>/%d_%T_%s_%p_FULL' ;

backup archivelog all
tag <DB_ARCHIVE>  
format '<location with format>/%d_%T_%s_%p_ARCHIVE' ;

backup current controlfile
tag <DB_CONTROL 
format '<location with format>/%d_%T_%s_%p_CONTROL';

release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;

}

After Backup completed, scp to the Target (Test) server and follow the below steps to DUPLICATE the database.

Now perform the RMAN Duplication as below.
Step 1) Login to Target (Test) database tier and source the Environment
Step 2) connect as sysdba , i.e. sqlplus ‘/as sysdba’
SQL> startup nomount;  ## it should start from spfile.
SQL>exit
$rman log=RMAN_dup_SID_timestamp.log
RMAN> connect auxiliary /
RMAN> run
 {
ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux3 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux4 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux5 DEVICE TYPE DISK;

DUPLICATE DATABASE TO <DATABASE_NAME> BACKUP LOCATION '/<backup location>/' NOFILENAMECHECK;
}

Whereas:
NOFILENAMECHECK:
Suppose, If we want the duplicate filenames to be the same as the target filenames, and also if our databases are in different hosts, then we should specify the option as NOFILENAMECHECK.
<backup_name_full>
example: proddb_bkp_full
<backup location with formate>/%d_%T_%s_%p_FULL 
example: /rmanbkp/PROD/%d_%T_%s_%p_FULL' ;

You may like some more below:
Regards,
ora-data Team

Monday, 28 May 2018

How to apply CPU OCT 2015 patch on 10.1.3 in r12.1.3

Hey DBA-Mates…
Hope you all doing well. CPU patches is little bit different than other patches but as I always says we/you can do it just need time and patient. 
Recently one of my colleague applied CPU Oct2015 apps patches 10.1.3.5 in R12.1.3
This below steps which guided to him and patches applied successfully. 
So, I thought to share with you all. Hope this may useful and helpful in your career. 
It is almost from basic and each point is provided.
I would like to request one more thing, please always read and follow the patches either readme.txt or readme.html which is very important. So, let’s see the below steps:
Check for OS details for downloading correct patch:
OS version details:
$ uname -a
SunOS hostname 5.xx $$.$$ sun4v sparc sun4v

$ cat /etc/release
                            Oracle Solaris $$.$ SPARC
  Copyright (c) 1983, 2017, Oracle and/or its affiliates.  All rights reserved.
                            Assembled 05 October 2017
$ isainfo -b
64 (bit)

$ opatch version
Oracle Interim Patch Installer version 1.0.0.0.64
Copyright (c) 2011 Oracle Corporation. All Rights Reserved..
Oracle recommends you to use the latest OPatch version
and read the OPatch documentation available in the OPatch/docs
directory for usage. For information about the latest OPatch and
other support-related issues, refer to document ID 293369.1
available on My Oracle Support (https://myoraclesupport.oracle.com)

OPatch Version: 1.0.0.0.64

Note: Always read patch either readme.txt or readme.html and follow that.
Note: As per readme.html Opatch version should be min 1.0.0.0.63, here in our case it is 1.0.0.0.64

$ cd $INST_TOP/ora/10.1.3
$ pwd
/apps/ebs/inst/apps/TEST_hostname/ora/10.1.3

$ echo $ORACLE_HOME
/apps/ebs/apps/tech_st/10.1.2   ## it should be point to 10.1.3
$ ls -ltr
total 15
drwxr-xr-x   3 applmgr  oinstall    network
drwxr-xr-x   3 applmgr  oinstall    Apache
drwxr-xr-x   3 applmgr  oinstall    javacache
drwxr-xr-x   6 applmgr  oinstall    j2ee
drwxr-xr-x   2 applmgr  oinstall    deconfig
drwxr-xr-x   2 applmgr  oinstall    config
drwxr-xr-x   5 applmgr  oinstall    opmn
drwxr-xr-x   2 applmgr  oinstall    cfgtoollogs
drwx------   3 applmgr  oinstall    ccr
-rw-r--r--   1 applmgr  oinstall    TEST_hostname.env

$ . ./TEST_hostname.env

$ echo $ORACLE_HOME
/apps/ebs/apps/tech_st/10.1.3
$

Pre check as it is applied or not:
$ opatch lsinventory | grep 21845960  [Main Patch number which no need output]

$ opatch lsinventory | grep 21845942  [Sub-patches if applied should show in output, which we will check after applying the patches]

$ pwd
/apps/ebs/apps/tech_st/10.1.3/opatches/21845960

$ echo $ORACLE_HOME
/apps/ebs/apps/tech_st/10.1.3

$ echo $IAS_ORACLE_HOME
/apps/ebs/apps/tech_st/10.1.3
$ echo $TWO_TASK
TEST
$
As per readme.html these below path should be mentioned in $PATH
$ ls -ltr /usr/bin/ld
-r-xr-xr-x   1 root     bin        24688 Mar 24 10:29 /usr/bin/ld
$ ls -ld /usr/bin/ar
-r-xr-xr-x   1 root     bin        43904 Mar 24 10:29 /usr/bin/ar
$ ls -ld /usr/bin/nm
-r-xr-xr-x   1 root     bin        48128 Mar 24 10:30 /usr/bin/nm
$ ls -ld /usr/bin/make
-rwxr-xr-x   1 root     bin       212988 May 25  2017 /usr/bin/make
$
If it now included in PATH then need to export as below shown:

$ export PATH=$PATH:/usr/bin/ld:/usr/bin/ar:/usr/bin/nm:/usr/bin/make

$ echo $PATH
$ pwd
/apps/ebs/apps/tech_st/10.1.3/opatches/21845960
$ which opatch
/apps/ebs/apps/tech_st/10.1.3/OPatch/opatch
$ echo $ORACLE_HOME
/apps/ebs/apps/tech_st/10.1.3
$ echo $TWO_TASK
TEST
$ pwd
/apps/ebs/apps/tech_st/10.1.3/opatches/21845960
$ ls -ltr
total 70
drwxr-xr-x   4 applmgr  oinstall       5 Oct 13  2015 21845942
-rwxr-xr-x   1 applmgr  oinstall    2258 Oct 13  2015 remove_demo.sh
-rw-r--r--   1 applmgr  oinstall      67 Oct 13  2015 README.txt
drwxr-xr-x   5 applmgr  oinstall       7 Oct 13  2015 21815758
drwxr-xr-x   4 applmgr  oinstall       5 Oct 13  2015 9273888
drwxr-xr-x   5 applmgr  oinstall      10 Oct 13  2015 10011970
drwxr-xr-x   5 applmgr  oinstall       6 Oct 13  2015 10036362
drwxr-xr-x   5 applmgr  oinstall       6 Oct 13  2015 14123312
-rw-rw-r--   1 applmgr  oinstall   57215 Oct 19  2015 README.html
$
Check for Invalid Objects:

SQL> select object_name,object_type,owner from dba_objects where status='INVALID'
$ pwd
/apps/ebs/apps/tech_st/10.1.3/opatches/21845960
$opatch napply

Note: Here napply we are using for multiple patches to ally as shown above under the cpu patches there were many patches.

After that it will ask many times as Y/N, read once I always provided Y as shown below like:
Please respond Y|N > Y

Once OPatch succeeded Then check for applied or not as below command:
$opatch lsinventory | grep 21845942
  2) Patch  21845942 applied on Sun May 27 02:17:58 GMT-05:00 2018
      [ Bug fixes: 17232193 7215134 12434146 21845942 21843498 9173042 7457583 19647609 15930322 17232255 17988318 6406333 6855621 18272601 19952531 18855617 7576325 6768420 16264435 14003474 20034700 13564298 16021033 19288606 17232750 17250040 17643943 9481810 17664485 17631115 16802872 6768427 16193586 20900385 6032064 8806540 7632951 16021138 13564285 17664561 12434225 18746609 14251913 16802900 18272665 14110089 14010533 19947918 17329650 19319912 12959528 8800528 19320420  ]

$ opatch lsinventory | grep 21815758
  3) Patch  21815758 applied on Sun May 27 02:10:56 GMT-05:00 2018

$  opatch lsinventory | grep 9273888
  1) Patch  9273888 applied on Sun May 27 02:19:55 GMT-05:00 2018

      [ Bug fixes: 9273888  ]

$ opatch lsinventory | grep 10011970
  5) Patch  10011970 applied on Sun May 27 01:50:07 GMT-05:00 2018
      [ Bug fixes: 6912255 6790178 7428561 6433471 5397517 3645912 5724681 4473073 6682888 7157442 8416899 6080374 6471931 6912781 7552946 5453754 6018059 6150541 9336949 5999450 5740055 7021360 7335185 6713795 5477073 6134487 7196121 7430171 6080307 5259451 6655345 10011970 7146872 5697416 6024000 6153975 7353810 5932346 7519011 7195030 6844221 5979883 5486768 7127677 7229577 5985742 6852049 4635520 6917549 5871130 7004606 6237650 5573438 6681624 6772953 6816068 7574599 5763122 6526074 5902630 7113141  ]

$ opatch lsinventory | grep 10036362  [ There is no problem if not showing, during applying it will show as Opatch success just check alert log.]

$ opatch lsinventory | grep 14123312
  4) Patch  14123312 applied on Sun May 27 02:06:07 GMT-05:00 2018
      [ Bug fixes: 14123312  ]
$
Or

Note: After applying the above patch, please check the readme.html where is mentioned the Post steps.

Hope this may useful and helpful. Please let us know for any suggestions or correction in our either comment box or contact us @ora-data.blogspot.com

Some more useful links:





Regards,

Sunday, 29 April 2018

Oracle RMAN Interview Questions and Answers


Hi DBA-mates,
After long time, again we are back with some important RMAN utility Questions and Answers. Now a day it is very important to know about the RMAN details and Configurations.

As per technologies changes, we should also upgrade our self. Now a day’s RMAN is asking in every profile.
I have selected some very important Questions and Answers as per my experiences and I have some more questions which I will be including here soon.

Q1.What is RMAN ?
A.RMAN (Recovery Manager)is an Oracle Database client that performs backup and recovery tasks on your databases and automates administration of your backup strategies.
It greatly simplifies the dba jobs by managing the production database's backing up, restoring, and recovering database files.

Q2.Why to use RMAN ?
A.RMAN gives you access to several backup and recovery techniques and features not available with user-managed backup and recovery. The most noteworthy are the following:
-- Automatic specification of files to include in a backup :  Establishes the name and locations of all files to be backed up.
-- Maintain backup repository:  Backups are recorded in the control file, which is the main repository of RMAN metadata.  Additionally, you can store this metadata in a recovery catalog.
-- Incremental backups: An incremental backup stores only blocks changed since a previous backup.
Thus, they provide more compact backups and faster recovery, thereby reducing the need to apply redo during datafile media recovery.

-- Unused block compression  :  In unused block compression, RMAN can skip data blocks that have never been used
-- Block media recovery: You an repair a datafile with only a small number of corrupt data blocks without taking it offline or restoring it from backup.
-- Binary compression: A binary compression mechanism integrated into Oracle Database reduces the size of backups.
-- Encrypted backups : RMAN uses backup encryption capabilities integrated into Oracle Database to store backup sets in an encrypted format.
-- Corrupt block detection :  RMAN checks for the block corruption before taking its backup.

Q3.How to check RMAN Configuration ?
RMAN>Show all;

Q4.How to Reset to default Configuration ?

A.To reset the default configuration setting use Connect to the target database from sqlplus and run
SQL> connect <sys/passwd as sysdba>@target_database; 
SQL> execute dbms_backup_restore.resetConfig;

Q5. How Many catalog database I can have ?
A.  You can have multiple catalog database for the same target database . But at a time you can connect to only 1 catalog database via RMAN. It’s not recommended to have multiple catalog databases.

Q6. Is this mandatory to use catalog database ?
A.  No ! it’s a optional one.

Q7. What is the difference between catalog database & catalog schema ?
A.  Catalog database is like any other database which contains the RMAN catalog user's schema.

Q8. What are the database file's that RMAN can backup ?
A. RMAN can backup  Controlfile , Datafiles , Archive logs , standby database controfile, Spfile

Q9. What are the database file's that RMAN cannot backup ?
A.  RMAN cannot take backup of the pfile, Redo logs , network configuration files, password files, external  tables and the contents of the Oracle home files

Q10. Can I have archivelogs and datafile backup in a single backupset ?
A.  No . we can not put datafiles and archive logs in the same backupset.

Q11. What is the difference between backup set backup and Image copy backup ?
A :  A backup set is an RMAN-specific proprietary format, whereas an image copy is a bit-for-bit copy of a file. By default, RMAN creates backup sets

Q12. Can I take RMAN backup when the database is Down ?
A. No ! You can take RMAN backup only when the target database is Open or in Mount stage. Its because RMAN keep the backup metadata in controfile . Only in open or mount mode controlfile is accessible.

Note: Please Check for Duplicate RMAN backup and Restore

Some Important links:






Hope this may useful and helpful. For any concerns please let us know either in comment box or contact @ora-data.blogspot.com
ref. doc:469777.1

Regards,
ora-data Team

Sunday, 4 March 2018

Oracle Apps Interviews Technical Questions and Answers by MNC Companies

Hi DBA-mates,
We are back again with some important Questions which may useful and helpful for any interviews.
I got these Questions from a friend, so I thought to share and it might useful here for all.
Actually, these questions are not for Oracle Apps DBA. These questions are looks like for Oracle DBA (Core).

1. Introduced yourself and your role.

2. How to disable archive log:
Ans. The method for disabling archive log mode described above is the only way to disable archive log mode.

Shutdown edit pfile / spfile (spfile when instance is up of course) to say log_archive_start = false.

startup mount

alter database noarchivelog;

alter database open;


Remember that once you disable archive log mode you need to take a fresh backup once archive log mode is turned back on.

3. RMAN Configuration:

rman>show all ;                                                 ## to check all the configuration.

RMAN> configure controlfile autobackup on;    # for on and off
RMAN> configure backup optimization off;

4. How to check database alert log path?
Ans:
If database if UP and Running:
SQL> show parameters dump

Or SELECT * FROM v$daig_info;

If database is down:
Or you can check as from ps –ef|grep tns then follow the paths…
i.e go till oracle_home (oracle version)
then $ORACEL_HOME/admin/SID_Hostname/diag/rdbms/sid/SID/trace

ls –l alert*
alert_SID.log


5. How to check Table log? (i.e. Logging and Nologging concepts) # not sure

6. How to check blocking session?
Ans:
$ cat block.sql
select sid "Session id ", decode(Block,1, 'Blocking Session','Waiting Session') Details, ctime  "Blocking Time /Waiting time",id2 from v$lock where (block <> 0 or request <>0 ) and ctime > 200 order by id2,Details;

SQL> desc v$lock
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ADDR                                               RAW(8)
 KADDR                                              RAW(8)
 SID                                                NUMBER
 TYPE                                               VARCHAR2(2)
 ID1                                                NUMBER
 ID2                                                NUMBER
 LMODE                                              NUMBER
 REQUEST                                            NUMBER
 CTIME                                              NUMBER
 BLOCK                                              NUMBER

SQL>

7. How to do expdp and impdp details and concepts.

Ans:


8. How to Apply Database Patches.

Ans:
9. How to Apply Apps patches apply.

Ans:

Regards,

Sunday, 14 January 2018

How to create user and grant privileges in oracle in R12.2

Hi DBA-mates,
As we all know, creating a Schema or DB User is very easy and we all do it in DBA’s life. Here, How to create database user and grant privileges in oracle.
However, there is some important points, which we need to take care.
There is some points such as how to create User’s and Grant them the Privileges.

How to create User and grant the user:
1. Create DB User or Schema:
Note: Here username is ora-data.
$sqlplus '/as sysdba'
Before creating user, we should check either user is existing or not.
SQL>select USERNAME from DBA_USERS where USERNAME like '%ORA-DATA%';

Query:
CREATE USER user_name IDENTIFIED BY  'passsword' DEFAULT TABLESPACE tablespace_name TEMPORARY TABLESPACE tablespace_name PROFILE DEFAULT ACCOUNT UNLOCK;

Example:
SQL>CREATE USER ora-data IDENTIFIED BY ora-data DEFAULT TABLESPACE user TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK;
Cross check:
SELECT USERNAME, ACCOUNT_STATUS, DEFAULT_TABLESPACE, TEMPORARY_TABLESPACE, CREATED from dba_users where USERNAME='ora-data';

Providing GRANTS:
SQL>GRANT CONNECT, RESOURCE TO ora-data;
SQL>GRANT CREATE SESSION TO ora-data;

SQL>GRANT CONNECT TO ora-data;
SQL>GRANT SELECT ANY DICTIONARY to ora-data;
SQL>GRANT SELECT ANY TABLE to ora-data;
SQL>GRANT UNLIMITED TABLESPACE to ora-data;
SQL>ALTER USER ora-data ENABLE EDITIONS; (In R12.2 specially)

If you want to Grant only on any particular Table (tb1) then find the below details:
SQL>GRANT SELECT ON tb1 to ora-data;

Suppose, if you want to GRANT for any particular OWNER for particular TABLE then follow below steps:

Example: OWNER= xxabc, TABLE= tb1, USERNAME=ora-data

SQL>conn xxabc/password
SQL>show user
xxabc
SQL> GRANT SELECT ON tb1 TO ora-data;

How to Check the GRANT details:
1. DBA_SYS_PRIVS: To show information about user's privileges related to System (DBA).
2. DBA_TAB_PRIVS: To show information about user's privileges related to Tables.
3. DBA_ROLE_PRIVS: To show information about user's privileges related to Roles.

To know details:
SQL>desc DBA_SYS_PRIVS;

Some Column Name and details:
GRANTEE: It is the name, role, or user that was assigned the privilege.

PRIVILEGE: It is the privilege that is assigned.

ADMIN_OPTION: It indicates if the granted privilege also includes the ADMIN option.

SQL>desc DBA_TAB_PRIVS;

GRANTEE: It is the name of the user with granted access.

TABLE_NAME: It is the name of the object (table, index, sequence, etc).

PRIVILEGE: It is the privilege assigned to the GRANTEE for the associated object.

Hope this may useful and helpful. If there is any suggestions or  corrections, please let us know either in comment box or contact us @https://ora-data.blogspot.in/

Some more useful links:
Regards,
ora-data Team