interview que -ORACLE RAC (11g + 12c)


!! ORACLE RAC (11g + 12c)!!
















--------------------------------------------------------------------------
                            ORACLE RAC (11g + 12c)
--------------------------------------------------------------------------


*. Mention what is cluster?
    A cluster is referred to a group of independent, but connected servers that behaves as a single system.
       
*.What is RAC?
    RAC stands for Real Application cluster.
    It is a clustering solution from Oracle Corporation that ensures high availability of databases by providing instance failover, media failover features.
    Oracle RAC is a cluster database with a shared cache architecture that overcomes the limitations of traditional shared-nothing and shared-disk approaches to provide a highly scalable and available database solution for all the business applications.
    Oracle RAC provides the foundation for enterprise grid computing.

*.    What is Oracle RAC One Node?
    Oracle RAC one Node is a single instance running on one node of the cluster while the 2nd node is in cold standby mode. If the instance fails for some reason then RAC one node detect it and restart the instance on the same node or the instance is relocate to the 2nd node incase there is failure or fault in 1st node. The benefit of this feature is that it provides a cold failover solution and it automates the instance relocation without any downtime and does not need a manual intervention. Oracle introduced this feature with the release of 11gR2 (available with Enterprise Edition).

*. What is RAC and how is it different from non RAC databases?
    Oracle Real Application clusters allows multiple instances to access a single database, the instances will be running on multiple nodes. 
    In Real Application Clusters environments, all nodes concurrently execute transactions against the same database.
    Real Application Clusters coordinates each node's access to the shared data to provide consistency and integrity.'

*. What are the advantages of RAC (Real Application Clusters)?
    Reliability - if one node fails, the database won't fail'
    Availability - nodes can be added or replaced without having to shutdown the database
    Scalability - more nodes can be added to the cluster as the workload increases

*. What is Cache Fusion?
    Oracle RAC is composed of two or more instances. When a block of data is read from datafile by an instance within the cluster and another instance is in need of the same block, it is easy to get the block image from the instance which has the block in its SGA rather than reading from the disk. To enable inter instance communication Oracle RAC makes use of interconnects. The Global Enqueue Service (GES) monitors and Instance enqueue process manages the cache fusion.

*. How do we verify that RAC instances are running?
    SQL>select * from V$ACTIVE_INSTANCES;
    The query gives the instance number under INST_NUMBER column,host_:instancename under INST_NAME column.

*.Which is the "MASTER NODE" in RAC?
    The node with the lowest node number will become master node and dynamic remastering of the resources will take place.
    To find out the master node for particular resource, you can query v$ges_resource for MASTER_NODE column.
    To find out which is the master node, you can see ocssd.log file and search for "master node number".
    when the first master node fails in the cluster the lowest node number will become master node.   
   
*. Give few examples for solutions that support cluster storage?
    ·ASM (automatic storage management),
    ·Raw disk devices,
    ·Network file system (NFS),
    ·OCFS2 and
    ·OCFS (Oracle Cluster Fie systems).
   
*. What are Oracle Cluster Components?
    1.Cluster Interconnect (HAIP)
    2.Shared Storage (OCR/Voting Disk)
    3.Clusterware software
    4.Oracle Kernel Components

*. What are Oracle RAC Components?
    VIP, Node apps etc.
   
*.What are Oracle Kernel Components?
    Basically Oracle kernel need to switched on with RAC On option when you convert to RAC, that is the difference as it facilitates few RAC bg process like LMON,LCK,LMD,LMS etc.
   
   
*. What are Oracle database background processes specific to RAC?
    Oracle RAC is composed of two or more database instances. They are composed of Memory structures and background processes same as the single instance database.Oracle RAC instances use two processes GES(Global Enqueue Service), GCS(Global Cache Service) that enable cache fusion.Oracle RAC instances are composed of following background processes:
    ACMS—Atomic Controlfile to Memory Service (ACMS)
    GTX0-j—Global Transaction Process
    LMON—Global Enqueue Service Monitor
    LMD—Global Enqueue Service Daemon
    LMS—Global Cache Service Process
    LCK0—Instance Enqueue Process
    RMSn—Oracle RAC Management Processes (RMSn)
    RSMN—Remote Slave Monitor
    To ensure that each Oracle RAC database instance obtains the block that it needs to satisfy a query or transaction, Oracle RAC instances use two processes, the Global Cache Service (GCS) and the Global Enqueue Service (GES). The GCS and GES maintain records of the statuses of each data file and each cached block using a Global Resource Directory (GRD). The GRD contents are distributed across all of the active instances.
   
*. How to turn on RAC?
    # link the oracle libraries
    $ cd $ORACLE_HOME/rdbms/lib
    $ make -f ins_rdbms.mk rac_on
    # rebuild oracle
    $ cd $ORACLE_HOME/bin
    $ relink oracle
   
   
*. Disk architechture in RAC?
    SAN (Storage Area Networks) - generally using fibre to connect to the SAN
    NAS (Network Attached Storage) - generally using a network to connect to the NAS using either NFS, ISCSI

*. What are the Oracle Clusterware key components?
    Oracle Clusterware has two key components Cluster Registry OCR and Voting Disk.

*.    What is Voting Disk and OCR?
    • Voting Disk :
    Oracle RAC uses the voting disk to manage cluster membership by way of a health check and arbitrates cluster ownership among the instances in case of network failures. The voting disk must reside on shared disk.
    A node must be able to access more than half of the voting disks at any time.
    For example, if you have 3 voting disks configured, then a node must be able to access at least two of the voting disks at any time. If a node cannot access the minimum required number of voting disks it is evicted, or removed, from the cluster.

    • Oracle Cluster Registry (OCR) :
    The cluster registry holds all information about nodes, instances, services and ASM storage if used, it also contains state information ie they are available and up or similar.
    The OCR must reside on shared disk that is accessible by all of the nodes in your cluster.
   
   
*.What are the administrative tasks involved with voting disk? [428681.1]
    Following administrative tasks are performed with the voting disk :
    1) Backing up voting disks        ./ocrconfig -export /backup/ocrvot_bkp/ocr.dmp or  dd if=/dev/raw/raw2 of=/backup/ocrvot_bkp/voting.dmp
    2) Recovering Voting disks
    3) Adding voting disks             ./ocrconfig -add /dev/raw/raw3 OR  ./crsctl add css votedisk /dev/raw/raw5 -force
    4) Deleting voting disks
    5) Moving voting disks
   
# show backups
ocrconfig -showbackup

# to change the location of the backup, you can even specify a ASM disk
ocrconfig -backuploc <path|+asm>

# perform a backup, will use the location specified by the -backuploc location
ocrconfig -manualbackup

# perform a restore
ocrconfig -restore <file>

# delete a backup
orcconfig -delete <file>

Note: there are many more option so see the ocrconfig man page ## add/relocate the ocrmirror file to the specified location
ocrconfig -replace ocrmirror '/ocfs2/ocr2.dbf'

## relocate an existing OCR file
ocrconfig -replace ocr '/ocfs1/ocr_new.dbf'

## remove the OCR or OCRMirror file
ocrconfig -replace ocr
ocrconfig -replace ocrmirror
   
*. Can you add voting disk online? Do you need voting disk backup?
    Yes,  as per documentation, if you have multiple voting disk you can add online, but if you have only one voting disk , by that cluster will be down as its lost you just need to start crs in exclusive mode and add the votedisk using
    crsctl add votedisk <path>
   
   
*. What are the major RAC wait events?
    In a RAC environment the buffer cache is global across all instances in the cluster and hence the processing differs.The most common wait events related to this are gc cr request and gc buffer busy

    • GC CR request :the time it takes to retrieve the data from the remote cache
    Reason: RAC Traffic Using Slow Connection or Inefficient queries (poorly tuned queries will increase the amount of data blocks requested by an Oracle session. The more blocks requested typically means the more often a block will need to be read from a remote instance via the interconnect.)

    • GC BUFFER BUSY: It is the time the remote instance locally spends accessing the requested data block.
   
*. What do you do if you see GC CR BLOCK LOST in top 5 Timed Events in AWR Report?
    This is most likely due to a fault in interconnect network.
    Check netstat -s
    if you see "fragments dropped" or "packet reassemblies failed" , Work with your system administrator find the fault with network.
   
*.What is GRD?
    GRD stands for Global Resource Directory. The GES and GCS maintains records of the statuses of each datafile and each cahed block using global resource directory.This process is referred to as cache fusion and helps in data integrity.

*.What is ACMS?
    ACMS stands for Atomic Controlfile Memory Service.In an Oracle RAC environment ACMS is an agent that ensures a distributed SGA memory update(ie)SGA updates are globally committed on success or globally aborted in event of a failure.

*. What is SCAN listener?
    A scan listener is something that additional to node listener which listens the incoming db connection requests from the client which got through the scan IP, it got end points configured to node listener where it routes the db connection requests to particular node listener.

    SCAN IP can be disabled if not required. However SCAN IP is mandatory during the RAC installation. Enabling/disabling SCAN IP is mostly used in oracle apps environment by the concurrent manager (kind of job scheduler in oracle apps).
   
*. What is SCAN? (11gR2 feature)
-->
    Single Client Access Name (SCAN) is s a new Oracle Real Application Clusters (RAC) 11g Release 2
    feature that provides a single name for clients to access an Oracle Database running in a cluster. The benefit
    is clients using SCAN do not need to change if you add or remove nodes in the cluster.

    SCAN provides a single domain name via (DNS), allowing and-users to address a RAC cluster as-if it were a
    single IP address. SCAN works by replacing a hostname or IP list with virtual IP addresses (VIP).

    Single client access name (SCAN) is meant to facilitate single name for all Oracle clients to connect to the cluster
    database, irrespective of number of nodes and node location. Until now, we have to keep adding multiple address
    records in all clients tnsnames.ora, when a new node gets added to or deleted from the cluster.

    Single Client Access Name (SCAN) eliminates the need to change TNSNAMES entry when nodes are added to or removed from the
    Cluster. RAC instances register to SCAN listeners as remote listeners. Oracle recommends assigning 3 addresses to SCAN,
    which will create 3 SCAN listeners, though the cluster has got dozens of nodes.. SCAN is a domain name registered to at
    least one and up to three IP addresses, either in DNS (Domain Name Service) or GNS (Grid Naming Service). The SCAN must
    resolve to at least one address on the public network. For high availability and scalability, Oracle recommends configuring
    the SCAN to resolve to three addresses.tly used in oracle apps environment by the concurrent manager (kind of job scheduler in oracle apps).

*.  What is difference between RAC ip addresses ?

    Public IP adress : is the normal IP address typically used by DBA and SA to manage storage,
                       system and database. Public IP addresses are reserved for the Internet.
    Private IP address : is used only for internal clustering processing (Cache Fusion) (aka as interconnect).
                       Private IP addresses are reserved for private networks.
    VIP : is used by database applications to enable fail over when one cluster node fails. The purpose for having VIP is so
        client connection can be failover to surviving nodes in case there is failure           
       
*. What is split brain?

    When database nodes in a cluster are unable to communicate with each other, they may continue to process and modify the
    data blocks independently. If the same block is modified by more than one instance, synchronization/locking of the data
    blocks does not take place and blocks may be overwritten by others in the cluster. This state is called split brain.
   
*. What is cache fusion?
    In a RAC environment, it is the combining of data blocks, which are shipped across the interconnect from remote database caches (SGA) to the local node, in order to fulfill the requirements for a transaction (DML, Query of Data Dictionary).
   
*.    What is the difference between Crash recovery and Instance recovery?
    When an instance crashes in a single node database on startup a crash recovery takes place. In a RAC enviornment the same recovery for an instance is performed by the surviving nodes called Instance recovery.

*.What is an interconnect network?(private )
    An interconnect network is a private network that connects all of the servers in a cluster. The interconnect network uses a switch/multiple switches that only the nodes in the cluster can access.

*. How can we configure the cluster interconnect?
    · Configure User Datagram Protocol (UDP) on Gigabit Ethernet for cluster interconnects.
    · On UNIX and Linux systems we use UDP and RDS (Reliable data socket) protocols to be used by Oracle Clusterware.
    · Windows clusters use the TCP protocol.
*.  What is VIP IP used for?
    It returns a dead connection IMMIDIATELY, when its primary node fails. Without using VIP IP, the clients have to wait around 10 minutes to receive ORA-3113: “end of file on communications channel”. However, using Transparent Application Failover (TAF) could avoid ORA-3113.

*. What is the purpose of Private Interconnect?
    Clusterware uses the private interconnect for cluster synchronization (network heartbeat) and daemon communication between the the clustered nodes. This communication is based on the TCP protocol.
    RAC uses the interconnect for cache fusion (UDP) and inter-process communication (TCP). Cache Fusion is the remote memory mapping of Oracle buffers, shared between the caches of participating nodes in the cluster.
   
*. What are SCAN components in a cluster?
    1.SCAN Name
    2.SCAN IPs (3)
    3.SCAN Listeners (3)
*. What is FAN?
    Fast application Notification as it abbreviates to FAN relates to the events related to instances,services and nodes.This is a notification mechanism that Oracle RAc uses to notify other processes about the configuration and service level information that includes service status changes such as,UP or DOWN events.Applications can respond to FAN events and take immediate action.
   
*. What is TAF?
    TAF (Transparent Application Failover) is a configuration that allows session fail-over between different nodes of a RAC database cluster.
    Transparent Application Failover (TAF). If a communication link failure occurs after a connection is established, the connection fails over to another active node. Any disrupted transactions are rolled back, and session properties and server-side program variables are lost. In some cases, if the statement executing at the time of the failover is a Select statement, that statement may be automatically re-executed on the new connection with the cursor positioned on the row on which it was positioned prior to the failover.

    After an Oracle RAC node crashes—usually from a hardware failure—all new application transactions are automatically rerouted to a specified backup node. The challenge in rerouting is to not lose transactions that were "in flight" at the exact moment of the crash. One of the requirements of continuous availability is the ability to restart in-flight application transactions, allowing a failed node to resume processing on another server without interruption. Oracle's' answer to application failover is a new Oracle Net mechanism dubbed Transparent Application Failover. TAF allows the DBA to configure the type and method of failover for each Oracle Net client.
    TAF architecture offers the ability to restart transactions at either the transaction (SELECT) or session level.   
   
*. What are the characteristics controlled by Oracle services feature?
    The characteristics include a unique name, workload balancing, failover options, and high availability.
   


   
   
Process Name            Functionality
crsd                    •The CRS daemon (crsd) manages cluster resources based on configuration information that is stored in                          Oracle Cluster Registry (OCR) for each resource. This includes start, stop, monitor, and failover                           operations. The crsd process generates events when the status of a resource changes.
cssd                    •Cluster Synchronization Service (CSS): Manages the cluster configuration by controlling which nodes                          are members of the cluster and by notifying members when a node joins or leaves the cluster. If you                          are using certified third-party clusterware, then CSS processes interfaces with your clusterware to                          manage node membership information. CSS has three separate processes: the CSS daemon (ocssd), the CSS                            Agent (cssdagent), and the CSS Monitor (cssdmonitor). The cssdagent process monitors the cluster                         and provides input/output fencing. This service formerly was provided by Oracle Process Monitor                         daemon (oprocd), also known as OraFenceService on Windows. A cssdagent failure results in Oracle C                           lusterware restarting the node.
diskmon                    •Disk Monitor daemon (diskmon): Monitors and performs input/output fencing for Oracle Exadata Storage                           Server. As Exadata storage can be added to any Oracle RAC node at any point in time, the diskmon                            daemon is always started when ocssd is started.
evmd                    •Event Manager (EVM): Is a background process that publishes Oracle Clusterware events
mdnsd                    •Multicast domain name service (mDNS): Allows DNS requests. The mDNS process is a background process                          on Linux and UNIX, and a service on Windows.
gnsd                    •Oracle Grid Naming Service (GNS): Is a gateway between the cluster mDNS and external DNS servers. The                             GNS process performs name resolution within the cluster.
ons                        •Oracle Notification Service (ONS): Is a publish-and-subscribe service for communicating Fast                             Application Notification (FAN) events
oraagent                •oraagent: Extends clusterware to support Oracle-specific requirements and complex resources. It runs                             server callout scripts when FAN events occur. This process was known as RACG in Oracle Clusterware                             11g Release 1 (11.1).
orarootagent            •Oracle root agent (orarootagent): Is a specialized oraagent process that helps CRSD manage resources                             owned by root, such as the network, and the Grid virtual IP address
oclskd                    •Cluster kill daemon (oclskd): Handles instance/node evictions requests that have been escalated to CSS
gipcd                    •Grid IPC daemon (gipcd): Is a helper daemon for the communications infrastructure
ctssd                    •Cluster time synchronisation daemon(ctssd) to manage the time syncrhonization between nodes, rather                         depending on NTP   
   


*.  Under which user or owner the process will start?
    (http://db.geeksinsight.com/2012/09/28/11g-grid-infrastructure-rac-crs-startup-sequence/)

    Component                                        Name of the Process                    Owner
   
    Oracle High Availability Service                ohasd                                init, root
    Cluster Ready Service (CRS)                        Cluster Ready Services                root
    Cluster Synchronization Service (CSS)            ocssd,cssd monitor, cssdagent        grid owner
    Event Manager (EVM)                                evmd, evmlogger                        grid owner
    Cluster Time Synchronization Service (CTSS)        octssd                                root
    Oracle Notification Service (ONS)                ons, eons                            grid owner
    Oracle Agent                                    oragent                                grid owner
    Oracle Root Agent                                orarootagent                        root
    Grid Naming Service (GNS)                        gnsd                                root
    Grid Plug and Play (GPnP)                        gpnpd                                grid owner
    Multicast domain name service (mDNS)            mdnsd                                grid owner
   


   
*. What enables the load balancing of applications in RAC?
    Oracle Net Services enable the load balancing of application connections across all of the instances in an Oracle RAC database.

*. LOAD BALANCING in RAC:-
    The Oracle RAC system can distribute the load over many nodes this feature called as load balancing.

    There are two methods of load balancing
    1.Client load balancing
    2.Server load balancing

    1.Client Load Balancing
        Client Load Balancing distributes new connections among Oracle RAC nodes so that no one server is overloaded with connection requests and it is configured at net service name level by providing multiple descriptions in a description list or multiple addresses in an address list. For example, if connection fails over to another node in case of failure, the client load balancing ensures that the redirected connections are distributed among the other nodes in the RAC.

        Configure Client-side connect-time load balancing by setting LOAD_BALANCE=ON in the corresponding client side TNS entry.

                    TESTRAC =
                    (DESCRIPTION =
                    (ADDRESS_LIST=
                    (LOAD_BALANCE = ON)
                    (ADDRESS = (PROTOCOL = TCP)(HOST = TESTRAC1-VIP)(PORT = 1521))
                    (ADDRESS = (PROTOCOL = TCP)(HOST = TESTRAC2-VIP)(PORT = 1521))
                    )
                    (CONNECT_DATA = (SERVICE_NAME = testdb.selectstarfrom.com))
                    )
                   
        2.Server Load Balancing
            Server Load Balancing distributes processing workload among Oracle RAC nodes. It divides the connection load evenly between all available listeners and distributes new user session connection requests to the least loaded listener(s) based on the total number of sessions which are already connected. Each listener communicates with the other listener(s) via each database instance’s PMON process.

            Configure Server-side connect-time load balancing feature by setting REMOTE_LISTENERS initialization parameter of each instance to a TNS name that describes list of all available listeners.

                        TESTRAC_LISTENERS =
                        (DESCRIPTION =
                        (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = TESTRAC1)(PORT = 1521)))
                        (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = TESTRAC2)(PORT = 1521))))
                        )
                       
                Set *.remote_listener= TESTRAC_LISTENERS’ initialization parameter in the database’s shared SPFILE and add TESTRAC_LISTENERS’ entry to the TNSNAMES.ORA file in the Oracle Home of each node in the cluster.

    Once you configure Server-side connect-time load balancing, each database’s PMON process will automatically register the database with the database’s local listener as well as cross-register the database with the listeners on all other nodes in the cluster. Now the nodes themselves decide which node is least busy, and then will connect the client to that node.

*.AILOVER in RAC:-
    The Oracle RAC system can protect against failures caused by O/S or server crashes or hardware failures. When a node failure occurs in RAC system, the connection attempts can fail over to other surviving nodes in the cluster this feature called as Failover.

    There are two methods of failover
    1. Connection Failover
    2. Transparent Application Failover (TAF)
   
        1. Connection Failover
        If a connection failure occurs at connect time, the application failover the connection to another active node in the cluster. This feature enables client to connect to another listener if the initial connection to the first listener fails.
   
        Enable client-side connect-time Failover by setting FAILOVER=ON in the corresponding client side TNS entry.

                            TESTRAC =
                            (DESCRIPTION =
                            (ADDRESS_LIST=
                            (LOAD_BALANCE = ON)
                            (FAILOVER = ON)
                            (ADDRESS = (PROTOCOL = TCP)(HOST = TESTRAC1-VIP)(PORT = 1521))
                            (ADDRESS = (PROTOCOL = TCP)(HOST = TESTRAC2-VIP)(PORT = 1521))
                            )
                            (CONNECT_DATA = (SERVICE_NAME = testdb.selectstarfrom.com))
                            )
                           
    If LOAD_BALANCE is set to on then clients randomly attempt connections to any nodes. If client made connection attempt to a down node, the client needs to wait until it receives the information that the node is not accessible before trying alternate address in ADDRESS_LIST.

    2. Transparent Application Failover (TAF)
            If connection failure occurs after a connection is established, the connection fails over to other surviving nodes. Any uncommitted transactions are rolled back and server side program variables and session properties will be lost. In some case the select statements automatically re-executed on the new connection with the cursor positioned on the row on which it was positioned prior to the failover.

                        TESTRAC =
                        (DESCRIPTION =
                        (LOAD_BALANCE = ON)
                        (FAILOVER = ON)
                        (ADDRESS = (PROTOCOL = TCP)(HOST = TESTRAC1-VIP)(PORT = 1521))
                        (ADDRESS = (PROTOCOL = TCP)(HOST = TESTRAC1-VIP)(PORT = 1521))
                        (CONNECT_DATA =
                        (SERVICE_NAME = testdb.selectstarfrom.com)
                        (FAILOVER_MODE = (TYPE = SELECT)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5))
                        )
                        )
   

