溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

LINUX下ORACLE增量備份的步驟是什么

發(fā)布時(shí)間:2021-11-04 16:58:07 來源:億速云 閱讀:169 作者:柒染 欄目:建站服務(wù)器

這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)碛嘘P(guān)LINUX下ORACLE增量備份的步驟是什么,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

操作步驟:

 

1     查看操作系統(tǒng)版本

[oracle@localhost ~]$ cat /proc/version

Linux version 2.6.18-164.el5 (mockbuild@x86-003.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Tue Aug 18 15:51:48 EDT 2009

 

2     查看數(shù)據(jù)庫版本

 

SQL>  select * from v$version;

BANNER

----------------------------------------------------------------

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit

PL/SQL Release 10.2.0.1.0 - Production

CORE    10.2.0.1.0      Production

TNS for Linux: Version 10.2.0.1.0 - Production

NLSRTL Version 10.2.0.1.0 - Production

 

3     查看數(shù)據(jù)庫的名字

 

SQL> show parameter db_name;

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_name                              string      NACEC

 

4     查看歸檔狀態(tài)

 

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     42

Next log sequence to archive   44

Current log sequence           44

 

5     設(shè)置歸檔日志的格式

 

SQL>alter system set log_archive_format='ARC%s%t%r.log' scope=spfile;

 

6     設(shè)置歸檔日志的存放路徑

 

SQL>alter system set db_recovery_file_dest_size=2G

SQL>alter system set db_recovery_file_dest=’/dat/DBSoftware/oracle/flash_recovery_area’;

SQL>alter system set log_archive_dest_1=’location=/home/FRA’

SQL>alter system set log_archive_dest_10=’LOCATION=USE_DB_RECOVERY_FILE_DEST’;

SQL>shutdown immediate

SQL>startup

SQL>alter system switch logfile;

 

7     啟動(dòng)控制文件的自動(dòng)備份

 

RMAN> configure controlfile autobackup on;

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored

RMAN> show controlfile autobackup;

RMAN configuration parameters are:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

 

8     查看是否用spfile參數(shù)文件

 

SQL> show parameter spfile

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string

VALUE的值為空,數(shù)據(jù)庫是用pfile文件啟動(dòng)的,如果有值,則為spfile啟動(dòng)

創(chuàng)建spfile參數(shù)文件

SQL> create spfile from pfile;

File created.

會(huì)在$oracle_home/dbs/下生成spfileSID.ora

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area  268435456 bytes

Fixed Size                  1218868 bytes

Variable Size              88082124 bytes

Database Buffers          171966464 bytes

Redo Buffers                7168000 bytes

Database mounted.

Database opened.

SQL> show parameter spfile;

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string      /dat/DBSoftware/oracle/product/10.2.0/db_1/dbs/spfilenacec.ora

 

9     使用rman的冗余策略,默認(rèn)為7

 

RMAN> configure retention policy to recovery window of 15 days;

 

10    啟動(dòng)塊更改跟蹤文件

 

SQL>alter database enable block change tracking using file '/home/rob10gr2_block_change.fil';  

 

11    /home/NACEC/BackupDatabase/下創(chuàng)建backuplevel0.rcvbackuplevel1.rcv腳本

 

backuplevel0.rcv內(nèi)容:

#   script.:bakuplevel0.rcv

#   creater:liu shiming

#   date:2010/6/28

#   desc:backup level0 database datafile in archive with rman

# connect database

#!/bin/bash

export ORACLE_BASE=/home/DBSoftware/oracle

export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1

export ORACLE_SID=NACEC

export PATH=/home/DBSoftware/oracle/product/10.2.0/db_1/bin:$PATH

rman target/ << EOF_RMAN

run{

allocate channel c1 type disk;

backup incremental level 0 tag 'db0' format '/home/liusm/BackupDatabase/rmanbackup/db0_%d_%T_%s' database include current controlfile;

sql'alter system archive log current';

backup filesperset 3 format '/home/liusm/BackupDatabase/rmanbackup/arch0_%d_%T_%s' archivelog all delete input;

release channel c1;

}

# end

 

backuplevel1.rcv內(nèi)容:

#   script.:bakuplevel1.rcv

#   creater:liu shiming

#   date:2010/6/27

#   desc:backup level1 database datafile in archive with rman

# connect database

#!/bin/bash

export ORACLE_BASE=/home/DBSoftware/oracle

export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1

export ORACLE_SID=NACEC

export PATH=/home/DBSoftware/oracle/product/10.2.0/db_1/bin:$PATH

rman target/ << EOF_RMAN

run{

allocate channel c1 type disk;

backup incremental level 1 tag 'db1' format '/home/liusm/BackupDatabase/rmanbackup/db1_%d_%T_%s' database include current controlfile;

sql'alter system archive log current';

backup filesperset 3 format '/home/liusm/BackupDatabase/rmanbackup/arch2_%d_%T_%s' archivelog all delete input;

release channel c1;

}

# end

 

給這兩個(gè)腳本授予執(zhí)行的權(quán)限:

 

[oracle@NACEC BackupDatabase]$ chmod +x  *.rcv

(注意:要試運(yùn)行腳本:./backuplevel1.rcv)

 

12   crontab指定執(zhí)行時(shí)間

 

[oracle@NACEC BackupDatabase]$ crontab -e

crontab: installing new crontab

[oracle@NACEC BackupDatabase]$ crontab -l

0 1 * * 0  /home/NACEC/BackupDatabase/backuplevel0.rcv

0 1 * * 3  /home/NACEC/BackupDatabase/backuplevel0.rcv

0 1 * * 1-2  /home/NACEC/BackupDatabase/backuplevel1.rcv

0 1 * * 4-6  /home/NACEC/BackupDatabase/backuplevel1.rcv

周日和周三凌晨100執(zhí)行0級(jí)備份,周一、二、四、五、六凌晨100執(zhí)行1級(jí)備份

內(nèi)容:

0 1 * * 0  /home/NACEC/BackupDatabase/backuplevel0.rcv

0 1 * * 3  /home/NACEC/BackupDatabase/backuplevel0.rcv

0 1 * * 1-2  /home/NACEC/BackupDatabase/backuplevel1.rcv

0 1 * * 4-6  /home/NACEC/BackupDatabase/backuplevel1.rcv

 

13   建立基于數(shù)據(jù)庫的自動(dòng)備份,使用JOB完成

begin

dbms_scheduler.create_job(

job_name=>'nacec_job0',

job_type=>'executable',

job_action=>'/dat/DBData/oradata/scripts/backuplevel0.sh',

repeat_interval=>'freq=weekly;byday=WED,SUN;byhour=01;byminute=00');

end;

/

exec dbms_scheduler.enable('nacec_job0');

 

begin

dbms_scheduler.create_job(

job_name=>'job1_nacec',

job_type=>'executable',

job_action=>'/dat/DBData/oradata/scripts/backuplevel1.sh',

repeat_interval=>'freq=weekly;byday=MON,TUE,THU,FRI,SAT;byhour=01;byminute=00');

end;

/

exec dbms_scheduler.enable('job1_nacec');

 

上述就是小編為大家分享的LINUX下ORACLE增量備份的步驟是什么了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI