Thursday, June 25, 2015

Add Swap Space on Linux

Find current swap space on the system
# free -m
           total   used    free   shared   buffers  cached
Mem:       16051   15570    481      0       707     12644
-/+ buffers/cache: 2218    13833
Swap:      8189     0      8189

Or

# swapon -s
Filename         Type        Size    Used    Priority
/dev/sda2      partition   8385920    88       -1

 Or

# cat /proc/swaps
Filename         Type        Size    Used    Priority
/dev/sda2      partition   8385920    88       -1

Method 1 - Use Hard Drive Partition

If you have additional hard disk or space available in existing disk then create partition using fdisk command. Assume /dev/sdc1 is newly created partition 

Setup newly created partition as swap area
# mkswap /dev/sdc1
Enable swap partition
# swapon /dev/sdc1
Add following line to /etc/fstab to available even after reboot
# cat /etc/fstab
/dev/sdc1        swap         swap    defaults        0 0
Verify whether newly created swap space is available
# swapon -s
Filename         Type       Size     Used    Priority
/dev/sda2      partition   8385920    88       -1
/dev/sdc1      partition  10234430     0       -2

Method 2 - Use a file for Additional swap space

If you does not have any additional disk then you can create a file on your system and use that for swap space

Create the swap file called 'myswap' using following command (file size in bytes=bs*count)
# dd if=/dev/zero of=/root/myswap bs=1M count=2048
Change the permission of newly created file
# chmod 755 /root/myswap
Make this file as a swap file
# mkswap /root/myswap
Add following line to /etc/fstab to available even after reboot
# cat /etc/fstab
/root/myswap        swap         swap    defaults        0 0
Verify whether newly created swap space is available
# swapon -s
Filename         Type       Size     Used    Priority
/dev/sda2      partition   8385920    88       -1
/root/myswap     file      2097152     0       -2

Tuesday, June 23, 2015

Deploy 12c Management Agent

Here explain how to add target hosts to enterprise manager

Login to Enterprise Manager via Sysman login
Go to Setup->Add Target->Add Targets Manually


 Select Add Host Targets and Click Add Host Button

Click on Add Button and Add the target host name which need to deploy agent and Click on Next Button

Provide Installation Base Directory and Instance directory on target host

Review the Host Information and click on Deploy Agent button to begin the installation

Now Management Agent will deploy on target host

Ignore the Privileges warning and click on Continue->Continue, All Host

Run the root.sh to complete the Agent deployment


Go to Setup->Add Target->Add Targets Manually and select 'Add Target Declaratively by Specifying Target Monitoring Properties'
Select 'Database Instance' to Target Type and specific hostname for Monitoring Agent and click on 'Add Manually' Button

Provide Database Details of Agent and Test the connection


Agent configuration completed and now can monitor newly added DB through EM

Thursday, June 11, 2015

Install 12c Enterprise Manager

Prerequisites 

  • Download and Install Oracle Database 11g R2 on linux platform
  • Download Enterprise Manager Cloud control from following link
  • http://www.oracle.com/technetwork/oem/grid-control/downloads/index.html

  • If you have performed a default database installation you will need to de-configure Enterprise Manager Database Control. Run the following command as the "oracle" user.

  • $ emca -deconfig dbcontrol db -repos drop -SYS_PWD <sys pasword> -SYSMAN_PWD <sysman password>

  • Make following initialization parameter changes and restart the instance

  • $sqlplus / AS SYSDBA
    SQL>ALTER SYSTEM SET processes=300 SCOPE=SPFILE;
    SQL>ALTER SYSTEM SET session_cached_cursors=200 SCOPE=SPFILE
    SQL>ALTER SYSTEM SET sga_target=2G SCOPE=SPFILE;
    SQL>ALTER SYSTEM SET shared_pool_size=600M SCOPE=SPFILE;
    SQL>ALTER SYSTEM SET pga_aggregate_target=1G SCOPE=SPFILE;
    SQL>ALTER SYSTEM SET job_queue_processes=20 SCOPE=SPFILE;
    
    SQL>SHUTDOWN IMMEDIATE
    SQL>STARTUP
    
    If you have done a default installation as described here, the UNDO tablespace will be autoextensible. If you have done a custom installation make sure the UNDO tablespace is at least 200M in size. Also, make sure you have 3 redo logs of at least 300M to prevent a warning during the installation.

    Cloud Control Installation

    Create Following installation directories for management server and agent

    $ mkdir -p /u01/app/oracle/oms12cr3
    $ mkdir -p /u01/app/oracle/agent12cr3
    
    Unzip the cloud control media and begin the installation by running runinstaller
    $ mkdir em
    $ unzip -d em em12103p1_linux64_disk1.zip
    $ unzip -d em em12103p1_linux64_disk2.zip
    $ unzip -d em em12103p1_linux64_disk3.zip
    $ cd em
    
    $ ./runInstaller
    
    If you wish to receive support information enter the e-mail address else skip

    If you wish to check for updates enter the details else skip

    If you have completed all the prerequisites then installation pass all the checks

    Select 'Create a new Enterprise Manager System' and 'simple' option

    Enter Middleware and Agent installation locations

    Enter Administrator password and Database Details

    If you have any additional warnings, check they don't look like show-stoppers, then click the 'OK' button to continue and click 'Install' button to begin the installation


    When prompted, run the root scripts, then click the 'OK' button
    Make note of the URL below and close. Copy of following information are stored in /u01/app/oracle/oms12cr3/oms/install/setupinfo.txt file.

    Login to the EM using above URL.


    Startup and Shutdown Enterprise Manager

    Oracle Management Server
    export OMS_HOME=/u01/app/oracle/oms12cr3/oms
    $OMS_HOME/bin/emctl start oms
    $OMS_HOME/bin/emctl stop oms
    $OMS_HOME/bin/emctl status oms
    
    Agent
    export AGENT_HOME=/u01/app/oracle/agent12cr3/core/12.1.0.3.0
    $AGENT_HOME/bin/emctl start agent
    $AGENT_HOME/bin/emctl stop agent
    $AGENT_HOME/bin/emctl status agent
    

    Sunday, May 17, 2015

    Migrate Non ASM to ASM Database - 11g

    Prerequisite
    Running Non ASM 11g Database

    Migration Steps

    Download and Install appropriate ASMLib RPM's
    • oracleasm-support-2.1.7-1.el5.i386.rpm
    • oracleasmlib-2.0.4-1.el5.i386.rpm
    • oracleasm-[your-kernel-version].rpm

    Then create the disk as follows which using creation of ASM instance









    I have created 2 disks DISK1 and DISK2

    Check the permission of created disk under /dev/oracleasm/disks/


    Now unzip the grid software and install using ./runInstaller

    And select 'Install and Configure Grid Infrastructure for Standalone Server' as we are not using ASM for RAC database.


    Here you can able see the disks created earlier. I have kept the redundancy 'External' so that only one disk is required for a disk group. For redundancy 'Normal' we need to have a two disks in a diskgroup and for 'High' we need a minimum for three disks. Select the disk which has to be added to diskgroup named 'DATA'.

    Provide the password for SYS and ASMSNMP

     Select the OS group or keep as It is



     Click Finish to begin the installation





    Once the installation is completed you can check whether ASM processes are running

    Now below are the steps to move Non ASM DB to ASM disks
    SQL> select name from v$database;
    
    NAME
    ---------
    DEV
    
    SQL> select file_name from dba_data_files;
    
    FILE_NAME
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEV/users01.dbf
    /u01/app/oracle/oradata/DEV/undotbs01.dbf
    /u01/app/oracle/oradata/DEV/sysaux01.dbf
    /u01/app/oracle/oradata/DEV/system01.dbf
    /u01/app/oracle/oradata/DEV/example01.dbf
    
    SQL> select file_name from dba_temp_files;
    
    FILE_NAME
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEV/temp01.dbf
    
    
    SQL> show parameter spfile;
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    spfile                               string      /u01/app/oracle/product/11.2.0
                                                     /dbhome_1/dbs/spfileDEV.ora
    
    
    SQL> show parameter control_file;
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    control_file_record_keep_time        integer     7
    control_files                        string      /u01/app/oracle/oradata/DEV/co
                                                     ntrol01.ctl, /u01/app/oracle/f
                                                     lash_recovery_area/DEV/control
                                                     02.ctl
    
    SQL> alter system set control_files='+DATA' scope=spfile;
    
    System altered.
    
    SQL> alter system set db_create_file_dest='+DATA' scope=spfile;
     
    System altered.
    
    SQL> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    
    SQL> startup nomount;
    ORACLE instance started.
    
    Total System Global Area 1653518336 bytes
    Fixed Size                  2213896 bytes
    Variable Size             956303352 bytes
    Database Buffers          687865856 bytes
    Redo Buffers                7135232 bytes
    
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    
    [oracle@dev ~]$ rman target /
    
    Recovery Manager: Release 11.2.0.1.0 - Production on Thu May 14 11:05:40 2015
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    connected to target database: DEV (not mounted)
    
    RMAN> restore controlfile from '/u01/app/oracle/oradata/DEV/control01.ctl';
    
    Starting restore at 14-MAY-15
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=23 device type=DISK
    
    channel ORA_DISK_1: copied control file copy
    output file name=+DATA/dev/controlfile/current.257.879678343
    Finished restore at 14-MAY-15
    
    RMAN> alter database mount;
    
    database mounted
    released channel: ORA_DISK_1
    
    RMAN> backup as copy database format '+DATA'
    2> ;
    
    Starting backup at 14-MAY-15
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=25 device type=DISK
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00001 name=/u01/app/oracle/oradata/DEV/system01.dbf
    output file name=+DATA/dev/datafile/system.258.879679631 tag=TAG20150514T112711 RECID=2 STAMP=879679658
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00002 name=/u01/app/oracle/oradata/DEV/sysaux01.dbf
    output file name=+DATA/dev/datafile/sysaux.259.879679667 tag=TAG20150514T112711 RECID=3 STAMP=879679687
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00003 name=/u01/app/oracle/oradata/DEV/undotbs01.dbf
    output file name=+DATA/dev/datafile/undotbs1.260.879679691 tag=TAG20150514T112711 RECID=4 STAMP=879679697
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00005 name=/u01/app/oracle/oradata/DEV/example01.dbf
    output file name=+DATA/dev/datafile/example.261.879679699 tag=TAG20150514T112711 RECID=5 STAMP=879679703
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
    channel ORA_DISK_1: starting datafile copy
    copying current control file
    output file name=+DATA/dev/controlfile/backup.262.879679707 tag=TAG20150514T112711 RECID=6 STAMP=879679707
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00004 name=/u01/app/oracle/oradata/DEV/users01.dbf
    output file name=+DATA/dev/datafile/users.263.879679709 tag=TAG20150514T112711 RECID=7 STAMP=879679709
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    including current SPFILE in backup set
    channel ORA_DISK_1: starting piece 1 at 14-MAY-15
    channel ORA_DISK_1: finished piece 1 at 14-MAY-15
    piece handle=+DATA/dev/backupset/2015_05_14/nnsnf0_tag20150514t112711_0.264.879679711 tag=TAG20150514T112711 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 14-MAY-15
    
    RMAN> switch database to copy;
    
    datafile 1 switched to datafile copy "+DATA/dev/datafile/system.258.879679631"
    datafile 2 switched to datafile copy "+DATA/dev/datafile/sysaux.259.879679667"
    datafile 3 switched to datafile copy "+DATA/dev/datafile/undotbs1.260.879679691"
    datafile 4 switched to datafile copy "+DATA/dev/datafile/users.263.879679709"
    datafile 5 switched to datafile copy "+DATA/dev/datafile/example.261.879679699"
    
    RMAN> alter database open;
    
    database opened
    
    RMAN> Exit
    
    SQL> select file_name from dba_data_files;
    
    FILE_NAME
    --------------------------------------------------------------------------------
    +DATA/dev/datafile/users.263.879679709
    +DATA/dev/datafile/undotbs1.260.879679691
    +DATA/dev/datafile/sysaux.259.879679667
    +DATA/dev/datafile/system.258.879679631
    +DATA/dev/datafile/example.261.879679699
    
    SQL> select file_name from dba_temp_files;
    
    FILE_NAME
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEV/temp01.dbf
    
    SQL> alter database tempfile '/u01/app/oracle/oradata/DEV/temp01.dbf' drop including datafiles;
    
    Database altered.
    
    SQL> select file_name from dba_temp_files;
    
    no rows selected
    
    SQL> alter tablespace temp add tempfile size 300M;
    
    Tablespace altered.
    
    SQL> select file_name from dba_temp_files;
    
    FILE_NAME
    --------------------------------------------------------------------------------
    +DATA/dev/tempfile/temp.265.879682295
    
    SQL> select member from v$logfile;
    
    MEMBER
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEV/redo03.log
    /u01/app/oracle/oradata/DEV/redo02.log
    /u01/app/oracle/oradata/DEV/redo01.log
    
    
    SQL> alter database add logfile group 4 '+DATA' size 10M;
    
    Database altered.
    
    SQL> alter database add logfile group 5 '+DATA' size 10M;
    
    Database altered.
    
    SQL> alter database add logfile group 6 '+DATA' size 10M;
    
    Database altered.
    
    SQL> select member from v$logfile;
    
    MEMBER
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEV/redo03.log
    /u01/app/oracle/oradata/DEV/redo02.log
    /u01/app/oracle/oradata/DEV/redo01.log
    +DATA/dev/onlinelog/group_4.266.879682579
    +DATA/dev/onlinelog/group_5.267.879682595
    +DATA/dev/onlinelog/group_6.268.879682607
    
    6 rows selected.
    
    
    SQL> alter database drop logfile group 2;
    
    Database altered.
    
    SQL> alter database drop logfile group 3;
    
    Database altered.
    
    SQL> select member from v$logfile;
    
    MEMBER
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEV/redo01.log
    +DATA/dev/onlinelog/group_4.266.879682579
    +DATA/dev/onlinelog/group_5.267.879682595
    +DATA/dev/onlinelog/group_6.268.879682607
    
    SQL>  
    
    SQL> select group#,status from v$log;
    
        GROUP# STATUS
    ---------- ----------------
             1 ACTIVE
             4 ACTIVE
             5 CURRENT
             6 UNUSED
    
    SQL> alter system switch logfile;
    
    System altered.
    
    SQL> select group#,status from v$log;
    
        GROUP# STATUS
    ---------- ----------------
             1 ACTIVE
             4 ACTIVE
             5 ACTIVE
             6 CURRENT
    
    
    SQL> alter system checkpoint;
    
    System altered.
    
    SQL> select group#,status from v$log;
    
        GROUP# STATUS
    ---------- ----------------
             1 INACTIVE
             4 CURRENT
             5 INACTIVE
             6 INACTIVE
    
    SQL> alter database drop logfile group 1;
    
    Database altered.
    
    SQL> 
    
    
    
    
    
    

    Monday, April 6, 2015

    Database Switchover and Failover on DR

    Switchover

    Convert primary database to standby

    Ensure that the last redo data transmitted from the primary database was applied on the standby database
    SQL>select sequence#,applied from v$archived_log;
    
    Check whether the primary is ready for switch.
    SQL>select switchover_status from v$database;
    If this query returns "TO STANDBY", then the environment is ready to switch. If it returns "SESSIONS ACTIVE", then the switch command should be used with the 'session shutdown' option.
    SQL>connect / as sysdba;
    SQL>alter database commit to switchover to physical standby with session shutdown;
    

    Shutdown and mount primary database for standby database
    SQL>shutdown immediate;
    SQL>startup nomount;
    SQL>alter database mount standby database;
    SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
    
    Verify the switchover status on new standby database
    SQL>select switchover_status from v$database;
    
    Above Query should return a value 'TO PRIMARY'

    Check the Database role after switch
    SQL>select database_role from v$database;
     
    On the original standby database issue the following commands.

    Convert standby database to primary

    SQL>connect / as sysdba;
    SQL>alter database commit to switchover to primary with session shutdown;
    

    Shutdown and Startup old standby database as primary
    SQL>SHUTDOWN IMMEDIATE;
    SQL>STARTUP;
    

    Check the Database role after switch
    SQL>select database_role from v$database;

    Failover

    If the primary database is not available the standby database can be activated as a primary database using the following statements.

    SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
    SQL>ALTER DATABASE ACTIVATE STANDBY DATABASE;
    

    Saturday, March 21, 2015

    Compile Invalid Objects using UTLRP.SQL and UTLIRP.SQL in R12

    UTLIRP.SQL

    This is a SQL script which Invalidates PL/SQL modules (procedures, functions, packages, types, triggers, views in a database). This script expects standard.sql, dbmsstdx.sql files. 

    There should be no other DDL on the database while running the script.

    For better performance set following parameter
    set  _disable_fast_validate=TRUE in init.ora file 

    connected AS SYSDBA

    start database in UPGRADE mode 
    SQL>STARTUP UPGRADE; or SQL>ALTER DATABASE OPEN UPGRADE;
    
    Run script utlirp.sql 
    SQL>@<ORACLE_HOME>/rdbms/admin/utlirp.sql


    UTLRP.SQL

    This script recompiles all existing invalid PL/SQL modules in a database. this invokes utlrcmp.sql

    There should be no other DDL on the database while running the script. 

    Connected AS SYSDBA

    Shut down the database and restart in normal mode 

    Run script utlrp.sql 
    SQL>@<ORACLE_HOME>/rdbms/admin/utlrp.sql

    Saturday, March 7, 2015

    Setup Printers for Cheque printing on Oracle EBS R12


    For Printer setup first need to setup from OS level and then setup from application

    Setup the printer at the OS level

    First we need to check the status for the Linux/UNIX based CUPS print server
    [root@ etc /]# /etc/init.d/cups status
    
    Then add the new printer to the LINUX environment, login to linux CUPS using following URL
    http://localhost:631/admin
    

    Click on Add Printer button and add printer details



    Click Continue button and select Device from drop down list for network printer select Apps Socket


    Enter IP for network printer 


    Select printer model and type



    And press continue. Now Printer is added from OS


    Setup through Application

    Navigation -  System Administrator -> Install -> Printer -> Register
    Define a new printer by entering the Printer Name and Type (Printer name must be same for both OS and application)


    For Custom style we can define new style  Add The printer to 'printer' profile option
    Navigation -  System Administrator -> Profile -> System 

    Select the style as 'PDF Publisher' and printer name for concurrent program.
    Navigation -  System Administrator -> Concurrent -> Program -> Define 
    Find the the relevant cheque printing program

    Bounce the Concurrent Manager to reflect the changes

    When run the concurrent program select the no of copies need to print