*. What is the difference between CRSCTL and SRVCTL?
    crsctl manages clusterware-related operations:
    Starting and stopping Oracle Clusterware
    Enabling and disabling Oracle Clusterware daemons
    Registering cluster resources

    srvctl manages Oracle resource–related operations:
    Starting and stopping database instances and services
    Also from 11gR2 manages the cluster resources like network,vip,disks etc
   
   
*.What is hangcheck timer?
    The hangcheck timer checks regularly the health of the system. If the system hangs or stop the node will be restarted automatically.
    There are 2 key parameters for this module:
    -> hangcheck-tick: this parameter defines the period of time between checks of system health. The default value is 60 seconds; Oracle recommends setting it to 30seconds.
    -> hangcheck-margin: this defines the maximum hang delay that should be tolerated before hangcheck-timer resets the RAC node.

   
*. State the initialization parameters that must have same value for every instance in an Oracle RAC database?
    Some initialization parameters are critical at the database creation time and must have same values.Their value must be specified in SPFILE or PFILE for every instance.The list of parameters that must be identical on every instance are given below:
    ACTIVE_INSTANCE_COUNT
    ARCHIVE_LAG_TARGET
    COMPATIBLE
    CLUSTER_DATABASE
    CLUSTER_DATABASE_INSTANCE
    CONTROL_FILES
    DB_BLOCK_SIZE
    DB_DOMAIN
    DB_FILES
    DB_NAME
    DB_RECOVERY_FILE_DEST
    DB_RECOVERY_FILE_DEST_SIZE
    DB_UNIQUE_NAME
    INSTANCE_TYPE (RDBMS or ASM)
    PARALLEL_MAX_SERVERS
    REMOTE_LOGIN_passWORD_FILE
    UNDO_MANAGEMENT
   
   
*. How to find location of OCR file when CRS is down?
    If you need to find the location of OCR (Oracle Cluster Registry) but your CRS is down.
    On Linux: /etc/oracle/ocr.loc
    On Solaris: /var/opt/oracle/ocr.loc


   
   
   
COMMANDS : ----------------------------------->



COMMAND                                                     PERPOSE                             USER
#crsctl stop crs                                            STOP crs                             root
#crsctl disable crs
#crsctl enable crs
#crsctl start crs
$crs_stat or
$crsctl stat res -t ------> 11gr2
$crsctl query crs activeversion
$crsctl query crs softwareversion [node_name]
$crsctl start crs
$crsctl stop crs
#/etc/init.d/init.crs start
#/etc/init.d/init.crs stop
#/etc/init.d/init.cssd stop
#/etc/init.d/init.cssd start
$crsctl enable crs
$crsctl disable crs
#/etc/init.d/init.crs enable
#/etc/init.d/init.crs disable
$crsctl check crs
$crsctl check cluster [-node node_name]
$crsctl check cssd
$crsctl check crsd
$crsctl check evmd
$crsctl check css votedisk
$crsctl query css votedisk
$crsctl add css votedisk <PATH>
$crsctl delete css votedisk <PATH>
$crsctl start resources
$crsctl stop resources
$crs_stat
$crs_register
$crs_unregister
$crs_start
$crs_stop
$crs_getperm
$crs_profile
$crs_relocate
$crs_setperm

Dual Environment CRSCTL Commands:

    crsctl add resource
    crsctl add type
    crsctl check css
    crsctl delete resource
    crsctl delete type
    crsctl get hostname
    crsctl getperm resource
    crsctl getperm type
    crsctl modify resource
    crsctl modify type
    crsctl setperm resource
    crsctl setperm type
    crsctl start resource
    crsctl status resource
    crsctl status type
    crsctl stop resource
   
cemulto -n        ---CLUSTER NAME
gsdctl             ---global service demon
oifcfg getif    ---oracle interphse
    oicfg setif -global <interface name>/<subnet>:public
    oicfg setif -global <interface name>/<subnet>:cluster_interconnect

olsnodes -n/l/g


SRVCTL COMMANDS

#srvctl stop instance -d <database_name> -n <node_name>
#srvctl stop vip -n <node_name> -f
$srvctl config nodeapps -a
$ifconfig -a
#$GRID_HOME/bin/srvctl start scan
#$GRID_HOME/bin/srvctl start scan_listener
#$GRID_HOME/bin/srvctl stop scan_listener
#$GRID_HOME/bin/srvctl stop scan
#$GRID_HOME/bin/srvctl status scan_listener
#$GRID_HOME/bin/srvctl status scan
#$GRID_HOME/bin/srvctl config scan
$nslookup <scan-name>




Directory Path                                                     Contents
-------------------------------------------------------------------------------------------------------------------------
GRID_HOME/log/<host>/alert<host>.log                          -- Clusterware alert log
GRID_HOME/log/<host>/diskmon                                 -- Disk Monitor Daemon
GRID_HOME/log/<host>/client                                 -- OCRDUMP, OCRCHECK, OCRCONFIG, CRSCTL
GRID_HOME/log/<host>/ctssd                                     -- Cluster Time Synchronization Service
GRID_HOME/log/<host>/gipcd                                     -- Grid Interprocess Communication Daemon
GRID_HOME/log/<host>/ohasd                                     -- Oracle High Availability Services Daemon
GRID_HOME/log/<host>/crsd                                     -- Cluster Ready Services Daemon
GRID_HOME/log/<host>/gpnpd                                     -- Grid Plug and Play Daemon
GRID_HOME/log/<host>/mdnsd                                     -- Mulitcast Domain Name Service Daemon
GRID_HOME/log/<host>/evmd                                     -- Event Manager Daemon
GRID_HOME/log/<host>/racg/racgmain                             -- RAC RACG
GRID_HOME/log/<host>/racg/racgeut                             -- RAC RACG
GRID_HOME/log/<host>/racg/racgevtf                             -- RAC RACG
GRID_HOME/log/<host>/racg                                     -- RAC RACG (only used if pre-11.1 database is installed)
GRID_HOME/log/<host>/cssd                                     -- Cluster Synchronization Service Daemon
GRID_HOME/log/<host>/srvm                                     -- Server Manager
GRID_HOME/log/<host>/agent/ohasd/oraagent_oracle11             -- HA Service Daemon Agent
GRID_HOME/log/<host>/agent/ohasd/oracssdagent_root             -- HA Service Daemon CSS Agent
GRID_HOME/log/<host>/agent/ohasd/oracssdmonitor_root         -- HA Service Daemon ocssdMonitor Agent
GRID_HOME/log/<host>/agent/ohasd/orarootagent_root             -- HA Service Daemon Oracle Root Agent
GRID_HOME/log/<host>/agent/crsd/oraagent_oracle11             -- CRS Daemon Oracle Agent
GRID_HOME/log/<host> agent/crsd/orarootagent_root             -- CRS Daemon Oracle Root Agent
GRID_HOME/log/<host> agent/crsd/ora_oc4j_type_oracle11g     -- CRS Daemon Oracle OC4J Agent
GRID_HOME/log/<host>/gnsd                                     -- Grid Naming Service Daemon

interview questions : core database

!! oracle core database interview questions :!!






68. What is Cursor ?
-- A Cursor is a handle ( a name or pointer) for the memory associated with a
-- specific statement

21. What is an Index ?
-- An Index is an optional structure associated with a table to have direct access
-- to rows,which can be created to increase the performance of data retrieval. Index
-- can be created on one or more columns of a table.

22. How are Indexes Update ?
/*
    Indexes are automatically maintained and used by ORACLE. Changes to table data are
    automatically incorporated into all relevant indexes.
*/

23. What are Clusters ?
/*
    Clusters are groups of one or more tables physically stores together to share common
    columns and are often used together.
*/

24. What is cluster Key ?
/*
    The related columns of the tables in a cluster is called the Cluster Key.
*/

25. What is Index Cluster ?
/*
    A Cluster with an index on the Cluster Key.
*/

26. What is Hash Cluster ?
/*
    A row is stored in a hash cluster based on the result of applying a hash function
    to the rows cluster key value. All rows with the same hash key value are stores
    together on disk.
*/

27. When can Hash Cluster used ?
/*
    Hash clusters are better choice when a table is often queried with equality queries.
    For such queries the specified cluster key value is hashed. The resulting hash key
    value points directly to the area on disk that stores the specified rows.
*/

111. What is a Procedure ?
/*
    A Procedure consist of a set of SQL and PL/SQL statements that are grouped together
    as a unit to solve a specific problem or perform a set of related tasks.
*/

112. What is difference between Procedures and Functions ?
/*
    A Function returns a value to the caller where as a Procedure does not.
*/

113. What is a Package ?
/*
    A Package is a collection of related procedures, functions, variables and other
    package constructs together as a unit in the database.
*/

114. What are the advantages of having a Package ?
/*
    Increased functionality (for example,global package variables can be declared
    and used by any proecdure in the package) and performance (for example all objects
    of the package are parsed compiled, and loaded into memory once)
*/

115. What is Database Trigger ?
/*   
    A Database Trigger is procedure (set of SQL and PL/SQL statements) that is
    automatically executed as a result of an insert in,update to, or delete from a
    table.
*/

116. What are the uses of Database Trigger ?
/*
    Database triggers can be used to automatic data generation, audit data modifications,
    enforce complex Integrity constraints, and customize complex security authorizations.
*/

117. What are the differences between Database Trigger and Integrity constraints ?

/*  A declarative integrity constraint is a statement about the database that is always true.
    A constraint applies to existing data in the table and any statement that manipulates the table.

    A trigger does not apply to data loaded before the definition of the trigger,
    therefore, it does not guarantee all data in a table conforms to the rules
    established by an associated trigger.

    A trigger can be used to enforce transitional constraints where as a declarative
    integrity constraint cannot be used.
*/

28. What is Database Link ?
--  A database link is a named object that describes a "path" from one database to
--  another.

29. What are the types of Database Links ?
--  Private Database Link, Public Database Link & Network Database Link.

30. What is Private Database Link ?
--  Private database link is created on behalf of a specific user. A private database
--  link can be used only when the owner of the link specifies a global object name
--  in a SQL statement or in the definition of the owners views or procedures.

31. What is Public Database Link ?
--  Public database link is created for the special user group PUBLIC. A public database
--  link can be used when any user in the associated database specifies a global object
--  name in a SQL statement or object definition.

32. What is Network Database Link ?
--  Network database link is created and managed by a network domain service. A network
--  database link can be used when any user of any database in the network specifies a
--  global object name in a SQL statement or object definition.

33. What is Data Block ?
--  ORACLE databases data is stored in data blocks. One data block corresponds to a
--  specific number of bytes of physical database space on disk.

34. How to define Data Block size ?
--  A data block size is specified for each ORACLE database when the database is
--  created. A database users and allocated free database space in ORACLE datablocks.
--  Block size is specified in INIT.ORA file and cannt be changed latter.

35. What is Row Chaining ?
--  In Circumstances, all of the data for a row in a table may not be able to fit in
--  the same data block. When this occurs , the data for the row is stored in a chain
--  of data block (one or more) reserved for that segment.

36. What is an Extent ?
--  An Extent is a specific number of contiguous data blocks, obtained in a single
--  allocation, used to store a specific type of information.

37. What is a Segment ?
--  A segment is a set of extents allocated for a certain logical structure.

38. What are the different type of Segments ?
--  Data Segment, Index Segment, Rollback Segment and Temporary Segment.

39. What is a Data Segment ?
--  Each Non-clustered table has a data segment. All of the tables data is stored
--  in the extents of its data segment. Each cluster has a data segment. The data
--  of every table in the cluster is stored in the clusters data segment.

40. What is an Index Segment ?
--  Each Index has an Index segment that stores all of its data.

41. What is Rollback Segment ?
--  A Database contains one or more Rollback Segments to temporarily store "undo"
--  information.

42. What are the uses of Rollback Segment ?
--    Rollback Segments are used :To generate read-consistent database information
--    during database recovery to rollback uncommitted transactions for users.
1) How do you switch from an init.ora file to a spfile?
-> Issue the create spfile from pfile command.


2) Explain the difference between a data block, an extent and a segment.
-> A data block is the smallest unit of logical storage for a database object.
As objects grow they take chunks of additional storage that are composed of
contiguous data blocks. These groupings of contiguous data blocks are called extents.
All the extents that an object takes when grouped together are considered the segment
of the database object.


3) Where would you look for errors from the database engine?
-> In the alert log.


4) Compare and contrast TRUNCATE and DELETE for a table.
-> Both the truncate and delete command have the desired outcome of getting rid of all the
rows in a table. The difference between the two is that the truncate command is a DDL operation
and just moves the high water mark and produces a now rollback. The delete command, on the other
hand, is a DML operation, which will produce a rollback and thus take longer to complete.


5) Give the reasoning behind using an index. ?
-> Faster access to data blocks in a table.


6) What type of index should you use on a fact table?
-> A Bitmap index.


7) Give two examples of referential integrity constraints.
-> A primary key and a foreign key.

8) Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode.?
-> ARCHIVELOG mode is a mode that you can put the database in for creating a backup of all transactions
that have occurred in the database so that you can recover to any point in time.

NOARCHIVELOG mode is basically the absence of ARCHIVELOG mode and has the disadvantage
of not being able to recover to any point in time.
NOARCHIVELOG mode does have the advantage of not having to write transactions to an
archive log and thus increases the performance of the database slightly.


9) What command would you use to create a backup control file?
-> Alter database backup control file to trace.


10) Give the stages of instance startup to a usable state where normal users may access it. ?
->
STARTUP NOMOUNT - Instance startup

STARTUP MOUNT - The database is mounted

STARTUP OPEN - The database is opened


11) Explain the difference between $ORACLE_HOME and $ORACLE_BASE.?
-> ORACLE_BASE is the root directory for oracle. ORACLE_HOME located beneath
ORACLE_BASE where the oracle products reside.



12) Explain the difference between Pfile and Spfile ?
-> Pfile is Text file, where as SPfile is binary file which is created from pfile
before database is startup.


13) Explain logical and physical part of Oracle database in short
-> logical is tablespace and physical is datafile.


