Tuesday, May 26, 2015

Enterprise manager Configuration




1- make sure you have static IP also add it to hosts file



2-  Login as sysdba and follow the steps :
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP RESTRICT;
SQL> EXEC sysman.emd_maintenance.remove_em_dbms_jobs;
SQL> EXEC sysman.setEMUserContext('',5);
SQL> REVOKE dba FROM sysman;
SQL> DECLARE
    CURSOR c1 IS
      SELECT owner, synonym_name name
      FROM dba_synonyms
      WHERE table_owner = 'SYSMAN';
 
BEGIN
    FOR r1 IN c1
    LOOP
        IF r1.owner = 'PUBLIC' THEN
            EXECUTE IMMEDIATE 'DROP PUBLIC SYNONYM '||r1.name;
        ELSE
            EXECUTE IMMEDIATE 'DROP SYNONYM '||r1.owner||'.'||r1.name;
        END IF;
    END LOOP;
END;
/
SQL> DROP USER mgmt_view CASCADE;
SQL> DROP ROLE mgmt_user;
SQL> DROP USER sysman CASCADE;
SQL> ALTER SYSTEM DISABLE RESTRICTED SESSION;


 
3-  Make sure var -à path is oracle home

4-  Make sure sqlnet.ora has (NTS)

5-  Run : emca -repos drop
: emca -deconfig dbcontrol db ( -cluster for RAC)

6-  Run : emca -repos create
: emca -config dbcontrol db ( -cluster for RAC)



8-  Cmd> emctl start dbconsole

9-  login from web browser : https://hostname or IP:1158/em/console/aboutApplication

or https://hostname or IP:1158/em/console/logon/logon

Monday, May 25, 2015

Extending an LVM volume in Linux 6

 

Extending an LVM volume in Linux 6:

Storage Layers : Physical volumes (partitions) -> Volume groups -> Logical volume -> Filesystem

Logical Volumes are allocated/extended within the boundaries of their underlying storage pool which is called a Volume Group in LVM terminology. 

 
  • addto VMWare a new virtual hard disk 

  • as root user  
    •  check the newly added disks

# ls /dev/sd*

/dev/sda /dev/sda1 /dev/sda2 /dev/sdb

note that the new disk is : sdb

check Volume Group name:
 
# vgdisplay
 
 --- Volume group ---
  VG Name               vg_linux6
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               18.14 GiB
  PE Size               4.00 MiB
  Total PE              4645
  Alloc PE / Size       4480 / 17.50 GiB
  Free  PE / Size       00 / 00.00 MiB
  VG UUID               IwaFL0-QCi8-iIUE-TWjQ-R906-PYpH-gMPaH9
 
partition to the Volume Group:
# pvcreate /dev/sdb 
 
# vgextend vg_linux6 /dev/sdb
 
check the new free size 
 
#vgdisplay
 
 
After you've extended the Volume Group, you are free to extend the Logical Volume:

# lvdisplay

--- Logical volume ---
  LV Path                /dev/vg_linux6/LogVol01
  LV Name              LogVol00 
 VG Name              vg_linux6
  LV size         4.0 GB
..............
  LV Path                /dev/vg_linux6/LogVol01
  LV Name              LogVol01
  VG Name              vg_linux6
  LV size         16.0 GB
  
decide witch LV you want to extend then :
 
# lvextend -L+10G /dev/vg_linux6/LogVol01
 
note : 10G is the size of disk sdb
 

# resize2fs /dev/vg_linux6/LogVol01
 
check the new size of LV
 
# lvdisplay 

Create oracle Dump Backup with cron schedule in linux 6


Create oracle Dump Backup with cron schedule in linux 6

prerequisites and assumption :
- Oracle 11gr2 installed on linux 6.5
- installed DB name : orcl
- HR schema 
- knowledge of using VI editor ( i : to insert    ,   ESC ans :wq to save the content )


Follow below Steps :
  • Create shell file named "auto_dump.sh" in /u01/DUMPBACKUP :
    •  vi /u01/DUMPBACKUP/auto_dump.sh
    • paste the following


# please update hostname,oracle_base,oracle_unqname and SID to suite your installation
ORACLE_HOSTNAME=linux6.site; export ORACLE_HOSTNAME
ORACLE_UNQNAME=orcl; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID

PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

# dump and log file names with date format

DUMPFILE=$(date '+expdp_%Y_%m_%d_%s.dmp')
LOGFILE=$(date '+expdp_%Y_%m_%d_%s.log')
 
# please update user to your powerful user 

USER=system
PWD=your_password
 
# please specify your schema or FULL=y

expdp $USER/$PWD compression=all SCHEMAS=HR DIRECTORY=datapump_exp_imp_file dumpfile=$DUMPFILE logfile=$LOGFILE

exit

      • ESC and  :wq to save content

    • as root user :
      •  mkdir -p /u01/DUMPBACKUP
      • chown -R oracle:oinstall  /u01/DUMPBACKUP
      • chmod -R 775 /u01/DUMPBACKUP
    • Login to SQL as sysdba 
      • sql>create or replace directory datapump_exp_imp_file as '/u01/DUMPBACKUP';
    • test shell manually in terminal :
      • bash /u01/DUMPBACKUP/auto_dump.sh
    • to schedule shell:
      • crontab -e
      • to run at 6 am every day add the following line
        • 0 6 * * * /u01/DUMPBACKUP/auto_dump.sh >> /u01/DUMPBACKUP/Dump_export.log 2>&1  
        • :wq