rmancatalog方式备份配制与脚本
----本次实验oracle 11g r2
---在本机中安装有两个数据库,分别为sid=sjjc sid=dndn
---现使用sjjc为catalog库来备份dndn
sys@sjjc> select version from v$instance;
VERSION
-----------------
11.2.0.1.0
sys@dndn> select version from v$instance;
VERSION
-----------------
11.2.0.1.0
1.首先把两个库的listener.ora和tnsnames.ora来配制一下
vim $ORACLE_HOME/network/admin/tnsnames.ora
SJJC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle1.jsu.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sjjc.jsu.com)
)
)
DNDN =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle1.jsu.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dndn.jsu.com)
)
)
vim $ORACLE_HOME/network/admin/listener.ora
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=sjjc.jsu.com)
(SID_NAME=sjjc)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
(PRESPAWN_MAX=20)
(PRESPAWN_LIST=
(PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
)
)
(SID_DESC=
(GLOBAL_DBNAME=dndn.jsu.com)
(SID_NAME=dndn)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
(PRESPAWN_MAX=20)
(PRESPAWN_LIST=
(PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle1.jsu.com)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
现在开启监听来测试一下
[oracle@oracle1 ~]$ lsnrctl start
ok!
[oracle@oracle1 ~]$ tnsping dndn
ok!
[oracle@oracle1 ~]$ tnsping sjjc
ok!
[oracle@oracle1 ~]$ sqlplus sys/runner@sjjc as sysdba
ok!
[oracle@oracle1 ~]$ sqlplus sys/runner@sjjc as sysdba
ok!
这样,网络就配制好了
2.在sjjc中创建rman用户和表空间
sys@sjjc> create tablespace rman_tbs datafile '/u01/app/oracle/oradata/sjjc/rman_tbs01.dbf' size 100m autoextend on;
Tablespace created.
sys@sjjc> create user rman identified by rman default tablespace rman_tbs;
User created.
sys@sjjc> grant recovery_catalog_owner ,resource to rman; --授权
Grant succeeded.
--测试一下
sys@sjjc> conn rman/rman
Connected.
3.配制rman
[oracle@oracle1 ~]$ rman catalog rman/rman@sjjc --用catalog方式连接到rman(连接到恢复目录)
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Dec 9 10:34:21 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to recovery catalog database
RMAN>
RMAN> create catalog tablespace rman_tbs; --创建恢复目录
recovery catalog creat
--现在可以使用sjjc库中的catalog来连备份dndn库
[oracle@oracle1 ~]$ rman target sys/runner@dndn catalog rman/rman@sjjc
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Dec 9 10:42:22 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: DNDN (DBID=2705026088)
connected to recovery catalog database
RMAN>
RMAN> register database; --将目标数据库(dndn)注册到恢复目录
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
---可以sjjc库自己连接
[oracle@oracle1 ~]$ rman target / catalog rman/rman
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Dec 9 17:20:46 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: SJJC (DBID=3775066873)
connected to recovery catalog database
RMAN>
RMAN> register database; --将目标数据库(sjjc)库注册到恢复目录
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
--至此基本配制完成--------------------------
--每次登陆到catalog rman在备份这前要同步一下信息
RMAN> resync catalog;
starting full resync of recovery catalog
full resync complete
或
RMAN> report schema; --这条命令也能做到同步信息的效果,只是它会打印出来很多信息
Report of database schema for database with db_unique_name SJJC
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 690 SYSTEM YES /u01/app/oracle/oradata/sjjc/system01.dbf
2 520 SYSAUX NO /u01/app/oracle/oradata/sjjc/sysaux01.dbf
3 100 UNDOTBS1 YES /u01/app/oracle/oradata/sjjc/undotbs01.dbf
4 5 USERS NO /u01/app/oracle/oradata/sjjc/users01.dbf
5 100 EXAMPLE NO /u01/app/oracle/oradata/sjjc/example01.dbf
6 100 RMAN_TBS NO /u01/app/oracle/oradata/sjjc/rman_tbs01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 29 TEMP 32767 /u01/app/oracle/oradata/sjjc/temp01.dbf
RMAN>
level0
run {
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
allocate channel d1 type disk;
backup incremental level 0 database format '/u01/app/oracle/backup/level0_%T_%d_%s_%p_%u.dbf.bak'
tag='level 0' include current controlfile;
sql'alter system archive log current';
backup archivelog all format '/u01/app/oracle/backup/log_%T_%d_%s_%p_%u.arc.bak' delete all input;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
resync catalog;
level1
run {
allocate channel d1 type disk;
backup incremental level 1 database format '/u01/app/oracle/backup/level1_%T_%d_%s_%p_%u.dbf.bak'
tag='level 1' include current controlfile;
sql 'alter system archive log current';
backup archivelog all format '/u01/app/oracle/backup/log_%T_%d_%s_%p_%u.arc.bak' delete all input;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
resync catalog;
level2
run {
allocate channel d1 type disk;
backup incremental level 2 database format '/u01/app/oracle/backup/level2_%T_%d_%s_%p_%u.dbf.bak'
tag='level 2' include current controlfile;
sql 'alter system archive log current';
backup archivelog all format '/u01/app/oracle/backup/log_%T_%d_%s_%p_%u.arc.bak' delete all input;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
resync catalog;
level2c
run {
allocate channel d1 type disk;
backup incremental level 2 cumulative database format '/u01/app/oracle/backup/level2c_%T_%d_%s_%p_%u.dbf.bak'
tag='level 2' include current controlfile;
sql 'alter system archive log current';
backup archivelog all format '/u01/app/oracle/backup/log_%T_%d_%s_%p_%u.arc.bak' delete all input;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
resync catalog;
(在root下)
crontab -e -u oracle (若在oracle用户下则 crontab -e)
10 10 * * 0 source ~/.bash_profile; rman target sys/runner@dndn catalog rman/rman@sjjc @/u01/app/oracle/backup/script/level0.rman
10 10 * * 1,4 source ~/.bash_profile; rman target sys/runner@dndn catalog rman/rman@sjjc @/u01/app/oracle/backup/script/level2.rman
10 10 * * 2,5,6 source ~/.bash_profile; rman target sys/runner@dndn catalog rman/rman@sjjc @/u01/app/oracle/backup/script/level2c.rman
10 10 * * 3 source ~/.bash_profile; rman target sys/runner@dndn catalog rman/rman@sjjc @/u01/app/oracle/backup/script/level1.rman
- 01-11全球最受赞誉公司揭晓:苹果连续九年第一
- 12-09罗伯特·莫里斯:让黑客真正变黑
- 12-09谁闯入了中国网络?揭秘美国绝密黑客小组TA
- 12-09警示:iOS6 惊现“闪退”BUG
- 12-05亚马逊推出新一代基础模型 任意模态生成大模
- 12-05OpenAI拓展欧洲业务 将在苏黎世设立办公室
- 12-05微软质疑美国联邦贸易委员会泄露信息 督促其
- 12-05联交所取消宝宝树上市地位 宝宝树:不会对公
- 12-04企业微信致歉:文档打开异常已完成修复