14) What view(s) do you use to associate a user’s SQLPLUS session with his o/s process?
-> v$session and v$process


15) What is an Integrity Constrains ?  
-> An integrity constraint is a declarative way to define a business rule for a column of a table. 


16) What is SYSTEM tablespace and when is it Created? Subscribe 
-> Every ORACLE database contains a tablespace named SYSTEM, which is automatically
created when the database is created. The SYSTEM tablespace always contains the
data dictionary tables for the entire database.


17) How are Indexes Update ? 
-> Indexes are automatically maintained and used by ORACLE. Changes to table
data are automatically incorporated into all relevant indexes. 


18) What is Data Block ? Subscribe  ?
-> ORACLE databases data is stored in data blocks. One data block corresponds to a specific
number of bytes of physical database space on disk


19)RE: what is the back ground process in oracle architec.?
-> the mandatory background process for 9i is 5.
   they are SMON,PMON,CKPT,DBWR,LGWR.
  
 The Background process related to Oracle Architecture are as follows:

    1.DBWR(DATABASE WRITER)
    2.LGWR(LOG WRITER)
    3.SMON(SYSTEM MONITOR)
    4.PMON(PROCESS MONITOR)
    5.CKPT(CHECK POINT)
    6.SERVER
    7.CJQ(CO-ORDINATOR JOB QUEUE PROCESSES)
    8.RECOVER
    9.DISPATCHER
    10.ARCHIVER 

Including some more from Oracle 11G
    1) VKTM (Virtual Keeper of TiMe keeps the "SGA time" variable current)
    2) GEN 0 (General Task Execution Process)
    3)









*. What is Oltp database?
        OLTP means Online Transaction Processing. OLAP means Online Analytical Processing. OLTP deals with processing of data from transactional systems. For example, an application that loads the reservation data of a hotel is an OLTP system. An OLTP system is designed mainly keeping in the mind the performance of the end application. It comprises of the application, database & the reporting system that directly works on this database. The database in an OLTP system would be designed in a manner as to facilitate the improvement in the application efficiency thereby reducing the processing time of the application.

*. What is Olap database?
        OLAP systems were mainly developed using data in a warehouse. Having said that a need was felt to isolate older data, it was necessary to store them in a format that would be useful in easing out the reporting bottlenecks. A need was felt to isolate the data & redesign the application data to such a format & structure that this data repository would be the prime source of business decisions. Coming back to OLAP systems, these systems were mainly developed on the isolated data.
*. What is the function of Optimizer?
        The goal of the optimizer is to choose the most efficient way to execute a SQL statement.
   
*. What is Execution Plan?
        The combination of the steps the optimizer chooses to execute a statement is called an execution plan.
   
*. What are the different approaches used by Optimizer in choosing an execution plan?
        Rule-based and Cost-based.
   
*. What is dictionary cache?
        The dictionary cache stores “metadata” (data about your tables and indexes) and it’s also known as the row cache. It is used to cache data dictionary related information in RAM for quick access. The dictionary cache is like the buffer cache, except it’s for Oracle data dictionary information instead of user information.
   
*.     What is a Data Dictionary?
    The Oracle data dictionary is one of the most important components of the Oracle DBMS.It contains all information about the structures and objects of the database such as tables,columns, users, data files etc. The data stored in the data dictionary are also often called metadata.
   
*.     What is Database Buffers?
        Database buffers are cache in the SGA used to hold the data blocks that are read from the data    segments in the database such as tables, indexes and clusters DB_BLOCK_BUFFERS parameter in INIT.ORA decides the size
       
*. What is the functionality of SYSTEM table space?
        System tablespace is a main part of oracle database. All the database information is in it.it is created when database is created.It is managed by oracle server . dba cannot change its contents. it contains the data dictionary objects .

*.  What is the function of checkpoint (CKPT)?
        Checkpoint is a background process which ensures dbwn process has written data to datafiles and upadates control file and datafile header to establish data consistency.The CKPT is also useful to get the point in time from where to begin the recovery in case of failure.
*. When ckpt occurs?  
     1. For every 3 seconds
     2. When 1/3rd of DB buffer fills
     3. When log swtich occurs
     4. When database shuts down
   
*. When does LGWR write to the database?
        Log Writer (LGWR) writes redo log entries. it is generated in the redo log buffer of the SGA to on-line Redo Log File.LGWR writes  redo  log  entries  into an  on-line  redo  log  file  when transactions commit and the log buffer files are full.
   
*.      What is Shared SQL Area ?
        A shared SQL area contains the parse tree and execution plan for a given SQL statement. Oracle saves memory by using one shared SQL area for SQL statements run multiple times, which often happens when many users run the same application.Oracle allocates memory from the shared pool when a new SQL statement is parsed, to store in the shared SQL area. The size of this memory depends on the complexity of the statement. If the entire shared pool has already been allocated, Oraclecan deallocate items from the pool using a modified LRU (least recently used) algorithm until there is enough free space for the new statement's shared SQL area.'
       
*. What Does DBWR do?
        Database writer writes modified blocks from the database buffer cache to the data files.
       
*. What is server processes?
        A server process is one that handles user requests. When you type in a SQL statement, the server process handles the parsing and running of that SQL statement,

*.    Which background process performs Crash recovery? 
        SMON (system monitor)
       
*.    What is On-line Redo Log?
        The On-line Redo Log is a set of tow or more on-line redo files that record all committed changes made to the database. Whenever a transaction is committed, the  corresponding redo entries temporarily stores in redo log buffers of the SGA are   written to an on-line redo log file by the background process LGWR. The on-line redo log files are used in cyclical fashion.

*.  What are the steps involved in Instance Recovery?
        Rolling forward to recover data that has not been recorded in data files yet has      been recorded in the on-line redo log, including the contents of rollback segments. Rolling back transactions that have been explicitly rolled back or have  not been committed as indicated by the rollback segments regenerated in step a. Releasing any resources (locks) held      by transactions in process at the time of the failure. Resolving any Pending distributed transactions undergoing a two-phase commit at the time of the instance failure.
*.    What does COMMIT do?
        COMMIT makes permanent the changes resulting from all SQL statements in the transaction. The changes made by  the SQL statements of a transaction become visible to other user sessions transactions that start only after transaction  is committed.

*.  What are the steps involved in Database Startup?
    Start an instance, Mount the Database and Open the Database.

*. What are the steps involved in Database Shutdown?
    Close the Database; Dismount the Database and Shutdown the Instance.

*. What is Restricted Mode of Instance Startup?
    An instance can be started in restricted mode so that when the database is open connections are limited only to those whose user accounts have been granted the RESTRICTED SESSION system privilege.

*. What mode the instance should be to create the database?
    No mount

*. While creating database can you specify the size of control files?
      No

*. Which parameter determines the size of SHARED POOL?
    SHARED_POOL_SIZE.
   
*. What is a trace file and how is it created?
    Each server and background process can write an associated trace file. When an internal error is detected by a process or user process, it dumps information about the error to its trace. This can be used for tuning the database.

*.     What is a Tablespace?
        A database is divided into Logical Storage Unit called tablespaces.A tablespace is used to grouped related logical structures together
       
*.      What are the Characteristics of Data Files?
        A data file can be associated with only one Tablespaces. One or more data files can be use as data of database storage called a tablespace.
       
*.     How do you drop a tablespace, if it has database objects?
    Drop tablespace tablespacename including contents
   
*.  How to rename a datafile?
    1. Alter tablespace <TBSNAME> offline;
    2. Alter tablepsace <TBSNAME> rename datafile 'oldname' to 'newname';
    3. Alter tablespace <TBSNAME> online;
   
*.    What is the procedure for Transportable tablespace migration?
    Transportable Tablespaces (TTS) allows you to copy a set of datafiles for a tablespace on one database and plug that tablespace into a different database.As we noted, you cannot transport a single partition of a table without transporting the entire table. Therefore, we will need to exchange the partition with a stand-alone table temporarily, so that the partition becomes its own table.
   
*.    How to rename the tablespace?
    Sys>alter tablespace <tablesapce name> rename to <tablespace name>
   
*.     Tell me about ORA 1555 and how do you address if you get this error?
    It usually occurs after queries or batch processes have been running for a long time, which means you can lose many hours of processing when the error crops up.There are three situations that can cause the ORA-01555 error:
    A. An active database with an insufficient number of small-sized rollback segments
    B.A rollback segment corruption that prevents a consistent read requested by the query
    C.A fetch across commits while your cursor is open

*.     What is the view to see UNDO for how much data flushed out and how much data it having now….how many active blocks,         expired     blocks?
    V$undostat
   
*. What are the init parameters you have to set to make use of undo management?
    undo_tablespace= undotbs1
    undo_management= auto
    undo_retention= time in minutes
    comment rollback_segment
   
*. What is flashback query and flash back recovery?
        Flashback query, a new feature of Oracle 9i. Flashback query enables us to query our data as it existed in a previous state. In other words, we can query our data from a point in time before we or any other users made permanent changes to it.  Flashback recovery can bring the complete database to the previous state based on SCN number, on timestamp, on     restore point.
   
* . How to flush recycle bin?
        We use “Purge” command to Flush Recycle bin. It will automatically remove old data from recycle bin if tablespace needs     some more space. If you want to purge just one single table then you type "Purge table <tableName>"
   
*.  What background process refreshes materialized views?
        Cjqo (co-ordinate job queue)
       
*.     What is netstat?
        And it’s Usage? It is a utility to know the port numbers availability.
        Usage: netstat -na grep port number
   
*.     Which operations you can perform using database links?
    Options :-> DDL or DML
        DML
   
*.    Which operations are not allowed on Materialized views?
        DML
   
*. Can we manually refresh any materialized view? Using which package
        Yes, DBMS_MVIEW
   
*. Where the Materialized view stored?
        In database (client side db).this is not a view.it’s read only table.

*. What is snapshot?
        Snapshot is an object used to dynamically replicate data between distribute database at specified time intervals.

*. What are the various types of snapshots?There are three types of materialized views:
        Read only materialized view, Updateable materialized view, Writeable materialized view
       
*. What are the options available to refresh snapshots?
    COMPLETE -:     Tables are completely regenerated using the snapshots query and the master tables every time the snapshot referenced.
    FAST -:     If simple snapshot used then a snapshot log can be used to send the changes to the snapshot tables.
    FORCE -: Default value. If possible it performs a FAST refresh; otherwise it will perform a complete refresh.
   
*.  What is function of RECO?
        Recover (RECO) is used to resolve distributed transactions that are pending due to a network  or  system failure in a distributed database. At timed intervals,the  local  RECO  attempts  to  connect  to  remote databases and automatically  complete  the commit or rollback of the local portion of any pending distributed transactions.
   
*.  What is Archived Redo Log?
        Archived Redo Log consists of Redo Log files that have archived before being reused.

*.  What is Mirrored on-line Redo Log?
    A mirrored on-line redo log consists of copies of on-line redo log files physically located on separate disks; changes made to one member of the group are made to all members.
   
*.  What does a Control file Contain?
        A Control file records the physical structure of the database. It contains the following information. Database Name and locations of a database's files and redolog files. Time stamp of database creation'.
       
*.     What happens when archive log destination becomes 100% full when the database is running in ARCHIVELOG mode?
        How do you recover? The database gets shutdown. We should move old archives to different location and startup the database.
       
*.  How many maximum control files you can create in Oracle database?
        What is the error number you get if u tries to create more than 8?
        8, ora 208      
   
*.     If you want to maintain one more archive destination which parameter you have to set?
            It’s a dynamic parameter you have to set log_archive_dest_1=
           
*. How to create a trace file?
    "Alter database backup controlfile to trace;"
   
*. Where do you get all hidden parameters?
    In the table x$ksppi
    Sys>select ksppinm,ksppdesc from x$ksppi;
   
*.  How do you know whether the parameter is dynamic or static?
    Check the value from the column ISINSTANCE_MODIFIABLE from V$PARAMETER.
   
*. Which role you grant to rman user while configuring rman user  
        Recovery_catalog_owner role.   
       
*. Temporarily recovery catalog database (for RMAN) is down. Can you still run a backup? How?
        Yes, using no catalog mode
       
*.     You have run a backup of database using RMAN nocatalog. How do you sync the recovery catalog with the metadata about the         backup that was taken?
    Resync catalog
   
*.      With our catalog can we connect 2 target databases at a time?
        Yes …we can…
       
*.     What is difference between OBSOLETE and EXPIRED?
        Obsolete backups mean inconsistency backups for recovery purpose. Expired backups means those backups physical files are not available on disk.
       
*.     How  speed up backup jobs in Rman?
    By increase number of channels.
   
*.   
   
   
   
   
   
USER MANAGENMENTS :



*.    What is the difference between a user and schema?
        A user will not have any of his own objects and will always access others objects. Schema is a collection of objects

*.    After creating user, what are the privileges you would assign?
    We will give CONNECT role in 10g (CREATE SESSION if 9i) and any other roles or privileges specified by the application support

*.    What is the disadvantage of resource role?
    It will override the quota granted for a user and makes it unlimited

*.    How you will identify the privileges and roles assigned to a user?
    Using following views
    dba_sys_privs
    dba_tab_privs
    dba_role_privs
    role_sys_privs
    role_tab_privs
    role_role_privs

*.    How to create user and grant the permission in a single command?

    SQL> grant create session to user_a identified by <pwd>;

*.    What happens to the objects if we change the default tablespace for the user?
    Nothing. They will continue to work as normal

*.    You got a requirement to run a script as user “MARK” and you don’t have the password of MARK. How you will take next step?
    We will ask application support. In case they cannot be reached, we can take ASCII password stored in dba_users and change the password. Once work is done we can change the password back using ASCII that we stored earlier

    Also we can set current_user option in SQLPLUS

*.    What is the view to check default permanent and temp tablespace values?
    database_properties

*.    Have you implemented password policies?
    a. Yes. Using profile management

*.    What are SNIPPED sessions? If there any impact on database to have them?

    Those are sessions terminated from database because of crossing IDLE_TIME limit. But disadvantage is even though oracle level sessions are cleared, at OS level processes will still occupy resources which is a burden to the server

*.    I am using IDLE_TIME as 15 min, but observed that even after 20min idle time, session is not getting disconnected, what is the reason?
    RESOURCE_LIMIT parameter is not set to TRUE

*.    As a DBA will you recommend to implement auditing in the database?
    Depends on the type of database, but it would be wise to implement atleast on some critical tables

*.    What factors you will choose before you enable auditing?
    We need to check about database performance and what level of auditing is required

*.    If auditing is not in place, how you will get to know if a user performed update or not yesterday?
    We can use logminer to read the archives which are generated yesterday

