天天看点

Oracle RMAN-catalog database

Oracle RMAN-catalog database

以catalog database的方式代替control file,两个的作用都是相同的,都是保存备份信息的。图片上面的rman相当于一个工具,连接到target database,将target database里面需要备份的东西备份到硬盘或者磁带上面,在备份的时候会将备份产生的目录放到catalog database里面或者control file里面。

Catalog目录Oracle建议不要创建到target database上面,因为target database出现问题,恢复的时候找不到要恢复的目录,这样是不行的。也就是说catalog最好放在另外一台机器上。如出现故障,通过磁盘上面备份和存放在catalog database里面的信息进行恢复。

Oracle RMAN-catalog database

创建一个tablespace是为了存储备份时候产生的信息,使用catalog模式不再将信息存储到control file里面,将来存储到rman里面的表空间里面。

SQL> create tablespace rman_ts datafile '/u01/app/oraclermants.dbf' size 30m;

Tablespace created.

SQL> create user rman identified by rman default tablespace rman_ts quota unlimited on rman_ts;

User created.

SQL> grant recovery_catalog_owner to rman;

Grant succeeded.

SQL> grant connect to rman;

Grant succeeded.

这里不需要授予resource权限给rman用户。

SQL> select * from dba_sys_privs where grantee='CONNECT';

GRANTEE        PRIVILEGE ADM

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

CONNECT        CREATE SESSION NO

如果授予connect权限,其实授予的是create session权限。

SQL> select * from dba_sys_privs where grantee='RESOURCE';

GRANTEE        PRIVILEGE ADM

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

RESOURCE        CREATE TRIGGER NO

RESOURCE        CREATE SEQUENCE NO

RESOURCE        CREATE TYPE NO

RESOURCE        CREATE PROCEDURE NO

RESOURCE        CREATE CLUSTER NO

RESOURCE        CREATE OPERATOR NO

RESOURCE        CREATE INDEXTYPE NO

RESOURCE        CREATE TABLE NO

select * from dba_sys_privs where grantee='recovery_catalog_owner';

[[email protected] ~]$ rman catalog rman/rman

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Dec 15 20:18:52 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to recovery catalog database

下面创建一个恢复目录,指定表空间。(会在之前创建的表空间文件上面将catalog创建起来)

RMAN> create catalog tablespace rman_ts;

recovery catalog created

RMAN> register database;

database registered in recovery catalog

starting full resync of recovery catalog

full resync complete

总结:首先创建tablespace,这个tablespace和普通的tablespace是一样的,是没有任何区别的。之后是创建一个用户,指明密码和表空间并且赋予权限,之后就是使用之前的用户登入rman创建恢复目录。最后连接要备份

先去连接target database(要备份的数据库)之后再去连接catalog database(存放备份信息的)。

[orac[email protected] ~]$ rman target sys/[email protected]_RMAN catalog rman/rman((这里rman连接的远程的数据库)注意:一定要使用sys用户去连接,否则会提示ORA-01017: )

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Dec 15 21:42:35 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORADB (DBID=2714488060)

connected to recovery catalog database

此时rman一端连接target database,另外一端连接 catalog database。备份的方式和非catalog备份的方式是一样的,RMAN> backup database;只不过备份的信息不是放在control file里面,是放在catalog database里面了。

rman target sys/[email protected]_RMAN catalog rman/rman catalog模式备份

rman target / 非catalog模式