Monday, March 26, 2012

Power Of Native Compilation Initialization Parameter



Connect as 'sysdba' user


SQL> conn sys/oracle@Production as sysdba

SQL> SHOW PARAMETER PLSQL_CODE_TYPE


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
plsql_code_type                      string      INTERPRETED


SQL> alter user sh identified by sh account unlock;
User altered


SQL> conn sh/sh@Production

SQL> CREATE OR REPLACE FUNCTION C_N_K (N IN NUMBER, K IN NUMBER)
  2  RETURN NUMBER
  3  IS
  4  N_FAT NUMBER := 1;
  5  K_FAT NUMBER := 1;
  6  N_K_FAT NUMBER := 1;
  7  BEGIN
  8  FOR J IN 1..N LOOP
  9  N_FAT := N_FAT * J;
 10  END LOOP;
 11  FOR J IN 1..K LOOP
 12  K_FAT := K_FAT * J;
 13  END LOOP;
 14  FOR J IN 1..(N - K) LOOP
 15  N_K_FAT := N_K_FAT * J;
 16  END LOOP;
 17  RETURN (N_FAT / (N_K_FAT * K_FAT));
 18  END;
 19  /


Function created


SQL> CREATE OR REPLACE PROCEDURE STRESS(ANUM NUMBER)
  2  IS
  3  AVAL NUMBER;
  4  BEGIN
  5  FOR J IN 1..ANUM LOOP
  6  AVAL := C_N_K (50,10);
  7  END LOOP;
  8  END;
  9  /


Procedure created


SQL> SET TIMING ON
SQL> BEGIN
  2  STRESS(100000);
  3  END;
  4  /

PL/SQL procedure successfully completed


Executed in 1.123 seconds


Note : Flush the Shared Pool Area / Bounce the database server.


SQL> SET TIMING OFF


SQL> ALTER SESSION SET PLSQL_CODE_TYPE = NATIVE;
Session altered


SQL> CREATE OR REPLACE FUNCTION C_N_K (N IN NUMBER, K IN NUMBER)
  2  RETURN NUMBER
  3  IS
  4  N_FAT NUMBER := 1;
  5  K_FAT NUMBER := 1;
  6  N_K_FAT NUMBER := 1;
  7  BEGIN
  8  FOR J IN 1..N LOOP
  9  N_FAT := N_FAT * J;
 10  END LOOP;
 11  FOR J IN 1..K LOOP
 12  K_FAT := K_FAT * J;
 13  END LOOP;
 14  FOR J IN 1..(N - K) LOOP
 15  N_K_FAT := N_K_FAT * J;
 16  END LOOP;
 17  RETURN (N_FAT / (N_K_FAT * K_FAT));
 18  END;
 19  /


Function created


SQL> CREATE OR REPLACE PROCEDURE STRESS(ANUM NUMBER)
  2  IS
  3  AVAL NUMBER;
  4  BEGIN
  5  FOR J IN 1..ANUM LOOP
  6  AVAL := C_N_K (50,10);
  7  END LOOP;
  8  END;
  9  /


Procedure created


SQL> SET TIMING ON
SQL> BEGIN
  2  STRESS(100000);
  3  END;
  4  /


PL/SQL procedure successfully completed


Executed in 0.936 seconds


SQL> SET TIMING OFF
SQL> ALTER SESSION SET PLSQL_CODE_TYPE = INTERPRETED;
Session altered





Saturday, March 10, 2012

Effect of Creating Tablespace/Datafile on Primary Database when Logical Standby Database in Place


Primary Database:
Create a tablespace as below.

dbPRD>create tablespace tbstest2
              datafile '/oradata1/dbprd/tbstestt201.dbf' size 1m
              autoextend on next 1m maxsize unlimited;
Tablespace created.

dbPRD>select name from v$tablespace where name ='TBSTEST2';

NAME
-------------
TBSTEST2

Logical Standby Database :

Check whether the tablespace has replicated from primary site to logical standby site.

dbREP-LOGICAL>select name from v$database where name='TBSTEST2';
no rows selected

From the above result we can understand that, the tablespace created in primary site did not replicate to logical standby.

The following steps has to be followed to replicate the tablespace to logical standby site.

Stop the Logical Standby Database apply process :
 
dbREP-LOGICAL>alter database stop logical standby apply;
Database altered.

Execute the below procedure.

dbREP-LOGICAL>CREATE OR REPLACE PROCEDURE SYS.CREATE_TBS_DDL (
OLD_STMT IN VARCHAR2,
STMT_TYP  IN VARCHAR2,
SCHEMA    IN VARCHAR2,
NAME         IN VARCHAR2,
XIDUSN     IN NUMBER,
XIDSLT      IN NUMBER,
XIDSQN   IN NUMBER,
ACTION   OUT NUMBER,
NEW_STMT OUT VARCHAR2
)
AS
BEGIN
NEW_STMT := REPLACE(OLD_STMT,'/oradata1/dbprd','/oradata2/dbrep');
ACTION := DBMS_LOGSTDBY.SKIP_ACTION_REPLACE;
EXCEPTION
WHEN OTHERS THEN
ACTION := DBMS_LOGSTDBY.SKIP_ACTION_ERROR;
NEW_STMT := NULL;
END CREATE_TBS_DDL;
/

Procedure created.

After creating the procedure, Execute the below dbms statement.

dbREP-LOGICAL>EXECUTE DBMS_LOGSTDBY.SKIP
(stmt => 'TABLESPACE',
 proc_name => 'sys.CREATE_TBS_DDL');

PL/SQL procedure successfully completed.

Start the Logical Standby Database apply process :

