ºìÁªLinuxÃÅ»§
Linux°ïÖú

ÓÃLinuxÍê³ÉOracle×Ô¶¯ÎïÀí±¸·Ý

·¢²¼Ê±¼ä:2005-06-07 00:19:16À´Ô´:ºìÁª×÷Õß:linux_
OracleÊý¾Ý¿âÌṩÁ˼¸ÖÖÊý¾Ý±¸·Ý·½·¨£¬µ«ÓõÃ×î¶àµÄ»¹ÊÇʹÓÃexp½øÐÐÂß¼­±¸·Ý£¬¶øÎïÀí±¸·Ý£¨°üÀ¨Áª»ú±¸·ÝºÍÍÑ»ú±¸·Ý£©¹ý³ÌÓõò¢²»¶à¡£ÆäÖ÷ÒªÔ­ÒòÊÇÎïÀí±¸·Ý¹ý³Ì±È½Ï¸´ÔÓ£¬²»Ò×ÕÆÎÕ¡£±¾ÎÄÒÔOracleÊý¾Ý¿âÔÚLinuxÏÂ×Ô¶¯ÎïÀí±¸·Ý£¨ÍÑ»ú±¸·Ý£©µÄʵÏÖΪÀýÃèÊöÎïÀí±¸·ÝµÄ²Ù×÷²½Ö裬ϣÍûÄÜ°ïÖú¸ü¶àµÄOracleÊý¾Ý¿â¹ÜÀíÔ±Á˽âÕâÒ»ÎïÀí±¸·Ý¹ý³Ì£¬±ÜÃâ²»±ØÒªµÄÊý¾Ý¶ªÊ§¡£

¡¡¡¡±¾ÎĵÄÄ¿±êÊÇͨ¹ýÖ´ÐÐÒ»Shell½Å±¾À´Íê³ÉOracleÊý¾Ý¿â×Ô¶¯±¸·ÝµÄÈ«¹ý³Ì£¬¶øÇÒÄܹ»ÔÚµ±Ç°Ä¿Â¼ÏÂÉú³ÉÆäѹËõÎļþ¡£¾ßÌåʵÏÖ²½ÖèÈçÏ£º

1£®ÒÔOracleÓû§Éí·ÝµÇ¼µ½LinuxϵͳÏ¡£

2£®½¨Á¢database.srciptÎļþ£¬ÒÔ±ãÉú³É±¸·ÝÊý¾Ý¿âµÄһЩ²ÎÊýÐÅÏ¢²¢±£´æÔÚÎļþdatabase.parmÖС£

¡¡¡¡ÕâЩÐÅÏ¢¶ÔÓÚÒÔºó»Ö¸´Êý¾Ý¿â¾ßÓÐÖØÒªµÄ²Î¿¼×÷Óã¬ËùÒÔÔÚÎïÀí±¸·ÝµÄ¹ý³ÌÖУ¬ÐèÒª±£´æÕâЩÐÅÏ¢£¬Ò²¿ÉÒÔ°ÑÆäËûһЩÖØÒªµÄÐÅϢдÔÚÕâ¸ö½Å±¾Àï¡£

$vi database.srcipt
spool database.parm
--ÕâÊǵ±Ç°±¸·ÝÊý¾Ý¿âµÄϵͳ²ÎÊýÁбí
select * from v$parameter;
--ÕâÊǵ±Ç°±¸·ÝÊý¾Ý¿âµÄ×Ö·û¼¯²¿·Ö²ÎÊý
select * from props$;
--ÕâÊǵ±Ç°±¸·ÝÊý¾Ý¿âÊý¾ÝÎļþ´æ´¢Î»Öü°Ãû³Æ
select * from v$datafile;
--ÕâÊǵ±Ç°±¸·ÝÊý¾Ý¿â¿ØÖÆÎļþ´æ´¢Î»Öü°Ãû³Æ
select * from v$controlfile;
--ÕâÊǵ±Ç°±¸·ÝÊý¾Ý¿âÈÕÖ¾Îļþ´æ´¢Î»Öü°Ãû³Æ
select * from v$logfile;
--¿ÉÒÔÔÚÕâÀïÌí¼ÓÆäËûһЩÖØÒªÐÅÏ¢
--¿ªÊ¼Éú³É±¸·ÝshellÎļþ£¬¿É²Î¿¼backup.sh
spool off
spool backup.sh
select 'cp '||name || ' backup/' from v$datafile ;
select 'cp '||name || ' backup/' from v$controlfile ;
select 'cp '||member || ' backup/' from v$logfile;
spool off
shutdown immediate
exit
!



