温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Oracle RMAN 备份到AWS 云

发布时间:2020-02-14 11:09:43 来源:网络 阅读:2084 作者:raygtr 栏目:关系型数据库

    首次尝试将oracle数据库备份到AWS 云,以前一般都是备份到磁带库或者磁盘,现在有了云就更方便了。这里主要是使用AWS 的S3存储作为SBT设备进行备份。至于什么是AWS,什么是S3,麻烦大家参考:http://www.amazonaws.cn/products/  具体操作步骤如下:

先决条件: 你要有一个AWS accunt(AWS access key ID 与 AWS secret key),你还需要有ORACLE的OTN账号与密码

    1、安装Centos 6.6 64位操作系统(具体过程略)

    2、 安装JAVA 1.8 JDK (具体过程略)

    3、 安装 Oracle 11G数据库 (具体过程略)

    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

当你看见类似上面的输出,则下载的osbws_install是正确的。

    6、编辑一个脚本文件叫:osbws.sh,然后输入如下内容:

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账号密码

    7、输入下面的命令:

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

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

[root@localhost ~]# ntpdate stdtime.gov.hk   #切换root用户进行ntp网络时间同步,不同步会报错

    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驱动已经安装成功。



    现在测试一下表空间备份与还原的操作,我先创建一个表空间以及一个测试用户,并在该用户下创建测试表。然后通过OSB备份到AWS上面.具体过程如下:

A、创建表空间:

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、创建用户

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

现在你可以尝试在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、现在通过RMAN去恢复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问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI