溫馨提示×

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

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

Oracle RMAN 備份到AWS 云

發(fā)布時(shí)間:2020-02-14 11:09:43 來源:網(wǎng)絡(luò) 閱讀:2107 作者:raygtr 欄目:關(guān)系型數(shù)據(jù)庫

    首次嘗試將oracle數(shù)據(jù)庫備份到AWS 云,以前一般都是備份到磁帶庫或者磁盤,現(xiàn)在有了云就更方便了。這里主要是使用AWS 的S3存儲(chǔ)作為SBT設(shè)備進(jìn)行備份。至于什么是AWS,什么是S3,麻煩大家參考:http://www.amazonaws.cn/products/  具體操作步驟如下:

先決條件: 你要有一個(gè)AWS accunt(AWS access key ID 與 AWS secret key),你還需要有ORACLE的OTN賬號(hào)與密碼

    1、安裝Centos 6.6 64位操作系統(tǒng)(具體過程略)

    2、 安裝JAVA 1.8 JDK (具體過程略)

    3、 安裝 Oracle 11G數(shù)據(jù)庫 (具體過程略)

    4、下載OSB模塊 ,可以到http://www.oracle.com/technetwork/database/database-technologies/secure-backup/secure-backup-s3-484709.html 查找到

    5、 解壓縮osbws_installer.zip

[oracle@localhost ~]$ unzip osbws_installer.zip

. [oracle@localhost ~]$ java -jar osbws_install.jar

Oracle Secure Backup Web Service InstallTool, build 2015-06-22

No arguments supplied

Usage: java -jar osbws_install.jar

         -AWSID:        AWS Access Key ID

         -AWSKey:       AWS Secret Access Key

         -otnUser:      OTN Username

         -walletDir:    Directory to store wallet

         -configFile:   File name of config file

         -libDir:       Directory to store library

         -libPlatform:  Platform of library to download

         -location:     Location to store backups

         -proxyHost:    HTTP proxy host

         -proxyPort:    HTTP proxy port

         -proxyID:      HTTP proxy userid, if needed

         -proxyPass:    HTTP proxy password, if needed

         -newLogBucket:Force creation of new log bucket

         -reRegister:   Force user registration

當(dāng)你看見類似上面的輸出,則下載的osbws_install是正確的。

    6、編輯一個(gè)腳本文件叫:osbws.sh,然后輸入如下內(nèi)容:

java -jar osbws_install.jar -AWSID XXXXXXXXX  \

-AWSKey //XXXXXXXXX \

-otnUser XXXX@ABC.COM  \

-otnPass xxxx \

-walletDir$ORACLE_HOME/dbs/osbws_wallet  \

-libDir $ORACLE_HOME/lib/


解釋:-AWSID 是AWS的 access key ID 例如:ABCDK234DDK39JDL

-AWSKey 是該acess key ID 的secrect key

-otnUser 與 -otnPass是你的oracle賬號(hào)密碼

    7、輸入下面的命令:

[oracle@localhost ~]$ mkdir $ORACLE_HOME/dbs/osbws_wallet

[oracle@localhost ~]$ chmod +x osbws.sh

[root@localhost ~]# ntpdate stdtime.gov.hk   #切換root用戶進(jìn)行ntp網(wǎng)絡(luò)時(shí)間同步,不同步會(huì)報(bào)錯(cuò)

    8、則行osbws.sh

[oracle@localhost ~]$ ./osbws.sh
Oracle Secure Backup Web Service Install Tool, build 2015-06-22
AWS credentials are valid.
Re-creating logbucket
Created new log bucket.
Registration ID: 0a43c1d0-2e98-43e2-aca6-e4b532b408b4
S3 Logging Bucket: oracle-log-test-abcx-1
Validating log bucket location ...
Validating license file ...
Oracle Secure Backup Web Service wallet created in directory /usr/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/osbws_wallet.
Oracle Secure Backup Web Service initialization file /usr/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/osbwsorcl.ora created.
Downloading Oracle Secure Backup Web Service Software Library from file osbws_linux64.zip.
Downloaded 27151475 bytes in 2062 seconds. Transfer rate was 13167 bytes/second.
Download complete.


查看$ORACLE_HOME/lib目錄

ls $ORACLE_HOME/lib/*osb*

輸出如:

/usr/oracle/app/oracle/product/11.2.0/dbhome_1/lib/libosbws11.so  /usr/oracle/app/oracle/product/11.2.0/dbhome_1/lib/libosbws.so

則AWS驅(qū)動(dòng)已經(jīng)安裝成功。



    現(xiàn)在測(cè)試一下表空間備份與還原的操作,我先創(chuàng)建一個(gè)表空間以及一個(gè)測(cè)試用戶,并在該用戶下創(chuàng)建測(cè)試表。然后通過OSB備份到AWS上面.具體過程如下:

A、創(chuàng)建表空間:

SQL> create tablespace up2s3
  2  logging
  3  datafile '/usr/oracle/app/oracle/oradata/orcl/up2s3_01.dbf' SIZE 5M
  4  autoextend on;

Tablespace created.

2、創(chuàng)建用戶

SQL> create user tests3 identified by test;
User created.

SQL>grant connect,resource to tests3;

Grant succeeded.

SQL> alter user tests3 default tablespace up2s3 ;

User altered.
SQL> conn tests3/test;
Connected.

SQL> create table test(id varchar(20));

Table created.

SQL> insert into test(id) values('abc');

1 row created.

SQL> select * from test;

ID
--------------------
abc

B、利用RMAN把up2s3表空間備份到云端,在rman輸入:

RMAN> run {
2> allocate channel dev1 type
3> sbt parms='SBT_LIBRARY=/usr/oracle/app/oracle/product/11.2.0/dbhome_1/lib/libosbws11.so,
4> SBT_PARMS=(OSB_WS_PFILE=/usr/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/osbwsorcl.ora)';
5> backup tablespace up2s3;
6> }

輸出:

allocated channel: dev1
channel dev1: SID=32 device type=SBT_TAPE
channel dev1: Oracle Secure Backup Web Services Library

Starting backup at 21-JUL-15
channel dev1: starting full datafile backup set
channel dev1: specifying datafile(s) in backup set
input datafile file number=00005 name=/usr/oracle/app/oracle/oradata/orcl/up2s3_01.dbf
channel dev1: starting piece 1 at 21-JUL-15
channel dev1: finished piece 1 at 21-JUL-15
piece handle=01qck3eb_1_1 tag=TAG20150721T155035 comment=API Version 2.0,MMS Version 2.0.0.0
channel dev1: backup set complete, elapsed time: 00:00:25
Finished backup at 21-JUL-15
released channel: dev1

現(xiàn)在你可以嘗試在rman使用list backupset 看到你剛剛的備份。

C、刪除up2s3表空間,模擬表空間損毀。

SQL> alter tablespace up2s3 offline;

Tablespace altered.

[oracle@localhost ~]$ su -
Password:

[root@localhost ~]# mv /usr/oracle/app/oracle/oradata/orcl/up2s3_01.dbf /root/

SQL> alter tablespace up2s3 online;
alter tablespace up2s3 online
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/usr/oracle/app/oracle/oradata/orcl/up2s3_01.dbf'

D、現(xiàn)在通過RMAN去恢復(fù)up2s3表空間

RMAN> run {
2> allocate channel dev1 type
3> sbt parms='SBT_LIBRARY=/usr/oracle/app/oracle/product/11.2.0/dbhome_1/lib/libosbws11.so,
4> SBT_PARMS=(OSB_WS_PFILE=/usr/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/osbwsorcl.ora)';
5> restore tablespace up2s3;
6> recover tablespace up2s3;
7> }

SQL> alter tablespace up2s3 online;


Tablespace altered.

SQL> conn tests3/test
Connected.
SQL> select * from test;

ID
--------------------
abc


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

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

AI