*.    Are you maintaining any SOX compliance database?
    No. We don’t have any SOX database as of now

*.    How to check which users are granted with sysdba role?
    We can check from v$syspw_file view

*.    If we want to restrict users to connect to the database, but want to allow some users to connect, how can we do that?
    We need to grant restrcited session privilege for the users whom we want to connect
   

   
   
   

interview questions : backup/restore

!! oracle backup/restore interview questions : !!



*.    What is the difference between cold and hot backup?
        a.COLD backup will be taken by shutting down the database, where as HOT backup will be taken while database is up and running
*.    What happens when a database or tablespace is placed in begin backup mode?
        Datafile header will get freezed i.e CKPT will not update latest SCN
        DBWR still will write data into datafiles
        When end backup, CKPT will update the latest SCN to datafile header
*.    Why more redo will generate during hot backup?
        It is to avoid fractured block as oracle will copy entire block as redo entry
*.    What is fractured block?
        A block which might contain inconsistent data. This happens because the speed of DBWR is different than OS copy during hot backup
*.    What is the difference between complete and incomplete recovery?
        No data loss in complete recovery whereas some data loss is observed in incomplete recovery
*.    What will happen if we use resetlogs?
        It will create new redolog files (if not already there)
        It will reset log sequence number to 1,2…etc
*.    Out of 100 datafiles, I lost 29 files. How you will identify which files to recover?
        a.Using the view v$recovery_file
*.    How to check if incomplete recovery is performed in the database?
        SQL> select RESETLOGS_TIME,RESETLOGS_CHANGE from v$database;
*.    I placed a tablespace in hot backup mode and datafile which is being backup is  lost. How you will recover it?
        We can restore from old backup and apply all the archives till now
        Yesterday night backup is successful. Today morning we added a datafile at 11  AM. After noon 3’o clock the new
*.    added datafile is lost. Can I recover that  datafile? If so, how?
        Yes we can recover it. We need to create that datafile using “alter database create datafile ‘path’;” command and then apply all the archives
*.        What is the importance of archives during recovery process?
        As they will store all the changes happened in the database, always we can do complete recovery if we have a perfect backup
*.    How you will recover database when all copies of control file are lost?
        We can do a complete recovery if we have a latest trace of it. Or else, we need to do incomplete recovery by restoring controlfile from last successful backup
*.    Application team informed that an important table is dropped. How you will  recover it?
        We can recover it by doing until time recovery. But this will affect other user transactions, so we need to get approval for this first
*.    What are the pre-requisite factors you will consider before performing until time  recovery?
        We need to see if other users are not getting any affect by doing this
*.    You need to restore the database and then realized there are no control files.  How you will proceed?
        Either we can resotre controlfiles first and do recovery (but a data loss is there as its incomplete recovery) or we can create new controlfile if we have a latest trace
       
       
*.    What is difference between Restoring and Recovery of database?
        Restoring means copying the database object from the backup media to the destination where actually it is required where as recovery means to apply the database object copied earlier (roll forward) in order to bring the database into consistent state.
   
*.    What is the benefit of running the DB in archivelog mode over no archivelog mode?
        When a database is in no archivelog mode whenever log switch happens there will be a loss of some redoes log information in order to avoid this, redo logs must be archived. This can be achieved by configuring the database in archivelog mode.
   
*.    If an oracle database is crashed? How would you recover that transaction which is not in backup?If the database is in         archivelog we can recover that transaction otherwise we cannot recover that transaction which is not in backup.
   
   
*.    Incremental backup levels:
        Level 0 – full backup that can be used for subsequent incrementals
        RMAN> backup incremental level 0 database;
        Differential Level 1–only the blocks that have changed since the last backup (whether it is level 0 or level 1)
        RMAN> backup incremental level 1 differential database;
        Cumulative Level 1 – all changes since the last level 0 incremental backup
        RMAN> backup incremental level 1 cumulative database;
        A full backup cannot be used for a cumulative level 1 backup.
        A cumulative level 1 backup must be done on top of an incremental level 0 backup.
   
*.    Why RMAN incremental backup fails even though full backup exists?If you have taken the RMAN full backup using the command         ‘Backup database’, where as a level 0 backup is physically identical to a full backup. The only difference is that the         level 0 backup is recorded as an incremental backup in the RMAN repository so it can be used as the parent for a level 1         backup. Simply the ‘full backup without level 0’ can not be considered as a parent backup from which you can take         level 1 backup.   
   
   
   
   
   
   
commands :


RMAN> CONNECT CATALOG rman/pwd@catdb;
RMAN> CONNECT AUXILIARY rman/pwd@auxdb;
RMAN> RESYNC CATALOG FROM DB_UNIQUE_NAME ALL;
RMAN> IMPORT CATALOG rman/rman@catdb1 DB_NAME=prod1 NO UNREGISTER;
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR SBT TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR SBT TO 1; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE; # default -- Oracle 11g R2
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '.../dbs/snapcf_sid.f'; # default


%F = dbid, day, month, year and sequence
%U = %u_%p_%c
%u = eight characters of the backup set and time ...
%p = piece number within the backupset
%c = copy number of the backup piece ...

RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt PARMS='ENV=mml_env_settings';
RMAN> CONFIGURE CHANNEL 2 DEVICE TYPE sbt CONNECT 'SYS/pwd@node2' PARMS 'ENV=(NSR_SERVER=bksrv2)';
RMAN> SET DBID=4240978820;
RMAN> SET COMMAND ID TO 'rman';



BACKUP FULL Options
BACKUP FULL AS (COPY | BACKUPSET) Options
BACKUP INCREMENTAL LEVEL [=] integer Options
BACKUP INCREMENTAL LEVEL [=] integer AS (COPY | BACKUPSET) Options
BACKUP AS (COPY | BACKUPSET) Options
BACKUP AS (COPY | BACKUPSET) (FULL | INCREMENTAL LEVEL [=] integer) Options


BACKUP VALIDATE DATABASE ARCHIVELOG ALL;
BACKUP VALIDATE DATABASE;
BACKUP VALIDATE CHECK LOGICAL DATABASE;
BACKUP AS COPY TABLESPACE test;
 LIST INCARNATION OF DATABASE;

 listBackupOption::=
[[BY BACKUP] [VERBOSE] | SUMMARY | BY {BACKUP SUMMARY|FILE}]


RMAN> REPORT OBSOLETE;
RMAN> REPORT NEED BACKUP;
RMAN> REPORT NEED BACKUP DAYS=5;
RMAN> REPORT NEED BACKUP REDUNDANCY=3;
RMAN> REPORT NEED BACKUP RECOVERY WINDOW OF 7 DAYS;
RMAN> REPORT NEED BACKUP DATABASE;
RMAN> REPORT NEED BACKUP INCREMENTAL 1;
RMAN> REPORT UNRECOVERABLE;
RMAN> REPORT SCHEMA;
RMAN> REPORT SCHEMA AT TIME 'sysdate-20/1440'

CROSSCHECK BACKUP OF DATABASE;
 CROSSCHECK BACKUP OF TABLESPACE userd COMPLETED BEFORE 'SYSDATE-14';

RESTORE SPFILE;
RESTORE ARCHIVELOG ALL VALIDATE;
RESTORE ARCHIVELOG ALL PREVIEW;


 DUPLICATE TARGET DATABASE TO dwhdb;

 SWITCH DATABASE TO COPY;