Tuesday, October 18, 2011

Backup and recovery concepts

RMAN environment


The RMAN environment consist of following components:

Required components:
  • RMAN client : The client application that manages the backup and recovery of target database.
  • target database: A database that RMAN backs up and restores

Optional components:

  • recovery catalogy database:
  • recovery catalog schema
  • physical standby database
  • duplicate database: a copy of the primary database that you can use for testing purposes
  • fast recovery area:
  • media manager:
  • media mangement catalog


RMAN channels


The RMAN client itself does not perform backup, restore or recovery opertations. When you connect the RMAN client to a target database, RMAN allocates server sessions on the target instance and directs them to perfom the operations.

The RMAN channel corresponds to a one database server session. It represents one stream of data to a device.

A channel establishes a connection from the RMAN client to a target or auxiallary database instance by starting a server session on the instance.

The RMAN supported device types are disk and SBT (system backup to tape). An SBT device is controlled by third party media manager.


The RMAN channels can be allocated either automatically or manually .

You can enable automatic channel allocation by using configure_channel command. . When you run a command that can use automatic channels, RMAN automatically allocates the channels with the options you specified in configure_channel command. RMAN determines the names for the automatic channels. RMAN comes preconfigured with DISK channel that you can use for backups to disk.

You can manually allocate channels as well. You give user defined names to manually created channels.

The number of channels available for use with a device determines whether RMAN reads from or write to this device in parallel or not. In parallelism, the back up of the file is performed by more than one channel. Each channel may back up more than one file but unless a multisection backup is performed, no file is backed up by more than one channel.

RMAN Backup Options


You can backup your database using "BACKUP" command. RMAN determines backup options based on RMAN environment and RMAN defaults.

This table summarizes the RMAN options and their default values:

Backup Option Default Value All possible values Example Note
Device type Value set in CONFIGURE_DEFAULT_DEVICE_TYPE Device type can be disk or SBT BACKUP Database
device type disk
(or) device type SBT

Backup type By default , RMAN creates backup sets Backup type can be backupset or image copy Backup as copy
(or) backup as backupset

File Format

format "/disk1/backup_%U" (file location)
(or) format 'tdgroup' (ASM group)

































Overview of RMAN backups

When you issue BACKUP command the following files are backed up:

  • Datafiles and control files
  • Server parameter files
  • Archived redo logs
  • RMAN backups
Network configuration files, password files , contents of Oracle home are not backed up with RMAN.

The backups created can either be consistent or in-consistent.

The entire database can be backup ed with "backup database" command. The database should either be mounted or open for backup to succeed.

Backing up tablespaces and datafiles:


If you want to backup only certain tablespaces or datafiles, you can issue BACKUP TABLESPACES or BACKUP DATAFILES command. When you specify tablespaces, RMAN translates the tablespace name internally into a list of datafiles.

RMAN automatically backs up control file and server parameter file when datafile 1 is included in the backup. If the control file autobackup is enabled , then RMAN writes the current control file and server parameter file to a seperate autobackup piece.

Backing up control files :

If the configure controlfile autobackup is set to ON, RMAN automatically backs up the control file and server parameter file after every backup and after database structural changes. The control file autobackup contains metadata about the previous backup, which is crucial for disaster recovery.

You can take manual backup of control file by

Running backup current controlfile command
Include a backup of control file within any backup by using include current controlfile option of the backup command
Backup datafile 1 (as it automoatically includes backup of control file and sp file)


Manual backup of control file is not the same as autobackup. Autoback contains metadata about the backup that just completed. Also, RMAN can automatically restore autobackups without the user of recovery catalog

Overview of Incremental backups


An incremental backup copies only datafile blocks that have changed since a specified previous backup.

