BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡

±Û¾´ÀÌ: °³¶óŬ ¿À¶óŬ ¹é¾÷½ºÅ©¸³Æ® Á¶È¸¼ö: 2966

http://m.blog.naver.com/xogstar/2217643

Oracle Database ¹é¾÷ ¹æ¹ý

¾È³çÇϼ¼¿ä? ORACLE DBA ÀÌÅÂÈÆÀÔ´Ï´Ù.
¿À´ÃÀº Á¦°¡ ½Ç¹«¿¡¼­ »ç¿ëÇÏ°í ÀÖ´Â Oracle ¹é¾÷ ¹æ¹ýÀ» °øÀ¯µå¸®·Á°í ÇØ¿ä.

Àú´Â ¹°¸®/³í¸® ¹é¾÷À» ¼öÇàÇÏ´Â Shell Script¸¦ °¢°¢ ¸¸µç ÈÄ¿¡

crontab¿¡ µî·ÏÇؼ­ ÀÚµ¿À¸·Î ¸ÅÀÏ µ¹¾Æ°¡°Ô²û ±¸¼ºÀ» Çسõ½À´Ï´Ù.

https://m.blog.naver.com/xogstar/221764350268

¿ì¼± .bash_profile ³»¿ëÀ» ¸ÕÀú ¼Ò°³ÇÏ°í

À̾ script, crontab µî·Ï ¹æ¹ýÀ» ¼³¸íµå¸±°Ô¿ä.

±Ã±ÝÇϽŠ»çÇ×ÀÌ ÀÖÀ¸½Ã¸é ´ñ±Û ³²°ÜÁÖ¼¼¿ä.


$ cat ~/.bash_profile


if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

# User specific environment and startup programs

umask 022




export ORACLE_HOSTNAME=triana

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/19.0.0.1

export ORACLE_SID=triana

export ORACLE_UNQNAME=triana

export ORACLE_SERVICE=triana

export ORACLE_TERM=xterm

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

export DISPLAY=X.X.X.X:0 # ¿À¶óŬ ¼³Ä¡¿ëÀ¸·Î »ç¿ëÇÑ Display ȯ°æº¯¼ö. #

export PATH=$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin




stty erase ^H




export ADUMP=$ORACLE_BASE/admin/triana/adump

export BDUMP=/u01/app/oracle/diag/rdbms/triana/triana/trace




PS1=oracle@`hostname`:'${PWD}> '




alias oh='cd $ORACLE_HOME'

alias alert='vi $BDUMP/alert_triana.log'

alias alertf='tail -30f $BDUMP/alert_triana.log'

alias bdump='cd $BDUMP'

alias oralog='cd $ORACLE_HOME/oramon/src/event'

alias log='cd $ORACLE_HOME/oramon/log'

alias sd='sqlplus / as sysdba'

alias cl='clear'

alias oradata='cd /u01/app/oracle/oradata/triana'

alias ds='$ORACLE_HOME/oramon/src/event/lth/d.sh'

alias rpt='cd $ORACLE_HOME/oramon/src/event/lth'

export NLS_LANG=AMERICAN_AMERICA.KO16MSWIN949













±× ´ÙÀ½Àº Shell Script ³»¿ë°ú Crontab ³»¿ë ÀÔ´Ï´Ù.







1-1. ¹°¸®¹é¾÷ : RMAN Àüü ¹é¾÷ ½©½ºÅ©¸³Æ®(Àüü¹é¾÷/ÁÖ°£)







$ cat /data/rman_bck/rman_bck.sh







#!/bin/ksh




. ~/.bash_profile

export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss'




LOG=/data/rman_bck/log/rman_`/bin/date +'%Y%m%d'`.log

BCK_PATH=/data/rman_bck/bckdata




#######################################

## delete archive log file

#######################################

/usr/bin/find /archive/ -name "*.arc" -mtime +20 -exec /bin/rm {} \; # 21ÀÏ ÈÄ ¾ÆÄ«ÀÌºê ·Î±× »èÁ¦ #




#######################################

## delete & move backup piece #±âº»ÀûÀ¸·Î ÀÌ ½ºÅ©¸³Æ®´Â ¸ÅÁÖ ÀÏ¿äÀϸ¶´Ù µ¹¾Æ°¡°Ô ¼³Á¤µÊ. #

#######################################

date >> $BCK_PATH/rman_bck.log # ¹é¾÷ ½ÃÀÛ Àü Áö³­ÁÖ ¹é¾÷ ÆÄÀÏÀ» old °æ·Î·Î À̵¿ #

/bin/rm -v /data/rman_bck_old/*.rman >> $BCK_PATH/rman_bck.log # ¹é¾÷ ½ÃÀÛ Àü 2ÁÖ Àü ¹é¾÷ »èÁ¦ #

/bin/mv -v $BCK_PATH/*.rman /data/rman_bck_old >> $BCK_PATH/rman_bck.log

echo "====================================" >> $BCK_PATH/rman_bck.log




#######################################

## crosscheck, delete expired backup # ¹°¸® ÆÄÀÏÀ» ¸ÕÀú Áö¿ì°í Control ÆÄÀÏ¿¡ ±â·ÏµÈ ¸ÞŸµ¥ÀÌÅ͵µ #

####################################### # »èÁ¦Çϱâ À§Çؼ­ crosscheck ¼öÇà #

rman target / nocatalog << EOF >> $LOG 2>&1




run {

allocate channel c1 type disk;

crosscheck backup; # ¹°¸® Àüü ¹é¾÷ ÆÄÀÏÀÌ ¾ø´Â ³í¸® ±â·Ï ½Äº° #

crosscheck archivelog all COMPLETED before 'sysdate-1/24'; # ¾ÆÄ«À̺ê ÆÄÀÏÀÌ ¾ø´Â ³í¸® ±â·Ï ½Äº° #

delete noprompt expired backup; # ½Äº°µÈ expired backupset ±â·Ï »èÁ¦ #

delete noprompt expired archivelog all; # ½Äº°µÈ expired archivelog ±â·Ï »èÁ¦ #

delete noprompt archivelog until time 'sysdate-22'; # 22ÀÏ ÀÌ»ó Áö³­ ¾ÆÄ«ÀÌºê ·Î±× »èÁ¦ #

backup format '$BCK_PATH/dbf_%U_%T.rman'(database); # µ¥ÀÌÅͺ£À̽º Àüü ¹é¾÷(backupset) ¼öÇà #

sql 'alter system archive log current'; # ¹é¾÷ ¼öÇà ÈÄ ¹é¾÷ ÁøÇà °£ ½×ÀÎ redo log ¾ÆÄ«À̺êÈ­ #

release channel c1;

}

exit

EOF




#######################################

## start rman archive log backup

#######################################

rman target / nocatalog << EOF2 >> $LOG 2>&1




run {

allocate channel c1 type disk;

sql 'alter system archive log current';

backup # 25½Ã°£ ÀüºÎÅÍ ¹é¾÷ÀÌ ¼öÇàµÉ ¶§±îÁöÀÇ ¸ðµç ¾ÆÄ«À̺ê·Î±× ¹é¾÷ #

(archivelog

from time 'sysdate-(1+1/24)' until time 'sysdate - 3/1440'

format '$BCK_PATH/arc_%U_%T.rman'

);

release channel c1;

}




EOF2




# RMAN Àüü ¹é¾÷ ½ºÅ©¸³Æ® ³»¿ë ³¡ #













1-2 ¹°¸®¹é¾÷ : RMAN Àüü ¹é¾÷ Å©·ÐÅÇ ¼³Á¤




$ crontab -l

##############################

### RMAN Backup ###

##############################



10 20 * * 0 /data/rman_bck/rman_bck.sh > /dev/null 2>&1







# ¾Æ·¡ºÎÅÍ´Â ÀÏÀϹé¾÷(¾ÆÄ«ÀÌºê ·Î±×¹é¾÷) ³»¿ë #



















1-3 ¹°¸®¹é¾÷ : RMAN ¾ÆÄ«ÀÌºê ·Î±× ¹é¾÷ ½©½ºÅ©¸³Æ®(¾ÆÄ«À̺ê/ÀÏÀÏ)







$ cat /data/rman_bck/archive_bck.sh







#!/bin/ksh




. ~/.bash_profile

export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss'




LOG=/data/rman_bck/log/rman_`/bin/date +'%Y%m%d'`.log

BCK_PATH=/data/rman_bck/bckdata




#######################################

## delete archive log file # 8ÀÏ ÀÌ»ó Áö³­ ¾ÆÄ«ÀÌºê ·Î±× ÆÄÀÏ »èÁ¦ #

#######################################

/usr/bin/find /archive/ -name "*.arc" -mtime +7 -exec /bin/rm {} \;




#######################################

## crosscheck, delete expired backup # ½ÇÁ¦ ÆÄÀÏ Á¸Àç ¿©ºÎ¿Í Control ÆÄÀÏ ³» ³í¸®±â·Ï ºñ±³ #

#######################################

rman target / nocatalog << EOF >> $LOG 2>&1




run {

allocate channel c1 type disk;

crosscheck backup;

crosscheck archivelog all COMPLETED before 'sysdate-1/24';

delete noprompt expired backup;

delete noprompt expired archivelog all;

delete noprompt archivelog until time 'sysdate-22';

sql 'alter system archive log current';

release channel c1;

}

exit

EOF




#######################################

## start rman backup # 26½Ã°£ ÀüºÎÅÍ ÇöÀç±îÁöÀÇ ¾ÆÄ«ÀÌºê ·Î±× ¹é¾÷ #

#######################################

rman target / nocatalog << EOF2 >> $LOG 2>&1




run {

allocate channel c1 type disk;

sql 'alter system archive log current';

backup

(archivelog

from time 'sysdate-(1+2/24)' until time 'sysdate - 3/1440'

format '$BCK_PATH/arc_%U_%T.rman'

);

release channel c1;

}

exit

EOF2







# RMAN ¾ÆÄ«ÀÌºê ·Î±× ¹é¾÷ ½ºÅ©¸³Æ® ³»¿ë ³¡ #







1-4. ¹°¸®¹é¾÷ : RMAN ¾ÆÄ«ÀÌºê ¹é¾÷ Å©·ÐÅÇ ¼³Á¤










$ crontab -l

##############################

### RMAN Backup ###

##############################

10 20 * * 1,2,3,4,5,6 /data/rman_bck/archive_bck.sh > /dev/null 2>&1







# ¹°¸®¹é¾÷ RMAN ¾ÆÄ«ÀÌºê ¹é¾÷ Å©·ÐÅÇ ³»¿ë ³¡ #



















2-1. ¹°¸®¹é¾÷ : ¼öµ¿¹é¾÷À» ÀÌ¿ëÇÑ ¹é¾÷ ½ºÅ©¸³Æ®







&#8203;&#65279;#!/bin/bash




_BCK_DIR=/oracle/app/oracle/product/11.2.0/dbhome_1/oralog/bck

_LOGFILE=$_BCK_DIR/backup_`date +%y%m%d`.log




. ~/.bash_profile




rm $_BCK_DIR/*.tmp

rm $_BCK_DIR/*.sql

rm $_BCK_DIR/*.lst




echo Hot Backup start : `date` > $_LOGFILE




$ORACLE_HOME/bin/sqlplus "/as sysdba" <> $_LOGFILE




set echo off

prompt #######################

prompt ## BEGIN/END Scripts ##

prompt #######################




set lines 132 pages 1000 trims on heading off feedback off time on




select 'alter tablespace ' || tablespace_name || ' begin backup;'

from dba_tablespaces where contents!='TEMPORARY';

spo $_BCK_DIR/bbackup.tmp

/

spo off




select 'alter tablespace ' || tablespace_name || ' end backup;'

from dba_tablespaces where contents!='TEMPORARY';

spo $_BCK_DIR/ebackup.tmp

/

spo off




prompt ###################

prompt ## DATAFILE LIST ##

prompt ###################




col file_name for a50

col dest for a50

col jjj for a100




select

file_name || ' ' || '/home/orabackup/datafile/'||substr(file_name, instr(file_name, '/',-1)+1, length(file_name)) jjj

from dba_data_files

order by 1;

spo $_BCK_DIR/file.tmp

/

spo off

exit

EOF0







cat $_BCK_DIR/bbackup.tmp | grep alter | grep -v SQL > $_BCK_DIR/bbackup.sql

##echo exit >> $_BCK_DIR/bbackup.sql

cat $_BCK_DIR/ebackup.tmp | grep alter | grep -v SQL > $_BCK_DIR/ebackup.sql

##echo exit >> $_BCK_DIR/ebackup.sql

sed -e '1,2d' -e '$d' $_BCK_DIR/file.tmp > $_BCK_DIR/file.lst




tail -v $_BCK_DIR/*up.sql >> $_LOGFILE




$ORACLE_HOME/bin/sqlplus "/as sysdba" <> $_LOGFILE




prompt ##################

prompt ## BEGIN backup ##

prompt ##################




alter system switch logfile;

@$_BCK_DIR/bbackup.sql

exit

EOF1




awk '{print $2}' $_BCK_DIR/file.lst | while read DEL_LIST

do

ftp -n <open X.X.X.X # ¿ø°ÝÁö ¹é¾÷ ÆÄÀÏ ÀúÀå¿ë ¼­¹ö¿¡ Á¢¼ÓÇÏ¿© Áö³­ ÁÖ ¹é¾÷À» »èÁ¦ #

user [username] *********

passive

del $DEL_LIST

bye

EOF2

done




echo ###################### >> $_LOGFILE

echo ## UPLOAD DATAFILES ## >> $_LOGFILE

echo ###################### >> $_LOGFILE

echo `date` >> $_LOGFILE




cat $_BCK_DIR/file.lst | while read FILE_LIST

do

ftp -n <open X.X.X.X # ¿ø°ÝÁö ¹é¾÷ ÆÄÀÏ ÀúÀå¿ë ¼­¹ö¸¦ ¿­¾î À̹øÁÖ ¹é¾÷ ÆÄÀÏ Àü¼Û #

user [username] *********

passive

ha

bi

prompt

put $FILE_LIST

bye

EOF3

done




$ORACLE_HOME/bin/sqlplus "/as sysdba" <> $_LOGFILE




prompt ################

prompt ## END backup ##

prompt ################




@$_BCK_DIR/ebackup.sql

alter system switch logfile;

alter database backup controlfile to trace as '$_BCK_DIR/control.trc' reuse;

alter database backup controlfile to '$_BCK_DIR/control_bck.ctl' reuse;

exit

EOF4




ftp -n <open X.X.X.X # ¿ø°ÝÁö ¹é¾÷ ÆÄÀÏ ÀúÀå¿ë ¼­¹ö¿¡ CONTROL¿¡ ´ëÇÑ ¹é¾÷ ÆÄÀÏ(.trc) Àü¼Û #

user [username] *********

passive

ha

bi

prompt

lcd $_BCK_DIR

cd /home/orabackup

mput control*

bye

EOF5




echo ######################## >> $_LOGFILE

echo ## Archive log backup ## >> $_LOGFILE

echo ######################## >> $_LOGFILE

echo `date` >> $_LOGFILE




find /oraarch/*.dbf -name '1_*_772932672.dbf' -mtime -9 | sort $8 > # DB ID or Archive ÆÄÀÏ¸í ¼öÁ¤ #




$_BCK_DIR/arc_file.lst

tar -cv -T $_BCK_DIR/arc_file.lst -f /oraarch/arclog_`date +%y%m%d`.tar >> $_LOGFILE

gzip /oraarch/arclog_`date +%y%m%d`.tar




ftp -n <open X.X.X.X # ¿ø°ÝÁö ¹é¾÷ ÆÄÀÏ ÀúÀå¿ë ¼­¹ö¿¡ ¹­Àº Archive Log ÆÄÀÏ Àü¼Û #

user [username] *********

passive

ha

bi

prompt

lcd /oraarch

cd /home/orabackup/arch

prompt

mdel arclog_*.tar.gz

prompt

put arclog_`date +%y%m%d`.tar.gz

bye

EOF6




find /oraarch -name '1_*_772932672.dbf' -mtime +32 -exec rm -f {} \;




echo Hot Backup end : `date` >> $_LOGFILE







# ¹°¸®¹é¾÷ ¼öµ¿ ½ºÅ©¸³Æ® ³»¿ë ³¡ #










2-2 ¹°¸®¹é¾÷ : ¼öµ¿¹é¾÷À» ÀÌ¿ëÇÑ ¹é¾÷ Å©·ÐÅÇ







$ crontab -l

############################

## Oracle On-line Backup #

############################

30 3 * * 0 /oracle/app/oracle/product/11.2.0/dbhome_1/oralog/bck/hot_bck.sh >> /dev/null




# ¹°¸®¹é¾÷ ¼öµ¿ Å©·ÐÅÇ ³»¿ë ³¡ #













3-1. ³í¸®¹é¾÷ : datapumpÀ» ÀÌ¿ëÇÑ ¹é¾÷ ½©½ºÅ©¸³Æ®










$ cat /share/backup/dump/backup.sh




#!/bin/bash




#######################################

### Oracle Data Pump Export Backup ###

#######################################

_DATE=`date '+%Y%m%d%H'`

_BCK=/share/backup/dump

_BCK_OLD=/share/backup/dump_bck




. ~/.bash_profile

find ${_BCK}/ -name 'full_*.tar.gz' -mtime +6 -exec mv {} ${_BCK_OLD} \;

find ${_BCK}/ -name 'full_*.log' -mtime +6 -exec mv {} ${_BCK_OLD} \;

find ${_BCK_OLD}/ -name 'full_*.tar.gz' -mtime +20 -exec rm {} \;

find ${_BCK_OLD}/ -name 'full_*.dmp.gz' -mtime +20 -exec rm {} \;




rm -r ${_BCK}/full_*_f




$ORACLE_HOME/bin/expdp triana/triana directory=everyday schemas=triana parallel=8 dumpfile=full%U.dmp logfile=full_${_DATE}.log # DB À¯Àú Æнº¿öµå ÀÔ·Â, Directory Object ¼³Á¤ ÇÊ¿ä #




mkdir -p ${_BCK}/full_${_DATE}_f

mv ${_BCK}/full??.dmp ${_BCK}/full_${_DATE}_f

tar -zcvf ${_BCK}/full_${_DATE}.tar.gz ${_BCK}/full_${_DATE}_f




date >> ${_BCK}/full_${_DATE}.log




# ³í¸®¹é¾÷ ½ºÅ©¸³Æ® ³»¿ë ³¡ #










3-2. ³í¸®¹é¾÷ : Datapump ¹é¾÷À» ÀÌ¿ëÇÑ ¹é¾÷ Å©·ÐÅÇ







$ crontab -l




#######################################

### Oracle Data Pump Export Backup ###

#######################################

30 12,18 * * * /share/backup/dump/backup.sh > /share/backup/dump/backup.log




# ³í¸®¹é¾÷ Å©·ÐÅÇ ³»¿ë ³¡ #



°ü·Ã±Û : ¾øÀ½ ±Û¾´½Ã°£ : 2021/05/21 23:31 from 122.32.218.68

  ¿À¶óŬ ¹é¾÷ °³³ä ¸ñ·Ïº¸±â »õ±Û ¾²±â Áö¿ì±â ÀÀ´ä±Û ¾²±â ±Û ¼öÁ¤ ¿À¶óŬ silent ¼³Ä¡  
BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