Tuesday, June 23, 2015

LOGICAL BACKUP PLAN - DUMP BACKUP



LOGICAL BACKUP PLAN - DUMP FILE FOR TRANSFFER AND BACKUP DATA

prerequisites and assumption :
====================
- Oracle 11gr2 installed on WINDOWS
- installed DB name : ORCL


TO DO :
======

1-      CREATE NEW FOLDER NAME "BACKUP" IN C:
2-       LOGIN AS SYSDBA
3-      SQL>CREATE OR REPLACE DIRECTORY BACKUP AS 'C:\BACKUP\';
5-      SQL>CREATE USER "BACKUPUSER" IDENTIFIED BY "BACKUP1" DEFAULT TABLESPACE "USERS" TEMPORARY TABLESPACE "TEMP" ACCOUNT UNLOCK;
SQL>GRANT CONNECT TO BACKUPUSER;
SQL>GRANT RESOURCE TO BACKUPUSER;
SQL>GRANT EXP_FULL_DATABASE TO BACKUPUSER;
SQL>GRANT READ,WRITE ON DIRECTORY BACKUP TO BACKUPUSER;



6-MAKE AUTODUMP.BAT IN C:\BACKUP LIKE BELOW :
============================================================================================
@Echo off
For /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set mydate=%%c_%%a_%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
expdp  BACKUPUSER/BACKUP1@ORCL full=y  directory=BACKUP dumpfile='expdp_dumpfile_%mydate%_%mytime%.dmp' logfile=dumpfile_exp%mydate%.log
if %ERRORLEVEL%==0 (echo "Success") else (echo "Failed with error code: " %ERRORLEVEL%)


7-       RUN AUTODUMP.BAT FILE TO CHECK IT ( TWO FILE (DMP ,LOG )SHOULD BE LOCATED IN C:\BACKUP)

8- USE WINDOWS SCHEDULE  TO CALL AUTODUMP.BAT FILE IN DAILY BASES

Sunday, June 21, 2015

Install Linux 6.5 + Gird + ASM + Standalone DB


This tutorial Show Installation of Standalone Oracle database 11gR2 realease 3 on Grid Infrastructure 
Linux 6.5 Environment
You Can Work  On Your Windows by using Oracle Virtual Box
Please make Sure You Download all required Software's Before Start


Required Software's:



Oracle Virtual Box :  Oracle VM
Oracle 11.2.0.3 patchset : 10404530  download ( Grid , Database ) from My Oracle Support
Oracle Linux : Linux 6.5


Videos :

Part 1 :




Part 2 :



part 3 :




Notes :

- you can also Install ASMlib from here




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

       

    Monday, February 2, 2015

    Oracle Database 11g R2 (11.2.0.1) on SUSE Linux Enterprise Server 11




    Install Oracle Database 11g R2 (11.2.0.1) on SUSE Linux Enterprise Server 11

    By Wisam Adel on 02 Feb 2015


    1- install Linux Suse interprise 11 with below  Hardware Requirements

    Memory :

    Recommended: 2 GB of RAM or more

    Swap :

    Minimum:  twice size of the Memory

    Network :

    define static ip


    2-after installation Logging In to the System as root


    Install below Required Packages :

    binutils-2.19
    gcc-4.3
    gcc-c++-4.3
    glibc-2.9
    glibc-devel-2.9
    ksh-93t
    libstdc++33-3.3.3
    libstdc++43-4.3.3_20081022
    libstdc++43-devel-4.3.3_20081022
    libaio-0.3.104
    libaio-devel-0.3.104
    libgcc43-4.3.3_20081022
    libstdc++-devel-4.3
    make-3.81
    sysstat-8.1.5
    unixODBC-2.2.12 or later
    unixODBC-devel-2.2.12 or later
    unixODBC-32bit-2.2.12 (32-bit) or later

    to install the packages goto yast2 ==> online update


    Search for each rpm and check it to install




    Installing SELinux Packages and modifying GRUB


    1. Log in to your server as root and start YaST2.
    2. Select Software+Software Management

    1. Select View+Patterns and select the entire C/C++ Compiler and Tools software category for installation.
    2. Select View+Search and make sure that Search in Name, Keywords and Summary are selected. Now enter the keyword selinux and click Search. You now see a list of packages.
    3. Make sure that all the packages you’ve found are selected and click Accept to install them.


    After installing the SELinux packages, you have to modify the GRUB boot loader. To do this, from YaST selectSystem > Boot loader. On the Section Management tab, you'll now see the current GRUB configuration. Select the label that starts with SUSE Linux Enterprise Server 11 SP2 and click Edit. Now select the line that contains the Optional Kernel Command Line Parameters and add the following to the end of this line:security=selinux selinux=1 enforcing=0

    Group and users :


    # groupadd oinstall
    # groupadd dba
    # groupadd oper

    # useradd -m -g oinstall -G dba,oper -s /bin/bash oracle

    # passwd oracle


    Kernal Parameters :

    # vi /etc/sysctl.conf

    and add or amend the following lines :

    fs.aio-max-nr = 1048576
    fs.file-max = 6815744
    kernel.shmall = 2097152
    kernel.shmmax = 536870912
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    net.ipv4.ip_local_port_range = 9000 65500
    net.core.rmem_default = 262144
    net.core.rmem_max = 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 1048576


    enter the following command to ensure that the system reads the /etc/sysctl.conf file when it restarts:

    # /sbin/chkconfig boot.sysctl on

    Enter the following command to change the current values of the kernel parameters:

    # /sbin/sysctl -p



     where the oinstall group GID is 1000:

    # echo 1000 > /proc/sys/vm/hugetlb_shm_group

    #vi /etc/sysctl.conf, and add this line

    vm.hugetlb_shm_group=1000

    # /sbin/sysctl -p


    Limits :

    # vi  /etc/security/limits.conf

    Add the following lines 
    oracle              soft    nproc   16384
    oracle              hard    nproc   16384
    oracle              soft    nofile  4096
    oracle              hard    nofile  65536
    oracle              soft    stack   10240

    Create The Directories :


    # mkdir -p /u01/app/
    # chown -R oracle:oinstall /u01/app/
    # chmod -R 775 /u01/app/
    # mkdir -p /u01/app/tmp


    Bash Profile

    #vi /home/oracle/.profile

    and add the following lines  :(note : amend "orcl" and "hostname.localdomain:  )


    ==========================
    # Oracle Settings
    TMP=/u01/app/tmp; export TMP
    TMPDIR=$TMP; export TMPDIR
    ORACLE_HOSTNAME=hostname.localdomain; 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
    
    LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
    CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
    ============================

    3- Install Database ( oracle 11gr2 )

    - login as oracle user

    - copy zip files to /u01/app/tmp and

    - extract the zip files

    - login to setup folder

    - #./runInstaller

    - follow screens to finish setup