3£®ÐÞ¸ÄÉÏÒ»²½ÖÐÉú³ÉµÄbackup.shÎļþ£¬²¢Ö´ÐÐËüÀ´Íê³ÉÊý¾Ý¿âÎļþµÄ²Ù×÷ϵͳ±¸·Ý¡£ÎªÇåÎúÆð¼û£¬½«Õâ¶Î½Å±¾ÃüÃûΪÎļþalterbackup.sh¡£

$vi alterbackup.sh
echo ¡°¸Ã½Å±¾Íê³É°ÑÊý¾Ý¿âÊý¾ÝÎļþ¡¢¿ØÖÆÎļþ¡¢ÈÕÖ¾ÎļþµÄ¸´ÖƵ½µ±Ç°Ä¿Â¼µÄ¹ý³Ì¡±
cat backup.sh|grep ¡®cp /¡¯>c.sh
#¸ÃÓï¾ä°Ñbackup.shÖÐËùÓÐÒÔ¡°cp /¡±¿ªÍ·µÄÓï¾äÌáÈ¡³öÀ´Éú³ÉеÄÎļþc.sh
rm backup.sh
mv c.sh backup.sh
chmod +x backup.sh
. backup.sh
#×¢Ò⣺µãºÅ¡°.¡±Óëbackup.shÖ®¼äÓÐÒ»¿Õ¸ñ



4£®½¨Á¢Êý¾Ý¿âÆô¶¯½Å±¾£¬ÒÔ±ãÍê³É±¸·ÝÖ®ºóÆô¶¯Êý¾Ý¿â£¬½«Õâ¶Î½Å±¾ÃüÃûΪstartup.script¡£

$vi startup.script
spool StartStatus.readme
--¿ªÊ¼Æô¶¯Êý¾Ý¿â
startup
--Êý¾Ý¿âÆô¶¯Íê³É£¬¿ÉÒԲ鿴StartStatus.readmeÎļþ¼ì²éÊý¾Ý¿âÆô¶¯Çé¿ö
spool off
exit
!



5£®Îª½ÚÊ¡´ÅÅÌ¿Õ¼äºÍ¸´ÖƵ½ÆäËû´æ´¢Î»Ö㬽¨Á¢ShellÎļþgzip.scriptÀ´Íê³É±¸·ÝÊý¾ÝÎļþµÄѹËõ¡£×¢ÒâÉú³É±¸·ÝÎļþʱ£¬ÔÚÎļþÃûÖÐ×¢Ã÷ʱ¼ä¡£

$vi gzip.sh
echo ¡°¿ªÊ¼½øÐб¸·ÝÎļþµÄѹËõ¹ý³Ì¡±
thedate=¡®date + %Y.%m.%d.%H.%M¡¯
#×¢Ò⣺×Ö·û´®Ç°ºó¶¼ÓÐÒ»¸ö·´ÒýºÅ£¬²»Êǵ¥ÒýºÅ
outfile=$thedate
tar -cvf backup$outfile.tar backup/*
#½«±¸·Ýµ½backupĿ¼ÏµÄËùÓÐÎļþÉú³ÉÒ»µµ°¸Îļþ
gzip backup$outfile.tar
#°Ñµµ°¸Îļþ½øÐÐѹËõ£¬ÒÔ½ÚÊ¡Ó²ÅÌ¿Õ¼ä
rm -R backup #ɾ³ýÄÇЩûÓÐѹËõµÄÎļþ



6£®°ÑÉÏÃæµÚ2²½µ½µÚ5²½Éú³ÉµÄÄÚÈÝ×éÖ¯³ÉÒ»¸öShellÎļþbegin.sh£¬µ«Õâ֮ǰ»¹ÐèÒªÏÈÔËÐÐÒÔÏÂÃüÁ

$chmod +x alterbackup.sh
$chmod +x gzip.sh
$vi begin.sh
echo ¡°¿ªÊ¼½øÐÐÊý¾Ý¿âµÄ×Ô¶¯ÎïÀí±¸·Ý¹ý³Ì£¬¸ÃShell½«ÔÚµ±Ç°Ä¿Â¼ÏÂÉú³Ébackup.gzÎļþ£¬
¸ÃÎļþÖаüº¬Êý¾Ý¿âµÄһЩ²ÎÊýÐÅÏ¢¼°Êý¾Ý¿âµÄÎïÀíÎļþ¡­¡­¡±
mkdir backup
sqlplus internal/oracle < database.srcipt
. alterbackup.sh
sqlplus internal/oracle < startup.script
. gzip.sh
echo ¡°Êý¾Ý¿â×Ô¶¯½øÐÐÎïÀí±¸·Ý¹ý³Ì½áÊø£¬ÇëÔÚµ±Ç°Ä¿Â¼Ï¼ì²ébackup.tar.gz¡±



7£®Ôö¼ÓÊý¾Ý¿â²ÎÊýÎļþµÄ±¸·ÝÓï¾ä¡£

¡¡¡¡Êý¾Ý¿â²ÎÊýÎļþͨ³£´æ´¢ÔÚ¡°ORACLE/ADMIN/Êý¾Ý¿âÃû/pfile/¡±Ä¿Â¼Ï£¬ÆäÎļþÃüÃû¹æÔòΪ¡°init+Êý¾Ý¿âÃû.ora¡±£¬Êý¾Ý¿âÃûȱʡÃû³ÆΪorcl£¬¿É¸ù¾ÝÊý¾Ý¿â°²×°Ãû³ÆÀ´½øÐÐÐ޸ġ£Èç¹û²»ÖªµÀ¸ÃÎļþ´æ´¢ÔÚʲôλÖ㬿ÉʹÓÃÏÂÃæÃüÁî½øÐвéÕÒ£º

$find $ORACLE_HOME -name ¡®initorcl.ora¡¯



¡¡¡¡¸ÃÓï¾ä¿ÉÄÜÏÔʾ³ö/u01/app/oracle/product/8.1.7/dbs/initorcl.ora£¬ÓÉÓÚÔÚLinuxÖÐÓÐÒ»ÖÖÁ´½ÓÎļþ£¬ËùÒÔÒª²é¿´ÏÔʾ³öµÄÎļþÊDz»ÊÇÁ´½ÓÎļþ£¬Èç¹ûÊÇ£¬»¹ÐèÒª½øÒ»²½²é¿´ÆäԭʼÎļþ¡£

$ll /u01/app/oracle/product/8.1.7/dbs/initorcl.ora



¡¡¡¡±¾ÀýÖÐÏÔʾ³ö¸ÃÎļþÊÇÒ»¸öÁ´½ÓÎļþ£¬ËüÖ¸Ïò/u01/app/oracle/admin/orcl/pfile/initorcl.ora¡£Îª´Ë£¬¿ÉÒÔÐ޸ĵÚ3²½µÄalterbackup.sh£¬Ð޸Ľá¹ûÈçÏ£¨´ÖÌåÏÔʾ£¬¸ÃÓï¾äÐèÒª¸ù¾ÝÊý¾Ý¿â°²×°Çé¿ö½øÐÐÐ޸ģ©£º

¡­¡­
chmod +x backup.sh
cp /u01/app/oracle/admin/orcl/pfile/initorcl.ora backup/initorcl.ora
. backup.sh
#×¢Ò⣺µãºÅ¡°.¡±Óëbackup.shÖ®¼äÓÐÒ»¿Õ¸ñ



8£®ÔÚ×¼±¸½øÐб¸·Ýʱ£¬ÏÈʹÓá°ls -l£¨»òll£©¡±ÃüÁî¼ì²éµ±Ç°Ä¿Â¼Ï£¬´ËʱӦ¸ÃÓÐÕâÑù¼¸¸öÎļþ£ºalterbackup.Sh£¬begin.sh£¬database.script£¬gzip.sh£¬startup.script¡£

¡¡¡¡´Ëºó£¬»¹Ó¦Ö´ÐÐÃüÁ

$chmod +x begin.sh



¡¡¡¡Èç¹ûÒ»ÇÐÍê³É£¬¾Í¿ÉÒÔÖ´ÐÐbegin.shÀ´Íê³É±¸·Ý¹ý³ÌÁË:

. begin.sh
#×¢Òâbegin.shÓëÇ°ÃæµãºÅ֮ǰÓÐÒ»¿Õ¸ñ¡£



¡¡¡¡ÒÔºóÿ´ÎÐèÒª×ö±¸·Ýʱ£¬Ö»ÐèÔËÐÐbegin.sh¼´¿É¡£ÕâÀïÒ²¿ÉÒÔʹÓÃcrontab×Ô¶¯Íê³É°´¼Æ»®±¸·Ý£¬ÓйØÈçºÎʹÓÃcrontab£¬Çë²Î¿¼Ïà¹Ø×ÊÁÏ£¬Ò²¿ÉÔÚÍøÉϲéѯ£¬±¾ÎIJ»ÔÙ×ö½éÉÜ¡£

¡¡¡¡Ê¹Óô˷½·¨½øÐÐÎïÀí±¸·Ý¹ý³Ì£¬²»½ö±¸·ÝÁËÊý¾Ý¿âµÄÊý¾ÝÎļþ£¬Ò²Í¬Ê±¼Ç¼ÁËÊý¾Ý¿âµÄһЩÖØÒªÐÅÏ¢£¨µÚ2²½µÄdatabase.parmÎļþÖУ©£¬Õâ¶ÔÓÚÒÔºó»Ö¸´Êý¾ÝÊǷdz£ÖØÒªµÄ¡£×îºóÒªÌáÐѶÁÕß×¢ÒâµÄÊÇ£¬±¾ÎÄÌṩµÄ·½·¨ÒªÇóÓÐ×ã¹»´óµÄÊ£Óà´ÅÅ̿ռ䣨¾¡¹Ü×îºóÖ»±£ÁôÁ˱¸·ÝÎļþµÄѹËõÎļþ£©£¬Õâ¸öȱº³Áô¸ø¶ÁÕßÈ¥ÃÖ²¹¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 14 ÌõÆÀÂÛ

  1. komji ÓÚ 2016-04-19 15:29:39·¢±í:

    ѧϰһÏÂ

  2. davemac ÓÚ 2012-01-19 15:11:09·¢±í:

    Ö§³Ö

  3. ¹ùÊÀÕ¹ ÓÚ 2011-11-30 10:30:27·¢±í:

    ºÃ£¬Ö§³Ö£¬¶¥Ò»Ï°¡

  4. pata2 ÓÚ 2011-11-27 15:10:30·¢±í:

    ѧϰÁË ËäÈ»¿´²»¶® ¹þ¹þ

  5. mylove_hu ÓÚ 2011-11-22 00:31:24·¢±í:

    лл

  6. ma_li1991 ÓÚ 2011-10-16 18:31:59·¢±í:

    ¶¥Ò»¸ö

  7. http2010 ÓÚ 2011-10-16 01:35:20·¢±í:

    okokookokk

  8. chaipeng ÓÚ 2011-08-18 12:30:31·¢±í:

    Ö§³Ö

  9. sunshine007 ÓÚ 2011-08-11 11:43:22·¢±í:

    À´Ñ§Ï°ÏÂÎïÀí±¸·Ý·½Ê½¡£

  10. dongyichen ÓÚ 2011-08-09 22:26:45·¢±í:

    ѧϰÁË~

  11. SOtsu ÓÚ 2005-11-26 13:56:35·¢±í:

    Ö§³Ö

  12. Myiozzdoc ÓÚ 2005-10-18 00:38:03·¢±í:

    Ö§³Ö

  13. linux_ ÓÚ 2005-08-31 09:41:45·¢±í:

    ¶¥

  14. zz123 ÓÚ 2005-07-13 00:10:15·¢±í:

    ²»´í£¬Ö§³Ö