An incremental backup is of two types:
  • Cumulative incremental backup
    • Backs up all blocks changed after the most recent incremental backup at level 0
  • Differential incremental backup
    • Backs up all blocks changes after the most recent incremental backup at level 1 or level 0
    • By default incremental backups are differntial.
  •  
    The contents of full backup and backup increment level 0 are the same. However, a full backup cannot be used as part of incremental strategy. Level 0 incremental backup is the basis of incremental strategy.

    A good rule of thump is to take new level 0 backup whenever 20% or more of the data has changed.

    In a data guard environment, you can offload incremental backups to a physical standby database. Incremental backups of a standby and primary database are interchangeable.

    To make differential incremental backup

    backup
    incremental level 0
    database ;

    To make cumulative incremental backup

    backup
    incremental level 1 cumulative
    database;

    To make incremental backups in the fast recovery area:
    backup
    incremental level 1
    from scn <look this up>



    Archival backups:


    You can use BACKUP ....KEEP to creat a backup that is both all-inclusive and exempt from the backup retention policy. The KEEP options also specifies that the backup should be exempt from the retention policy either forever or for a specified period of time (KEEP UNTIL TIME '01-JAN-08'.

    The characteristics of BACKUP ....KEEP command are as under:
    • It automatically backs up datafiles, control file (even if control file autobackup is disabled) and server parameter file.
    • It automatically generates an archived redo log backip to ensure that the database backup can be recovered to a consistent state.


    An Overview of Data Recovery Manager

    Data recovery manager is a tool to help reduce MTTS (Mean time to recover). The GUI of DRA is available in database control and grid control by selecting Perform Recovery in Availability tab. DRA has following commands:
    • LIST FAILURE
    • ADVISE FAILURE
    • REPAIR FAILURE
    • CHANGE FAILURE

    Advise failure comand is used to view repair options which typically include both automated and manual options. Repair failure command is used to repair the failure automatically. Once the failure is repaired, Repair failure command closes the relevant repaired failure. If you chose to repair failure manually, you should use change failure command to change the status of an open failure to closed. Change failure command is used to alter the status and priority of failure. You can change the status of the failure to closed or to priority high or priority low. You cannot set the status to open nor can you set the priority to critical with change failure command.


    To list all failures:
    • rman > list failure
    To list details of a particular failure
    • rman > list failure <failure id > detail
    List a subset of failure
    • rman > list failure low ( low is the failure priority; high and critical are the other two failure priority values)
    • rman > list failure close
    • rman > list failure exclude failure <failure id>
    To determine repair options for a subset of failure
    • rman > advice failure <failure id>
    To see what will be repaired if repair failure command is invoked
    • rman > repair failure preview

    Monday, October 10, 2011

    ILOM basics

    • Reset the server (poweroff and power on the server) 
      • reset /SYS
    • Start the console
    -> start /SP/console
    Are you sure you want to start /SP/console (y/n)? y
    Serial console is in use.

    -> stop /SP/console
    Are you sure you want to stop /SP/console (y/n)? y

    -> start /SP/console
    Are you sure you want to start /SP/console (y/n)? y

    Serial console started.  To stop, type ESC (


    • Log on to console
    telnet <hostts-m2> <portnum>




    When you start /sp/console, you get one of the following prompt.
    The prompt displayed on the terminal or shell tool tells you which channel you are accessing:
    • The # or % prompt indicates that you are at the system console and that the Solaris OS is running.
    • The ok prompt indicates that you are at the system console and that the server is running under OpenBoot firmware control.
    • The -> prompt indicates that you are at the service processor.
    • Additional Info:
    Command Cheat sheet:
    http://thegeekdiary.com/most-commonly-used-ilom-commands-cheat-sheet/

    http://www.fatmin.com/2008/04/sun-5220-consol.html

    http://blogs.oracle.com/merwick/entry/switching_between_alom_and_ilom

    Monday, October 3, 2011

    Naming Services essential

    • The naming and Directory services provided by Solaris are as under:
      • DNS 
      • NIS
      • LDAP
      • /etc files
      •  
      •  Modern network  uses two or more of these services in combination. When more than one service is used, the services are co-ordinated by nsswitch.conf file
      • Typically, NIS clients are configured with the nsswitch.conf file to use only NIS for machine name and address lookups. If this type of lookup fails, an NIS server can forward these lookups to DNS.ypcat, ypwhich and ypmatch commands are used for retrieving NIS maps
         
    • Solaris 10 Operating system ships with BIND 9.X DNS name server.
    • DNS service FMRL is svc:/network/dns/server:<instance> and svc:network/dns/client:<instance>
      • # svcs \*dns\*
        • STATE          STIME    FMRI
        • disabled       Sep_27   svc:/network/dns/server:default
        • online         Sep_27   svc:/network/dns/client:default
        • online         Sep_27   svc:/network/dns/multicast:default
    • The BIND 9.x configuration file in Solaris is : /etc/rndc.conf.
    • There are two extensions to DNS protocol. They are multicast DNS (mDNS) and DNS service discovery (DNS-SD)
      • mDNS extends the Domain Name service to operate over link-local multicast. Both Multicast DNS and Servic e Discovery are installed by default when installing the Solaris OS. In addition to being installed, mDNS must be enabled and must be included in /etc/nsswitch.conf
      • To enable mDNS, add mdns to hosts and ipnodes of /etc/nsswtich.conf (refer to /etc/nsswitch.dns for example)
      • The log file for mDNS can be found under /var/svc/log/network-dns-multicast:default.log
    • You can use dns-sd command as network diagnosis tool to browse and discover services.
    • To find out more about how DNS client resolver work in Solaris:
    • To  setup DNS server in Solaris
      • http://wikis.sun.com/display/tma/DNS+on+Solaris+11

    Monday, September 12, 2011

    Run Oracle Database in distinct resource pools in global container

    Suppose you have created three resource pools namely:
    • rac1Pool
    • rac2Pool
    • rac3Pool
    You want to run four Oracle database instances in each of these three pools and in the global pset.
    You can do so by creating 3 additional oracle users namely oracle_2, oracle_3 and oracle_4. All these users should have the same group as oracle user  and different (distinct)  home directory . Also, ensure that Oracle user home directory has group write permission. The command to create additional users is as under:
    • useradd -g oinstall -G dba -u 202 oracle_2
    •  useradd -g oinstall -G dba -u 203 oracle_3
    • useradd -g oinstall -G dba -u 204 oracle_4
    Next, create three projects with following pool and user association:
    rac1Project ---> rac1Pool---->oracle
    rac2Project---->rac2Pool----->oracle_2
    rac3Project---->rac3Pool----->oracle_3
    You can create the above mentioned associated by issuing the following command:
    1)Create a project , associate it with right user and pool:
    • projadd -U oracle -p 400  -K project.pool=rac1Pool rac1Project 
    • projadd -U oracle_2 -p 402  -K project.pool=rac2Pool rac2Project 
    • projadd -U oracle_3 -p 403 -K project.pool=rac3Pool rac3Project
    Additonal info : http://docs.oracle.com/cd/E26502_01/html/E29024/rmpool.task-41.html#rmpool.task-46

    2)Associate the user with right project  


    edit /etc/user_attr and add the following line
    • oracle::::project=rac1project  (add four colons after oracle)
    • orace_2::::project=rac2Project
    • oracle_3::::project=rac3Project
    3) Re-login as the use and verify that it is associated with right project
    •  id -p

    Thursday, August 11, 2011

    Bash Basics

    IO Redirection
    • 1>filename # Redirect stdout to file "filename."
    •  1>>filename # Redirect and append stdout to file "filename."
    •  2>filename # Redirect stderr to file "filename."
    • 2>>filename # Redirect and append stderr to file "filename."
    •  &>filename # Redirect both stdout and stderr to file "filename."
    Bash basic arithmetic:

    Surround your expression with double parenthesis .....
    #!/bin/bash
    x=5   # initialize x to 5
    y=3   # initialize y to 3
    add=$(($x + $y))   # add the values of x and y and assign it to variable add
    sub=$(($x - $y))   # subtract the values of x and y and assign it to variable sub
    mul=$(($x * $y))   # multiply the values of x and y and assign it to variable mul
    div=$(($x / $y))   # divide the values of x and y and assign it to variable div
    mod=$(($x % $y))   # get the remainder of x / y and assign it to variable mod

    Thursday, July 21, 2011

    Statspack Events

    enq: US - contention

    When you see enq: US - contention on Top 5 wait events on AWR or Statspack report or in ADDM findings you can take the following actions :

    1) Check undo advisor if in 10g anf up.
    2) Edit your undo retension parameter
    3) Give space to Undo Tablespace
    4) Move Undo tablespace to an other disk not so hot disk.

    Mostly this wait event concerns autoxents on undo tablespaces.

    • db file sequential read and read by other session
    Check buffer pool statistics and buffer wait (especiallyu data block wait)
    A "db file sequential read" occurs when a an Oracle process looks for a block in the buffer cache and can’t find the block. The block is then read of disk, creating IO.

    Db file sequential read wait time is increasing:
    Check the average read times per file under FILE IO Stats
    Check cache buffer hit ratio under "Buffer pool advisory"

    Oracle Installation notes

    • Create user and group:
      •  groupadd -g 201 dba
      • groupadd -g 200 oinstall
      •  useradd -g oinstall -G dba -u 200 oracle
      • mkdir /export/home/oracle
      • chown -R oracle:oinstall /export/home/oracle 
      • passwd oracle (setup password for oracle user) 
    • Create ZFS pool to install Oracle (optional)
      •  Find out which pools exist and which disks are used by those pools
        • zpool status
        •  Create a pool named oraclePool
        • zpool create  oraclePool c0t5000C5001D250C7Fd0   c0t5000C5001D207157d0 
          zfs create oraclePool/11gR2
    • Create directories and provide them right permissions:
      • mkdir -p /u01/app/oracle
      • mkdir -p /u01/app/11.2.0/grid
      • mkdir -p /u01/app/oracle/11.2.0/db
      • chown -R oracle:oinstall /u01
      • chmod -R 775 /u01
      • Oracle BASE : /u01/app/oracle
      • GRID Base: /u01/app/11.2.0/grid
      • DB BASE: /u01/app/oracle/11.2.0/grid
    • Install the required packages
      •  pkg install  SUNWarc SUNWbtool SUNWhea SUNWlibm SUNWlibms SUNWpool SUNWsprot SUNWtoo SUNWuiu8 SUNWfont-xorg-core SUNWfont-xorg-iso8859-1 SUNWmfrun SUNWxorg-client-programs SUNWxorg-clientlibs SUNWxwfsw pkg://solaris/SUNWxwplt

    • Set project attributes
      • projmod -s -K 'process.max-file-descriptor=(basic,10000,deny)' oracleProject

    Things to check
    • 11.2.0.3 and later are supported on Solaris 11
    •  
    •  Set up AWT_TOOLKIT variable on Solaris 11
      • if installing on Solaris 11, set the following variable so runInstaller can work
        • export AWT_TOOLKIT=XToolkit
    • To setup rsh/ rlogin/ssh between nodes on Solaris 11:
      •  pkg  install service/network/legacy-remote-utilities
      •  inetadm -e  svc:/network/login:rlogin
      • svcadm enable /network/shell:default
    • Clone ASM and DB installation
      • Check out Appendix B of this document:

    http://download.oracle.com/docs/cd/E11882_01/install.112/e24346/toc.htm

      • If you want to do a slient install with response file check out appendix A.
    •  Verify if you have all the required packages:

      • pkginfo -i SUNWarc SUNWbtool SUNWhea SUNWlibm SUNWlibms SUNWpool SUNWpoolr SUNWsprot SUNWtoo SUNWuiu8 SUNWfont-xorg-core SUNWfont-xorg-iso8859-1 SUNWmfrun SUNWxorg-client-programs SUNWxorg-clientlibs SUNWxwfsw SUNWxwplt 
      • Else install the packages
      • pkg  install <list of space separated pkg names> 
      • If required you can delete existing publisher and add new publisher
        •  pkg set-publisher -G '*' -g  http://ipkg.us.oracle.com/solaris11/dev/ solaris
          # pkg publisher
          PUBLISHER                             TYPE     STATUS   URI
          solaris                               origin   online   http://ipkg.us.oracle.com/solaris11/dev/