dbREP-LOGICAL>ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;
Database altered.

Check whether the tablespace is replicated in logical standby site.

dbREP-LOGICAL>select name from v$tablespace where name='TBSTEST2';

NAME
-------------
TBSTEST2

Executing Data Pump (EXPDP) from Physical Standby Database

Physical Standby Database:
SQL> alter database recover managed standby database cancel;

Production Database:

SQL> create database link dbstd_dblink
SQL> connect to scott identified by laser using 'dbstd';

SQL> show user
USER is "SCOTT"

SQL> conn sys/oracle@dbprd as sysdba
Connected.

SQL> grant read,write on directory data_pump_dir to scott;
Grant succeeded.

SQL> grant read,write on directory data_pump_dir to system;
Grant succeeded.

SQL> host

[oracle@nagpur Desktop]$ expdp directory=data_pump_dir dumpfile=scott.dmp log=scott.log network_link=dbstd_dblink
Export: Release 11.2.0.3.0 - Production on Tue Feb 21 19:36:18 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Username: scott/laser@dbprd

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Legacy Mode Active due to the following parameters:
Legacy Mode Parameter: "log=scott.log" Location: Command Line, Replaced with: "logfile=scott.log"
Legacy Mode has set reuse_dumpfiles=true parameter.
FLASHBACK automatically enabled to preserve database integrity.
Starting "SCOTT"."SYS_EXPORT_SCHEMA_01":  scott/********@dbprd directory=data_pump_dir dumpfile=scott.dmp logfile=scott.log network_link=dbstd_dblink reuse_dumpfiles=true
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 256 KB
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SCOTT"."DEPT"                              5.937 KB       4 rows
. . exported "SCOTT"."EMP"                               8.570 KB      14 rows
. . exported "SCOTT"."SALGRADE"                    5.867 KB       5 rows
. . exported "SCOTT"."T1"                                   5.125 KB      11 rows
. . exported "SCOTT"."BONUS"                                 0 KB       0 rows
Master table "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_SCHEMA_01 is:
  /cbsprddbs/oracle/admin/dbprd/dpdump/scott.dmp
Job "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully completed at 19:37:28

[oracle@nagpur Desktop]$

Restoration of scott schema in Primary database using the above taken backup:

SQL> select db_unique_name,name,database_role from v$database;

DB_UNIQUE_NAME               NAME     DATABASE_ROLE
------------------------------     ---------    ----------------
dbprd                                         dbPRD      PRIMARY

SQL> drop user scott cascade;
User dropped.

SQL> select username from all_users where username='SCOTT';
no rows selected

SQL> create user scott identified by laser default tablespace users;
User created.

SQL> grant connect,resource,create database link,debug connect session,debug any procedure to scott;
Grant succeeded.

SQL> host impdp directory=data_pump_dir dumpfile=scott.dmp log=impdp_scott.log remap_schema=scott:scott parallel=2
Import: Release 11.2.0.3.0 - Production on Tue Feb 21 20:38:07 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Username: sys/oracle@dbprd as sysdba

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Legacy Mode Active due to the following parameters:
Legacy Mode Parameter: "log=impdp_scott.log" Location: Command Line, Replaced with: "logfile=impdp_scott.log"
Master table "SYS"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_FULL_01":  sys/********@dbprd AS SYSDBA directory=data_pump_dir dumpfile=scott.dmp logfile=impdp_scott.log remap_schema=scott:scott parallel=2
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."DEPT"                              5.937 KB       4 rows
. . imported "SCOTT"."EMP"                               8.570 KB      14 rows
. . imported "SCOTT"."SALGRADE"                    5.867 KB       5 rows
. . imported "SCOTT"."T1"                                   5.125 KB      11 rows
. . imported "SCOTT"."BONUS"                                 0 KB       0 rows
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SYS"."SYS_IMPORT_FULL_01" successfully completed at 20:38:25

The schema Scott is restored from the backup taken from the physical standby database.

Monday, March 5, 2012

Oracle 11g RAC Exam Questions and Answers (1zo-058)

QUESTION NO: 1

Which three actions would be helpful in determining the cause of a node reboot?

A. determining the time of the node reboot by using the update command and subtracting the up time from the current system time
B. looking for messages such as "Oracle CSSD failure. Rebooting for cluster integrity” in
/var/log/messages
C. using the crsctl command to view tracing information
D. inspecting the ocssd log for "Begin Dump" or "End Dump" messages
E. inspecting the database alert log for reboot messages

Answer: A,B,D

QUESTION NO: 2

After Oracle Grid Infrastructure has been installed, you should take a few moments to verify the installation.
Which two actions would be useful in verifying the installation?

A. Run the crsctl status resource –t command to confirm that all necessary cluster resources are online.
B. Use the operating system utilities to verify that your SCAN addresses are being properly resolved.
C. Start Oracle Enterprise Manager and check all monitored targets.
D. Run the cluvfy comp nodecon –n all –verbose command to verify the entire Grid Infrastructure installation.

Answer: A,D

QUESTION NO: 3

Which two network addresses are required to be static, non-dhcp addresses when using the Grid Naming?

A. GNS VIP Address
B. SCAN VIP Address
C. Node VIP Address
D. Node Public Address
E. Node Private Address
Answer: A,D

QUESTION NO: 4

You are in the planning stages for upgrading your Oracle RAC database from Oracle Database 10g Release 2 to Oracle Database 11g Release 2 to run under the Oracle Grid Infrastructure.You decide to use an administrator-managed configuration because the cluster is fairly small.  Which statement is correct about this configuration?

A. A parent pool of the GENERIC server pool will be used.
B. You must define a new server pool called MANUAL.
C. A subpool of the GENERIC server pool will be used.
D. A subpool of the FREE server pool will be used.

Answer: C

QUESTION NO: 5

The Instance Initialization parameters are set to:
D8_CREATE_FILE_DEST = +DATA
DB_CREATE_ONLlNE_LOG_DEST_l = +LOGS
DB_CREATE_ONLlNE_LOG_DEST_2 = + FRA
The SQL* Plus command ALTER DATABASE ADD LOGFILE;  will create:

A. a new log file in the +DATA disk group, or a log file in the + FRA disk group, if +DATA is not available
B. a new log file in the +DATA disk group and a log file in the + FRA disk group
C. a new log file in the +LOGS disk group and a log file in the + FRA disk group
D. a new log file in the +LOGS disk group, or a log file in the +FRA dls* available
E. a new log file in the +DATA disk group, a log file in the +LOGS disk group, and a log file in the +FRA disk group
F. a new log file in the +LOGS disk group, or a log file in the +FRA disk group, if +LOGS is not available

Answer: C

QUESTION NO: 6

Which three statements define a cluster?

A. is a group of independent, but interconnected computers that act as a single system
B. can be deployed to increase availability and performance
C. can be deployed to balance a dynamically changing workload
D. should appear to an application as multiple servers

Answer: A,B,C

QUESTION NO: 7

You want to create an ACFS on an ADVM volume using a shell script and the appropriate command-line utilities. These are the requirements:
1. The dynamic volume file must use space in the VOLFILE disk group with a size of 500 M and be called prodvol.
2. The mount point called /acfs already exists.
Which four steps must be performed to achieve this?

A. As the Grid Infrastructure owner, run mount –t acfs /dev/asm/prodvol-417 /acfs to mount the file system.
B. As the Grid Infrastructure owner, run asmcmd volinfo –d VOLFILE prodvol to determine the volume information.
C. As the Grid Infrastructure owner, run asmcmd voicreate –d VOLFILE –s 500M
prodvol to create the volume file.
D. As the Grid Infrastructure owner, run mkfs –t acfs /dev/asm/prodvol -417 to create the file system.
E. As root, run mount –t acfs /dev/asm/prodvol -417 /acfs to mount the file system.
F. As root, run mkfs –t acfs /dev/asm/prodvol -417 to create the file system.

Answer: B,C,E,F

QUESTION 8

Some new non-ASM shared storage has been made available by the storage administrator and the Oracle Grid Infrastructure Administrator decides to move the voting disks, which do not reside in ASM, to this new non-ASM location. How can this be done?

A. By running crsctl add css votedisk <path_to_new_location> followed by crsctl delete css votedisk <path_to_old_location>      
B. By running crsctl replace css votedisk <path_to_old_location/path_to_new_location>      
C. By running srvctl replace css votedisk <path_to_old_location,path_to_new_location>      
D. By running crsctl add css votedisk<path_to_new_location> followed by srvctl delete css votedisk <path_to_old_location>   

Answer: B

QUESTION 9

Which three statements are true about using RMAN with ASM?

 A.RMAN is the only supported method to back up database files stored in ASM.      
B.RMAN is the only supported method to back up ACFS files.      
C.RMAN can use ASM storage for backups.      
D.RMAN cannot use ASM storage for backups.      
E.Using RMAN, database files can be migrated to ASM from a file system.      
F.Using RMAN, database files cannot be moved from ASM to a file system   

Answer: ACE

QUESTION 10

Which two statements are true about ACFS snapshots?

A.They can be created for ACFS file systems only if the ASM disk group hosting the ADVM volume file used by the file system has free space available.      
B.They can be created for ACFS file systems only if the ADVM volume file used by the file system has free space available.      
C.They can be created only if the ASM disk group hosting the ADVM volume used by the file system has no other ASM files contained in the disk group.      
D.They can be created when ACFS is used both on clusters and on stand-alone servers.      
E.They are accessible only on the cluster node that was used when creating the snapshot.   

Answer: AD

QUESTION 11

Your cluster is subject to a service-level agreement that allows for little scheduled down time You want to use patching and maintenance methods that permit the Oracle Grid Infrastructure and Oracle RAT Databases to be available as much as possible. Which two techniques will work some or all of the time to provide you with minimum down time?

A.rolling upgradeable and in place patch sets      
B.idling upgradeable and out of place patch bundles      
C.rolling upgradeable and out of place patch sets      
D.rolling upgradeable and in place patch bundles      
E.rolling upgradeable and out of place one-off patches   

Answer: CD

QUESTION 12

Which two types of files can be stored In an ASM clustered file system?

A.OCR and Voting Disk files      
B.data files for external tables      
C.Oracle database executable      
D.Grid Infrastructure executables      
E.data files for tablespaces      
F.archive log files   

Answer: BC

QUESTION 13

You want to reorganize the DATA diskgroup while continuing database operations. The DATA diskgroup was created using normal redundancy having one disk per failure group. The two disks used are /dev/sdal and /dev/sda2.
You plan to drop the existing disks and add the /dev/sdb1 and /dev/sdb2 disks to failure group FG_C and the /dev/sdcl and /dev/sdc2 disks to failure group FG_D.
Which procedure would you use to minimize the effect of the I/Os of this reorganization on ongoing database operations?

A.Set rebalance power to 0 for diskgroup DATA.
Add failure group FG_C with all the /dev/sdb disks.
Add failure group FG_D with all the /dev/sdc disks.
Drop disks/dev/sda1 and /dev/sda2
Set rebalance power to 1 for diskgroup DATA.      
B.Set rebalance power to 0 for diskgroup DATA.
Add failure group FG_C with all the /dev/sdb disks.
Add failure group FG_D with all the /dev/sdb disks.
Drop disks/dev/sda1 and /dev/sda2
Set rebalance power to 9 for diskgroup DATA.      
C.Set rebalance power to 9 for diskgroup DATA.
Add failure group FG_C with all the /dev/sdb disks.
Add failure group FG_D with all the /dev/sdc disks.
Drop disks /dev/sda1 and /dev/sda2.
Set rebalance power to 0 for diskgroup DATA.      
D.Set rebalance power to 0 for diskgroup DATA
Drop disks /dev/sdal and /dev/sdb disks.
Add failure group FG_C with all the /dev/sdb disks.
Add failure group FG_D with all the /dev/sdc disks
Set rebalance power to 1 for diskgroup DATA.   

Answer: A

QUESTION 14

Which two Cluster ware stack administration actions must be performed as the root user?

A.checking the health of the Clusterware on one node      
B.starting the Clusterware manually on one node      
C.disabling the Clusterware from automatic start at node reboot      
D.checking the health and viability of the Clusterware on all nodes      
E.listing the location of the voting disks   

Answer: BC

QUESTION 15

Which four statements are true about ADVM interoperability?

A.Using fdisk or similar disk utilities to partition ADVM-managed volumes is not supported      
B.On Linux platforms, the raw utility can be used to map ADVM volume block devices to raw volume devices.      
C.The creation of multipath devices over ADVM devices is not supported.      
D.You may create ASMLIB devices over ADVM devices to simplify volume management.      
E.ADVM does not support ASM storage contained in Exadata.      
F.ADVM volumes cannot be used as a boot device or a root file system.   

Answer: ACEF

QUESTION 16

Your four-node cluster was originally purchased, installed, and configured three years ago. You recently added another four nodes to the cluster.

Now you want to remove two of the older nodes that are still accessible to be redeployed elsewhere in the data center. Which two are true regarding the procedure for removing one or more cluster nodes?

A.The procedure requires that all commands be invoked from one of the surviving cluster nodes.      
B.All commands are run as root regardless of which nodes are used to invoke them.      
C.The procedure requires that some commands be invoked on the node or nodes to be removed and that some be invoked from all surviving cluster nodes.      
D.The procedure requires that some commands be invoked on the node or nodes to be removed and that some be invoked from one surviving cluster node.      
E.Some commands require that the name of the node or nodes to be removed are passed arguments, and some commands require the name of existing nodes to be passed   

Answer: DE

QUESTION 17

Your production environment cluster is running Oracle Enterprise Linux and currently has four nodes. You are asked to plan for extending the cluster to six nodes. Which three methods are available to add the new nodes?

A. silent cloning using crsctl clone cluster and ssh      
B. a GUI interface from Enterprise Manager      
C. with the Oracle Universal Installer using runInstaller ­clone <nodename>      
D. silent cloning using  perl clone.pl ­silent either with parameters in a file or in line      
E. using addNode.sh   

Answer: BDE

QUESTION 18

The Oracle 11g Release 2 (version 11.2.0.1) ASM instance has a new diskgroup named data that Is currently not mounted You log in to a cluster node as the Grid Infrastructure software, and set the environment variables to point to the ASM instance on that node. Using SQL*plus, you issue the commands:

CONNECT / AS SYSDBA
ALTER DISKGROUP DATA MOUNT;

The system response is:
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-1S260: permission denied on ASM disk group

How do you diagnose this error?

A.Check v$asm_operation for operations halted by the error.      
B.Check v$asm_attributes to determine the asm.compatible setting.      
C.Check v$asm_usergroup to determine the owning user group for this diskgroup.      
D.Check v$xs_session_role to determine the role privileges of the current user.      
E.Check the connect string for the privileged role.   

Answer: E

QUESTION 19

You enter the following command:

crsctl status resource MyApp

You get this output:
NAME=MyApp
TYPE=cluster_resource
TARGET=ONLINE
STATE=ONLINE on RACNODE4

MyApp is a policy-managed resource using a server pool with two nodes called RACNODE3 and RACNODE4 and has a cardinality of 1.
What are the meanings of the target and state status values?

A.MyApp is currently active on RACNODE4 and is meant to be active only on RACNODE4.      
B.MyApp is meant to be active, is currently active on RACNODE4, but the Grid Infrastructure may start MyApp on RACNODE3 due to failovers.      
C.MyApp is active on RACNODE4 and was manually started.      
D.MyApp should also be online on RACNODE3 because it is a cluster_resources type that must be active on at least two nodes in the cluster, thereby overriding the CARDINALITY attribute.   

Answer: B

QUESTION 20

After evaluating the various methods for extending a cluster, you decide to use addNode.sh.The cluster originally consisted of four nodes: RACNODE1, RACNODE2, RACNODE3, and RACNODE4. Now two nodes called RACNODE5 and RACNODE6 have been installed and connected to the cluster by OS administrations.

Which three actions should be performed to check whether the new nodes are ready for running addNode.sh and to help correct any problems?

A. cluvfy stage -pre crsinst -n RACNODE5/ RACNODE6 -C + DATA -q +VOTE -orainv      
B. <oinstall group> -fixup -verbose      
C. cluvfy stage -post hwos -n RACNODE5, RACNODE6 -verbose      
D. cluvfy comp peer -refnode RACNODE1 -n RACNODE5, RACNODE6 -orainv <oinstall group> - osdba <asmdba group> -verbose      
E. cluvfy stage -post hwos -n all -verbose      
F. cluvfy stage -pre nodeadd -n RACNODE5, RACNODE6 -fixup      
G. cluvfy comp peer -refnode RACNODE5 -n RACNODE6 -orainv <oinstall group> -osdba <asmdba group> -verbose   

Answer: CDF

QUESTION 21

What are the default connect strings used by SQL*Plus and ASMCMD when connecting to ASM instances?

A. operating system authentication for ASMCMD-none for SQL*Plus      
B. "/ as sysasm" for ASMCMD' "/" for SQL*Plus      
C. "sys/ as sysasm" for ASMCMD; "/ as sysdba" for SQL* Plus      
D. operating system authentication for ASMCMD; operating system authentication for SQL*Plus      
E. "/ as sysasm" for ASMCMD; Operating system authentication for SQL*Plus   

Answer: B

QUESTION 22

You want to install a database patch on your eight-node cluster by using Opatch with, the minimum amount of down time to your cluster nodes.

You have already been prompted for the first set of nodes and you replied with node names RACNODE1, RACNODE2 and RACNODE3.

Which two statements are true about the procedure for minimizing down time?

A. The patch must be propagated to, applied, and the inventory updated on all the remaining nodes before restarting the instances on the first set of nodes.      
B. When the first set of nodes has been patched, the instances on the remaining nodes are shut down automatically by opatch.      
C. The instances must be started on the first set of nodes and then stopped on the remaining set to make certain that some nodes are always available.      
D. When the first set of nodes has been patched, the administrator is prompted to shut down the instances on the remaining nodes.      
E. The patch must be propagated to and the inventory updated on all the remaining nodes before restarting the instances on the first set of nodes.   

Answer: CD

QUESTION 23

You are ready to add two new nodes called RACNODE5 and RACNODE6 to your existing four- node cluster Using addNode.sh

You have run cluvfy -peer to check the new nodes against a reference node.

When you originally created the cluster, the network administrators chose to statically define the scan vip addresses in the corporate DNS server, and you installed the Oracle Grid Infrastructure without using GNS.What is the correct way to silently add the nodes?


A. addNode.sh -silent "CLUSTER_NEW_NODES={RACNODE5,RACNODE6}"      
B. addNode.sh -silent "CLUSTER_NEW_VIRTUAL_HOSTNAMES={RACNODE5-VIP, RACNODE6-VIP}"      
C. addNode.sh -silent "CLUSTER_NEW_NODES={RACNODE5,RACNODE6}" "CLUSTER_NEW_VlRTUAL_HOSTNAMES=RACNODE5-VIP,RACNODE6-VIP"      
D. addNode.sh -silent -responseFile mynewnodea.txt with the response file containing only      
E. CLUSTER_NEW_NODES={"RACNODE5,RACNODE6"}      
F. addNode.sh -silent -responseFile mynewnodes.txt with the response file containing only   CLUSTER_NEW_VIRTUAL_HOSTNAMES={"RACNODE3-VIP,RACNODE4-VIP"}   

Answer: C

QUESTION 24
Which four statements about mounting ASM cluster file systems are true?

A. An ACFS volume can be mounted by using ASMCA.      
B. The standard Linux/UNIX mount command can be used to mount an ACFS volume, provided the ACFS type is specified; (mount -t acfs).      
C. ACFS volumes can be mounted by using the ASMCMD utility.      
D. The acfsmountvol command can be used to mount ACFS volumes on Windows platforms.      
E. Oracle Enterprise Manager can be used to mount ACFS volumes.   

Answer: ABDE

QUESTION 25

You are allocating space from the ASM disk group for an ADVM volume. What will be the volume extent and Volume Allocation Unit (VAU) if the stripe column is 4 and AU is 1 MB? which are the default values?

A. The volume extent is 64 MB and the VAU will be 512 MB.      
B. The volume extent is 64 MB and the VAU will be 256 MB.      
C. The volume extent is 32 MB and the VAU will be 256 MB.      
D. It is not possible to calculate these values with the given information.   

Answer: B

Thursday, March 1, 2012

Switchover In Logical Standby Database Without Using DGMGRL

On Primary Database:

Check the switchover status and of the  Primary Database.


SQL> select switchover_status from v$database;


SWITCHOVER_STATUS

-----------------------------

TO STANDBY


SQL> select name,db_unique_name,database_role,open_mode from v$database;


NAME      DB_UNIQUE_NAME         DATABASE_ROLE      OPEN_MODE

--------- ------------------------------ ---------------- --------------------

primdb      primdb              PRIMARY      READ WRITE


Issue the below command to prepare the Primary Database to switchover to logical standby.

--> alter database prepare to switchover to logical standby;


SQL> alter database prepare to switchover to logical standby;

Database altered.

SQL> select switchover_status from v$database;


SWITCHOVER_STATUS

-----------------------------

PREPARING SWITCHOVER


Here the switchover status is PREPARING SWITCHOVER. Change the switchover status of Logical standby database and Wait for some time so that the status of primary database will change as TO LOGICAL STANDBY.


On Logical Standby Database
primdb

Check the switchover status and database role of the database.


SQL> select switchover_status from v$database;


SWITCHOVER_STATUS

----------------------------

NOT ALLOWED


SQL> select name,db_unique_name,database_role,open_mode from v$database;


NAME      DB_UNIQUE_NAME         DATABASE_ROLE      OPEN_MODE

---------    ------------------------------ ---------------- --------------------

stddby   stddby             LOGICAL STANDBY  READ WRITE


Issue the command to prepare the Logical standby database to switchover to Primary Database.


--> alter database prepare to switchover to logical standby;


SQL> alter database prepare to switchover to primary;

Database altered.


SQL> select switchover_status from v$database;


SWITCHOVER_STATUS
----------------------------

TO PRIMARY


On Primary Database

Now the check the switchover status of primary database. The status will be changed as TO LOGICAL STANDBY.


SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
----------------------------

TO LOGICAL STANDBY

Now switchover primary database to Logical Standby using the  below command.


--> alter database commit to switchover to logical standby;


SQL> alter database commit to switchover to logical standby;

Database altered.


Now check the database role of the primary database. It will be changed to Logical Standby.


SQL> select name,db_unique_name,database_role,open_mode from v$database;

NAME      DB_UNIQUE_NAME         DATABASE_ROLE      OPEN_MODE

--------- ------------------------------ ---------------- --------------------

primdb      primdb              LOGICAL STANDBY  READ WRITE


On Logical Standby Database

Now check the switchover status of Logical Standby Database.

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS

----------------------------

TO PRIMARY


Switchover the  Logical standby database to Primary using the below command.


--> alter database commit to switchover to primary;


SQL> alter database commit to switchover to primary;

Database altered.

Check the database role of the Logical Standby database. It will be changed as Primary.


SQL> select name,db_unique_name,database_role,open_mode from v$database;


NAME      DB_UNIQUE_NAME         DATABASE_ROLE      OPEN_MODE

--------- ------------------------------ ---------------- --------------------

stddby   stddby             PRIMARY      READ WRITE


On Primary Database

Start the Logical Standby apply process.


SQL> alter database start logical standby apply immediate;

Database altered.


On Logical Standby Database (Current Primary Database)

Insert a row in a table and check whether it has been replicated to Primary Database(Currently Logical Standby).


SQL> select * from scott.t1;

    NO
----------

     2

     1

     3

SQL> insert  into scott.t1 values(4);

1 row created.


SQL> commit;

Commit complete.

SQL> select * from scott.t1;


    NO

----------

     2

     1

     3

     4


On Primary Database (Current Logical Standby Database)

Check the replication to Primary Database(Current Logical Standby).


SQL> select * from scott.t1;

    NO

----------

     2

     1

     3


SQL> select * from scott.t1;


    NO

----------

     2

     1

     3

     4

The same thing has to be followed for Switchback.


SWITCHBACK TO OLD ROLE


On Logical Standby Database(Current Primary Database)

SQL> select switchover_status from v$database;


SWITCHOVER_STATUS

-----------------------------

TO STANDBY


SQL> alter database prepare to switchover to logical standby;

Database altered.

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
----------------------------

PREPARING SWITCHOVER


SQL> select switchover_status from v$database;


SWITCHOVER_STATUS

----------------------------
TO LOGICAL STANDBY


SQL> alter database commit to switchover to logical standby;

Database altered.


SQL> select switchover_status from v$database;


SWITCHOVER_STATUS

----------------------------

NOT ALLOWED


SQL> select open_mode,database_role,name from v$database;

OPEN_MODE         DATABASE_ROLE    NAME

-------------------- ---------------- ---------

READ WRITE         LOGICAL STANDBY  stddby


SQL> alter database start logical standby apply immediate;

Database altered.


SQL> archive log list

Database log mode           Archive Mode

Automatic archival           Enabled

Archive destination           /oradata3/stddby/archives

Oldest online log sequence     17

Next log sequence to archive   19

Current log sequence           19


SQL> select * from scott.t1;

    NO

----------

     2

     1

     3

     4


SQL> select * from scott.t1;

    NO

----------

     2

     5

     1

     3

     4



On primary Database (Current Logical Standby Database)

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS

----------------------------

NOT ALLOWED


SQL> archive log list

Database log mode           Archive Mode

Automatic archival           Enabled

Archive destination           /oradata2/primdb/archives

Oldest online log sequence     33

Next log sequence to archive   35

Current log sequence           35

SQL> alter database prepare to switchover to primary;

Database altered.

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
----------------------------

PREPARING SWITCHOVER


SQL> select switchover_status from v$database;

SWITCHOVER_STATUS

----------------------------

TO PRIMARY


SQL> alter database commit to switchover to primary;

Database altered.


SQL> select switchover_status from v$database;

SWITCHOVER_STATUS

----------------------------

LOG SWITCH GAP


SQL> select open_mode,database_role,name from v$database;

OPEN_MODE         DATABASE_ROLE    NAME

-------------------- ---------------- ---------

READ WRITE         PRIMARY          primdb

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
----------------------------

LOG SWITCH GAP

SQL> alter system switch logfile;

System altered.

SQL> archive log list

Database log mode           Archive Mode

Automatic archival           Enabled

Archive destination           /oradata2/primdb/archives

Oldest online log sequence     40

Next log sequence to archive   42

Current log sequence           42

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS

----------------------------

TO STANDBY


SQL> select * from scott.t1;

    NO
----------

     4

     3

     1

     2

SQL> insert into scott.t1 values(5);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from scott.t1;

    NO
----------
     4

     3

     1

     2

     5


Logical Standby Database Switchover Using DGMGRL

Primary Database    - proddb
Logical Standby      -  stddb
DGMGRL config    - dg_logical

Primary Database:
SQL> select name,db_unique_name,open_mode,database_role,flashback_on from v$database;

NAME      DB_UNIQUE_NAME         OPEN_MODE          DATABASE_ROLE    FLASHBACK_ON
--------- ------------------------------ -------------------- ---------------- ------------------
proddb      proddb              READ WRITE          PRIMARY           YES

SQL> archive log list
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           /oradata2/proddb/archives
Oldest online log sequence     55
Next log sequence to archive   57
Current log sequence           57

Logical Standby Database:

SQL> select name,db_unique_name,open_mode,database_role,flashback_on from v$database;

NAME      DB_UNIQUE_NAME         OPEN_MODE          DATABASE_ROLE    FLASHBACK_ON
--------- ------------------------------ -------------------- ---------------- ------------------
stddb   stddb             READ WRITE          LOGICAL STANDBY  YES

SQL> archive log list
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           /oradata3/stddb/archives
Oldest online log sequence     38
Next log sequence to archive   40
Current log sequence           40

Replication Testing Before Switchover

On Primary Database:

SQL> select * from scott.t1;

    NO
----------
     1
     2

2 rows selected.

SQL> insert into scott.t1 values(3);
1 row created.

SQL> commit;
Commit complete.

SQL> select * from scott.t1;

    NO
----------
     3
     1
     2

3 rows selected.

On Standby Database:
SQL> select * from scott.t1;

    NO
----------
     2
     1
     3

3 rows selected.

Switchover using DGMGRL
Primary Database    - proddb
Logical Standby      - stddb
DGMGRL config    - dg_logical

1. Login to the DGMGRL prompt.
[oracle@nagpur bin]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle@proddb
Connected.

DGMGRL> show configuration
Configuration - dg_logical

  Protection Mode: MaxPerformance
  Databases:
    proddb   - Primary database
    stddb - Logical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

Since for switchover there is no requirement for Fast-Start Failover  it has been disabled.

2. To switchover primary database to Logical Standby database issue the below command.

switchover to stddb;

DGMGRL> switchover to stddb;
Performing switchover NOW, please wait...
Switchover succeeded, new primary is "stddb"

From the above spool we can clearly understand that the primary database has been switched over to Logical Standby.

3. Check the show configuration after switchover.

DGMGRL> show configuration
Configuration - dg_logical

  Protection Mode: MaxPerformance
  Databases:
    stddb - Primary database
    proddb   - Logical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

4. Check the role of the primary and logical standby database.
On Primary Database:

SQL> select name,db_unique_name,open_mode,database_role,flashback_on from v$database;

NAME      DB_UNIQUE_NAME         OPEN_MODE          DATABASE_ROLE    FLASHBACK_ON
--------- ------------------------------ -------------------- ---------------- ------------------
proddb      proddb              READ WRITE          LOGICAL STANDBY  YES

On Logical Standby Database:
SQL> select name,db_unique_name,open_mode,database_role,flashback_on from v$database;

NAME      DB_UNIQUE_NAME         OPEN_MODE          DATABASE_ROLE    FLASHBACK_ON
--------- ------------------------------ -------------------- ---------------- ------------------
stddb   stddb             READ WRITE          PRIMARY           YES

Replication Testing After SwitchoverOn Logical Standby Database (Now Primary):
SQL> select * from scott.t1;

    NO
----------
     2
     1
     3

3 rows selected.

SQL> insert into scott.t1 values(4);
1 row created.

SQL> commit;
Commit complete.

SQL> select * from scott.t1;

    NO
----------
     2
     1
     3
     4

4 rows selected.

On Primary Database (Now Logical Standby):
SQL> select * from scott.t1;

    NO
----------
     2
     1
     3
     4

4 rows selected.

Switchback using DGMGRL
Primary Database    - stddb
Logical Standby     - proddb
DGMGRL config          - dg_logical

1. Login to the DGMGRL prompt.
[oracle@nagpur bin]$ export ORACLE_SID=proddb
[oracle@nagpur bin]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle@proddb
Connected.

DGMGRL> show configuration
Configuration - dg_logical

  Protection Mode: MaxPerformance
  Databases:
    stddb - Primary database
    proddb   - Logical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

Since for switchback there is no requirement for Fast-Start Failover  it has been disabled.

2. To switchover primary database to Logical Standby database issue the below command.
switchover to proddb;

DGMGRL> switchover to proddb;
Performing switchover NOW, please wait...
Switchover succeeded, new primary is "proddb"

From the above spool we can clearly understand that the primary database has been switched over to Logical Standby.

3. Check the show configuration After switchback:
DGMGRL> show configuration
Configuration - dg_logical

  Protection Mode: MaxPerformance
  Databases:
    proddb   - Primary database
    stddb - Logical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

4. Check the role of the primary and logical standby database.
On Primary Database:

SQL> select name,db_unique_name,open_mode,database_role,flashback_on from v$database;

NAME      DB_UNIQUE_NAME         OPEN_MODE          DATABASE_ROLE    FLASHBACK_ON
--------- ------------------------------ -------------------- ---------------- ------------------
proddb      proddb              READ WRITE          PRIMARY           YES

On Logical Standby Database:
SQL> select name,db_unique_name,open_mode,database_role,flashback_on from v$database;

NAME      DB_UNIQUE_NAME         OPEN_MODE          DATABASE_ROLE    FLASHBACK_ON
--------- ------------------------------ -------------------- ---------------- ------------------
stddb   stddb             READ WRITE          LOGICAL STANDBY  YES

Replication Testing After Switchover
On Primary Database:

SQL> select * from scott.t1;

    NO
----------
     4
     3
     1
     2

4 rows selected.

SQL> insert into scott.t1 values(5);
1 row created.

SQL> commit;
Commit complete.

SQL> select * from scott.t1;

    NO
----------
     4
     3
     1
     2
     5

5 rows selected

On Logical Standby Database:
SQL> select * from scott.t1;

    NO
----------
     2
     5
     1
     3
     4

5 rows selected.

Striping Tables and Indexes across multiple disks at Table Level and Index Level

Step 1 : Login as 'SYS' as user and create tablespace
SQL> conn sys/oracle@db as sysdba

SQL> create tablespace TBFES datafile 'D:\db\TBFES01.dbf' size 10m autoextend on next 5m maxsize unlimited
Tablespace created.

SQL> create tablespace PRD datafile 'D:\db\PRD01.dbf' size 10m autoextend on next 5m maxsize unlimited
Tablespace created.

SQL> create user scott identified by oracle default tablespace PRD
User created.

Step 2 : Grant privileges to user
SQL> grant CONNECT,RESOURCE,CREATE TABLE,CREATE ANY PROCEDURE,CREATE SYNONYM,DEBUG ANY PROCEDURE,
           DEBUG CONNECT SESSION,CREATE ANY JOB,
           CREATE TYPE,CREATE VIEW,MANAGE ANY QUEUE,MANAGE SCHEDULER
Grant succeeded.

SQL> grant UNLIMITED TABLESPACE to scott
Grant succeeded.
SQL> grant execute on dbms_sqlhash to scott
Grant succeeded.
SQL> grant execute on dbms_scheduler to scott
Grant succeeded.
SQL> grant execute on dbms_lock to scott
Grant succeeded.
SQL> grant execute on dbms_job to scott
Grant succeeded.
SQL> create or replace directory imp as 'D:\volume'
Directory created.
SQL> grant read,write on directory imp to scott
Grant succeeded.

Step 3 : Check the autoextensible and size for created tablespaces
SQL> select file_name,autoextensible,bytes/1024/1024 MB from dba_data_files where tablespace_name in ('PRD','TBFES')

FILE_NAME                                     AUT         MB                                                                                         
--------------------------------------------- --- ----------                                                                                         
D:\DB\TBFES01.DBF                             YES         10                                                                                         
D:\DB\PRD01.DBF                               YES         10                                                                                         

Step 4 : BEFORE IMPORTING expdp_scott_exclude_comp_19022012.dmp tablespace size
SQL> select file_name,autoextensible,bytes/1024/1024 MB from dba_data_files where tablespace_name in ('PRD','TBFES')

FILE_NAME                                     AUT         MB                                                                                         
--------------------------------------------- --- ----------                                                                                         
D:\DB\TBFES01.DBF                             YES         10                                                                                         
D:\DB\PRD01.DBF                               YES         10                                                                                         

Step 5 : IMPORTING expdp_scott_exclude_comp_19022012.dmp
SQL> host impdp directory=imp dumpfile=expdp_scott_exclude_comp_19022012.dmp logfile=imp.log parallel=4 remap_schema=scott:scott tables=scott.tableext transform=oid:y:type

Step 6 : CREATING DATAFILES in DIFFERENT PARTITIONS
SQL> alter tablespace tbfes add datafile 'H:\DB\TBFES01.dbf' size 10m autoextend on next 2m maxsize unlimited;
Tablespace altered.

SQL> alter tablespace tbfes add datafile 'I:\DB\TBFES01.dbf' size 10m autoextend on next 2m maxsize unlimited;
Tablespace altered.

SQL> alter tablespace PRD add datafile 'I:\DB\PRD01.dbf' size 10m autoextend on next 2m maxsize unlimited;
Tablespace altered.

SQL> alter tablespace PRD add datafile 'H:\DB\PRD01.dbf' size 10m autoextend on next 2m maxsize unlimited;
Tablespace altered.

Step 7 : Allocate an extent for the tableext table of the SCOTT schema on the newly-created data file
SQL> conn scott/oracle@db
Connected.

SQL> alter table tableext allocate extent (datafile 'D:\DB\tbfes01.dbf'size 1M)
Table altered.

SQL> alter table tableext allocate extent (datafile 'H:\DB\tbfes01.dbf' size 1M)
Table altered.

SQL> alter table tableext allocate extent (datafile 'I:\DB\tbfes01.dbf' size 1M)
Table altered.

SQL> conn sys/oracle@db as sysdba
Connected.

Step 8 : AFTER IMPORT and ADDING DATAFILES TABLESPACE SIZE
SQL> select file_name,autoextensible,bytes/1024/1024 MB from dba_data_files where tablespace_name in ('PRD','TBFES');

FILE_NAME                                     AUT         MB                                                                                         
--------------------------------------------- --- ----------                                                                                         
D:\DB\TBFES01.DBF                             YES        805                                                                                         
D:\DB\PRD01.DBF                               YES        470                                                                                         
H:\DB\TBFES01.DBF                             YES         10                                                                                         
I:\DB\TBFES01.DBF                             YES         10                                                                                         
I:\DB\PRD01.DBF                               YES         10                                                                                         
H:\DB\PRD01.DBF                               YES         10                                                                                         

6 rows selected.

Step 9 : IMPORTING INCREMENTED DUMP
SQL> host impdp directory=imp dumpfile=26022012.dmp logfile=log1.log parallel=4 remap_schema=scott:scott tables=scott.tableext table_exists_action=append exclude=indexes

SQL> select file_name,autoextensible,bytes/1024/1024 MB from dba_data_files where tablespace_name in ('PRD','TBFES');

FILE_NAME                                     AUT         MB                                                                                         
--------------------------------------------- --- ----------                                                                                         
D:\DB\TBFES01.DBF                             YES       1195                                                                                         
D:\DB\PRD01.DBF                               YES        635                                                                                         
H:\DB\TBFES01.DBF                             YES        358                                                                                         
I:\DB\TBFES01.DBF                             YES        338                                                                                         
I:\DB\PRD01.DBF                               YES        186                                                                                         
H:\DB\PRD01.DBF                               YES        172                                                                                         

6 rows selected.