Kamis, 23 Juli 2020

Latihan 04 Baru

Pembaruan catatan untuk latihan04 nomor 3

1. #Define SQLDBA sebagai alias dari  sqlplus / as sysdba 

   DBCONN=" / as sysdba"  
   SQLDBA="${ORACLE_HOME}/bin/sqlplus -s ${DBCONN}"

2. Contoh Penggunaannya sbb :
   - $SQLDBA  <<-EOF
       alter system SWITCH LOGFILE;
       exit;
     EOF
   
   - Bila hasil query ingin ditulis ke file archive.lis 

      $SQLDBA > ${BKUPDIR}/archive.lis <<-EOF
      set pages 0
      set lines 80
      set head off
      set echo off
      set verify off
      set feedback off
      column name format a80
      
      select name from v\$archived_log
      where SEQUENCE# >= $maxlog;
      exit;
      EOF
      
      statement set pages, lines, head, echo, verify, feedback adalah agar 
      outputnya hanya isi data saja tanpa kolom judul, break page, feedback
      
   -  Contoh membaca isi file line per line dan copy ke backup direktori
      
      cat $BKUPDIR/archive.lis | while read arch
      do      # awal loop
         cp $arch $BKUPDIR
      done    # end loop 
      

3. Urutan proses hot backup :
   
   - Set environment dan variable 
   - step-01 : Switch log file
   - step-02 : Ambil max sequence dari online redo log ( dari v\$log )
   - step-03 : Create file $BKUPDIR/tablespace.lis  yang berisi list tablespaces yang akan dibackup
   - step-04 : Create file $BKUPDIR/datafile.lis yang berisi list datafiles untuk setiap tablespaces
   - step-05 : Baca file $BKUPDIR/tablespace.lis, loop untuk semua tablespace lalu loop untuk datafile, logik sbb:
               cat $BKUPDIR/tablespace.lis | while read ts
               do    #loop tablespace            
                 cat $BKUPDIR/tablespace.lis | while read df
                   do #loop datafile dari tablespace 
                      - begin backup ts
                      - backup df
                      - end backup ts
                   done
               done
                            
   - step-06 : Backup file-file init, spfile, controlfile
   - step-07 : Switch log file
   - step-07 : Create file ${BKUPDIR}/archive.lis yang berisi list archive selama backup 
               dari v\$archived_log dengan SEQUENCE# >= $maxlog;
   - step-08 : Backup archive log
   - echo "Timestamp : `date` :Hot backup tablespace $DBNAME selesai  "