CONFIGURE CONTROLFILE AUTOBACKUP ON
备份集准备
backup database format '/home/databak/whole_%d_%U';
backup spfile format '/home/databak/spfile_%d_%U';
切日志
alter system switch logfile;
backup archivelog all format '/home/databak/arch_%d_%U' delete input;
切日志
alter system switch logfile;
backup current controlfile format='/home/databak/ctl_%U_%T';
操作系统命令:传备份集
[oracle@oracle1 databak]$ scp whole_G_XSHIS_07rgqf2h_1_1* arch_G_XSHIS_09rgqf89_1_1* ctl_0brgqf9j_1_1_20160926* 172.16.28.25:/home/databak/
oracle@172.16.28.25's password:
whole_G_XSHIS_07rgqf2h_1_1 100% 3417MB 113.9MB/s 00:30
arch_G_XSHIS_09rgqf89_1_1 100% 14MB 13.9MB/s 00:00
ctl_0brgqf9j_1_1_20160926 100% 18MB 18.4MB/s 00:00
[oracle@oracle1 databak]$
还少了参数文件和口令文件
参数文件全备份集里面有包含
口令文件可以通过命令创建
恢复参数文件
rman target /
RMAN> startup nomount;
RMAN> restore spfile from '/home/databak/spfile_G_XSHIS_0drgqgn8_1_1';
Starting restore at 27-SEP-16
using channel ORA_DISK_1
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /home/databak/spfile_G_XSHIS_0drgqgn8_1_1
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 27-SEP-16
RMAN>
RMAN> shutdown immediate
处理目录
进行到sqlplus工具
SQL> create pfile from spfile;
修改参数文件,并根据参数文件中的参数创建相应的目录
[oracle@orcl dbs]$ cat initgxshis.ora
gxshis2.__data_transfer_cache_size=0
gxshis1.__data_transfer_cache_size=0
gxshis2.__db_cache_size=29259464704
gxshis1.__db_cache_size=28319940608
gxshis2.__java_pool_size=939524096
gxshis1.__java_pool_size=939524096
gxshis2.__large_pool_size=3087007744
gxshis1.__large_pool_size=3087007744
gxshis1.__oracle_base='/oracle/app/oracle'#ORACLE_BASE set from environment
gxshis2.__oracle_base='/oracle/app/oracle'#ORACLE_BASE set from environment
gxshis2.__pga_aggregate_target=13555990528
gxshis1.__pga_aggregate_target=13555990528
gxshis2.__sga_target=40667971584
gxshis1.__sga_target=40667971584
gxshis2.__shared_io_pool_size=402653184
gxshis1.__shared_io_pool_size=536870912
gxshis2.__shared_pool_size=6845104128
gxshis1.__shared_pool_size=7381975040
gxshis2.__streams_pool_size=0
gxshis1.__streams_pool_size=268435456
*.audit_file_dest=' /home/oracle/app/oracle/admin/gxshis/adump'
*.audit_trail='db'
*.cluster_database= false#true/false
*.compatible='12.1.0.2.0'
*.control_files=' /home/oracle/app/oracle/oradata/gxshis/current.261.922142579',' /home/oracle/app/oracle/oradata/gxshis/current.256.922142579'
*.db_block_size=8192
*.db_create_file_dest=' /home/oracle/app/oracle/oradata/gxshis'
*.db_domain=''
*.db_name='g_xshis'
*.db_recovery_file_dest=' /home/oracle/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=100g
*.diagnostic_dest=' /home/oracle/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=gxshisXDB)'
gxshis1.instance_number=1
gxshis2.instance_number=2
g_xshis1.instance_number=1
g_xshis2.instance_number=2
*.open_cursors=300
*.pga_aggregate_target=12900m
*.processes=1100
*.remote_login_passwordfile='exclusive'
*.sec_case_sensitive_logon=FALSE
*.sessions=1000
*.sga_target=38700m
gxshis2.thread=2
gxshis1.thread=1
gxshis1.undo_tablespace='UNDOTBS1'
gxshis2.undo_tablespace='UNDOTBS2'
[oracle@orcl dbs]$
SQL> startup nomount
恢复控制文件
rman target /
RMAN> restore controlfile from '/home/databak/ctl_0brgqf9j_1_1_20160926';
Starting restore at 27-SEP-16
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/home/oracle/app/oracle/oradata/gxshis/current.261.922142579
output file name=/home/oracle/app/oracle/oradata/gxshis/current.256.922142579
Finished restore at 27-SEP-16
RMAN>
启动到mount状态,恢复数据库
alter database mount;
注意:恢复参数文件和控制文件通过手工指定备份集恢复出来。所以这个备份集在哪个目录都无所谓。但是恢复数据文件是不能用from指定备份集。restore database;恢复数据文件的前提是备份集所在的目录必须跟控制文件中记录的目录一致。
当目录不一致的时候处理办法得新catalog;
oracle]$ mv whole_ORCL_01qsbu7l_1_1 /home/oracle
RMAN> restore database;
报错,找不到备份集
rman>catalog start with '/home/oracle';
再恢复数据库,正常。
RMAN> restore database;
Starting restore at 27-SEP-16
Starting implicit crosscheck backup at 27-SEP-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=423 device type=DISK
Crosschecked 4 objects
Finished implicit crosscheck backup at 27-SEP-16
Starting implicit crosscheck copy at 27-SEP-16
using channel ORA_DISK_1
Finished implicit crosscheck copy at 27-SEP-16
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to +DATA/G_XSHIS/DATAFILE/system.258.922142465
channel ORA_DISK_1: restoring datafile 00002 to +DATA/g_xshis/tablespaces/tsp_acct.dbf
channel ORA_DISK_1: restoring datafile 00003 to +DATA/G_XSHIS/DATAFILE/sysaux.257.922142419
channel ORA_DISK_1: restoring datafile 00004 to +DATA/G_XSHIS/DATAFILE/undotbs1.260.922142521
channel ORA_DISK_1: restoring datafile 00005 to +DATA/G_XSHIS/DATAFILE/undotbs2.265.922142785
channel ORA_DISK_1: restoring datafile 00006 to +DATA/G_XSHIS/DATAFILE/users.259.922142519
channel ORA_DISK_1: restoring datafile 00007 to +DATA/g_xshis/tablespaces/tsp_bldbank.dbf
channel ORA_DISK_1: restoring datafile 00008 to +DATA/g_xshis/tablespaces/tsp_clinpath.dbf
channel ORA_DISK_1: restoring datafile 00009 to +DATA/g_xshis/tablespaces/tsp_comm.dbf
channel ORA_DISK_1: restoring datafile 00010 to +DATA/g_xshis/tablespaces/tsp_cpr.dbf
channel ORA_DISK_1: restoring datafile 00011 to +DATA/g_xshis/tablespaces/tsp_healthcare.dbf
channel ORA_DISK_1: restoring datafile 00012 to +DATA/g_xshis/tablespaces/tsp_hisuser.dbf
channel ORA_DISK_1: restoring datafile 00013 to +DATA/g_xshis/tablespaces/tsp_infect.dbf
channel ORA_DISK_1: restoring datafile 00014 to +DATA/g_xshis/tablespaces/tsp_inpadm.dbf
channel ORA_DISK_1: restoring datafile 00015 to +DATA/g_xshis/tablespaces/tsp_inpbill.dbf
channel ORA_DISK_1: restoring datafile 00016 to +DATA/g_xshis/tablespaces/tsp_inquire.dbf
channel ORA_DISK_1: restoring datafile 00017 to +DATA/g_xshis/tablespaces/tsp_insurance.dbf
channel ORA_DISK_1: restoring datafile 00018 to +DATA/g_xshis/tablespaces/tsp_interface.dbf
channel ORA_DISK_1: restoring datafile 00019 to +DATA/g_xshis/tablespaces/tsp_lab.dbf
channel ORA_DISK_1: restoring datafile 00020 to +DATA/g_xshis/tablespaces/tsp_medadm.dbf
channel ORA_DISK_1: restoring datafile 00021 to +DATA/g_xshis/tablespaces/tsp_medrec.dbf
channel ORA_DISK_1: restoring datafile 00022 to +DATA/g_xshis/tablespaces/tsp_mobile.dbf
channel ORA_DISK_1: restoring datafile 00023 to +DATA/g_xshis/tablespaces/tsp_nursing.dbf
channel ORA_DISK_1: restoring datafile 00024 to +DATA/g_xshis/tablespaces/tsp_ordadm.dbf
channel ORA_DISK_1: restoring datafile 00025 to +DATA/g_xshis/tablespaces/tsp_outpadm.dbf
channel ORA_DISK_1: restoring datafile 00026 to +DATA/g_xshis/tablespaces/tsp_outpbill.dbf
channel ORA_DISK_1: restoring datafile 00027 to +DATA/g_xshis/tablespaces/tsp_outpdoct.dbf
channel ORA_DISK_1: restoring datafile 00028 to +DATA/g_xshis/tablespaces/tsp_pharmacy.dbf
channel ORA_DISK_1: restoring datafile 00029 to +DATA/g_xshis/tablespaces/tsp_phyexam.dbf
channel ORA_DISK_1: restoring datafile 00030 to +DATA/g_xshis/tablespaces/tsp_report.dbf
channel ORA_DISK_1: restoring datafile 00031 to +DATA/g_xshis/tablespaces/tsp_surgery.dbf
channel ORA_DISK_1: restoring datafile 00032 to +DATA/g_xshis/tablespaces/tsp_tj.dbf
channel ORA_DISK_1: restoring datafile 00033 to +DATA/g_xshis/tablespaces/tsp_tjhisrpt.dbf
channel ORA_DISK_1: restoring datafile 00034 to +DATA/g_xshis/tablespaces/tsp_wsyy.dbf
channel ORA_DISK_1: restoring datafile 00035 to +DATA/g_xshis/tablespaces/tsp_exam.dbf
channel ORA_DISK_1: restoring datafile 00036 to +DATA/g_xshis/tablespaces/tsp_equipment.dbf
channel ORA_DISK_1: restoring datafile 00037 to +DATA/g_xshis/tablespaces/tsp_econstat.dbf
备份集准备
backup database format '/home/databak/whole_%d_%U';
backup spfile format '/home/databak/spfile_%d_%U';
切日志
alter system switch logfile;
backup archivelog all format '/home/databak/arch_%d_%U' delete input;
切日志
alter system switch logfile;
backup current controlfile format='/home/databak/ctl_%U_%T';
操作系统命令:传备份集
[oracle@oracle1 databak]$ scp whole_G_XSHIS_07rgqf2h_1_1* arch_G_XSHIS_09rgqf89_1_1* ctl_0brgqf9j_1_1_20160926* 172.16.28.25:/home/databak/
oracle@172.16.28.25's password:
whole_G_XSHIS_07rgqf2h_1_1 100% 3417MB 113.9MB/s 00:30
arch_G_XSHIS_09rgqf89_1_1 100% 14MB 13.9MB/s 00:00
ctl_0brgqf9j_1_1_20160926 100% 18MB 18.4MB/s 00:00
[oracle@oracle1 databak]$
还少了参数文件和口令文件
参数文件全备份集里面有包含
口令文件可以通过命令创建
克隆库操作
orapwd file=/home/oracle/app/oracle/product/12.1.0/db_1/dbs/orapwgxshis password=oracle恢复参数文件
rman target /
RMAN> startup nomount;
RMAN> restore spfile from '/home/databak/spfile_G_XSHIS_0drgqgn8_1_1';
Starting restore at 27-SEP-16
using channel ORA_DISK_1
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /home/databak/spfile_G_XSHIS_0drgqgn8_1_1
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 27-SEP-16
RMAN>
RMAN> shutdown immediate
处理目录
进行到sqlplus工具
SQL> create pfile from spfile;
修改参数文件,并根据参数文件中的参数创建相应的目录
[oracle@orcl dbs]$ cat initgxshis.ora
gxshis2.__data_transfer_cache_size=0
gxshis1.__data_transfer_cache_size=0
gxshis2.__db_cache_size=29259464704
gxshis1.__db_cache_size=28319940608
gxshis2.__java_pool_size=939524096
gxshis1.__java_pool_size=939524096
gxshis2.__large_pool_size=3087007744
gxshis1.__large_pool_size=3087007744
gxshis1.__oracle_base='/oracle/app/oracle'#ORACLE_BASE set from environment
gxshis2.__oracle_base='/oracle/app/oracle'#ORACLE_BASE set from environment
gxshis2.__pga_aggregate_target=13555990528
gxshis1.__pga_aggregate_target=13555990528
gxshis2.__sga_target=40667971584
gxshis1.__sga_target=40667971584
gxshis2.__shared_io_pool_size=402653184
gxshis1.__shared_io_pool_size=536870912
gxshis2.__shared_pool_size=6845104128
gxshis1.__shared_pool_size=7381975040
gxshis2.__streams_pool_size=0
gxshis1.__streams_pool_size=268435456
*.audit_file_dest=' /home/oracle/app/oracle/admin/gxshis/adump'
*.audit_trail='db'
*.cluster_database= false#true/false
*.compatible='12.1.0.2.0'
*.control_files=' /home/oracle/app/oracle/oradata/gxshis/current.261.922142579',' /home/oracle/app/oracle/oradata/gxshis/current.256.922142579'
*.db_block_size=8192
*.db_create_file_dest=' /home/oracle/app/oracle/oradata/gxshis'
*.db_domain=''
*.db_name='g_xshis'
*.db_recovery_file_dest=' /home/oracle/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=100g
*.diagnostic_dest=' /home/oracle/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=gxshisXDB)'
gxshis1.instance_number=1
gxshis2.instance_number=2
g_xshis1.instance_number=1
g_xshis2.instance_number=2
*.open_cursors=300
*.pga_aggregate_target=12900m
*.processes=1100
*.remote_login_passwordfile='exclusive'
*.sec_case_sensitive_logon=FALSE
*.sessions=1000
*.sga_target=38700m
gxshis2.thread=2
gxshis1.thread=1
gxshis1.undo_tablespace='UNDOTBS1'
gxshis2.undo_tablespace='UNDOTBS2'
[oracle@orcl dbs]$
SQL> startup nomount
恢复控制文件
rman target /
RMAN> restore controlfile from '/home/databak/ctl_0brgqf9j_1_1_20160926';
Starting restore at 27-SEP-16
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/home/oracle/app/oracle/oradata/gxshis/current.261.922142579
output file name=/home/oracle/app/oracle/oradata/gxshis/current.256.922142579
Finished restore at 27-SEP-16
RMAN>
启动到mount状态,恢复数据库
alter database mount;
注意:恢复参数文件和控制文件通过手工指定备份集恢复出来。所以这个备份集在哪个目录都无所谓。但是恢复数据文件是不能用from指定备份集。restore database;恢复数据文件的前提是备份集所在的目录必须跟控制文件中记录的目录一致。
当目录不一致的时候处理办法得新catalog;
oracle]$ mv whole_ORCL_01qsbu7l_1_1 /home/oracle
RMAN> restore database;
报错,找不到备份集
rman>catalog start with '/home/oracle';
再恢复数据库,正常。
RMAN> restore database;
Starting restore at 27-SEP-16
Starting implicit crosscheck backup at 27-SEP-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=423 device type=DISK
Crosschecked 4 objects
Finished implicit crosscheck backup at 27-SEP-16
Starting implicit crosscheck copy at 27-SEP-16
using channel ORA_DISK_1
Finished implicit crosscheck copy at 27-SEP-16
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to +DATA/G_XSHIS/DATAFILE/system.258.922142465
channel ORA_DISK_1: restoring datafile 00002 to +DATA/g_xshis/tablespaces/tsp_acct.dbf
channel ORA_DISK_1: restoring datafile 00003 to +DATA/G_XSHIS/DATAFILE/sysaux.257.922142419
channel ORA_DISK_1: restoring datafile 00004 to +DATA/G_XSHIS/DATAFILE/undotbs1.260.922142521
channel ORA_DISK_1: restoring datafile 00005 to +DATA/G_XSHIS/DATAFILE/undotbs2.265.922142785
channel ORA_DISK_1: restoring datafile 00006 to +DATA/G_XSHIS/DATAFILE/users.259.922142519
channel ORA_DISK_1: restoring datafile 00007 to +DATA/g_xshis/tablespaces/tsp_bldbank.dbf
channel ORA_DISK_1: restoring datafile 00008 to +DATA/g_xshis/tablespaces/tsp_clinpath.dbf
channel ORA_DISK_1: restoring datafile 00009 to +DATA/g_xshis/tablespaces/tsp_comm.dbf
channel ORA_DISK_1: restoring datafile 00010 to +DATA/g_xshis/tablespaces/tsp_cpr.dbf
channel ORA_DISK_1: restoring datafile 00011 to +DATA/g_xshis/tablespaces/tsp_healthcare.dbf
channel ORA_DISK_1: restoring datafile 00012 to +DATA/g_xshis/tablespaces/tsp_hisuser.dbf
channel ORA_DISK_1: restoring datafile 00013 to +DATA/g_xshis/tablespaces/tsp_infect.dbf
channel ORA_DISK_1: restoring datafile 00014 to +DATA/g_xshis/tablespaces/tsp_inpadm.dbf
channel ORA_DISK_1: restoring datafile 00015 to +DATA/g_xshis/tablespaces/tsp_inpbill.dbf
channel ORA_DISK_1: restoring datafile 00016 to +DATA/g_xshis/tablespaces/tsp_inquire.dbf
channel ORA_DISK_1: restoring datafile 00017 to +DATA/g_xshis/tablespaces/tsp_insurance.dbf
channel ORA_DISK_1: restoring datafile 00018 to +DATA/g_xshis/tablespaces/tsp_interface.dbf
channel ORA_DISK_1: restoring datafile 00019 to +DATA/g_xshis/tablespaces/tsp_lab.dbf
channel ORA_DISK_1: restoring datafile 00020 to +DATA/g_xshis/tablespaces/tsp_medadm.dbf
channel ORA_DISK_1: restoring datafile 00021 to +DATA/g_xshis/tablespaces/tsp_medrec.dbf
channel ORA_DISK_1: restoring datafile 00022 to +DATA/g_xshis/tablespaces/tsp_mobile.dbf
channel ORA_DISK_1: restoring datafile 00023 to +DATA/g_xshis/tablespaces/tsp_nursing.dbf
channel ORA_DISK_1: restoring datafile 00024 to +DATA/g_xshis/tablespaces/tsp_ordadm.dbf
channel ORA_DISK_1: restoring datafile 00025 to +DATA/g_xshis/tablespaces/tsp_outpadm.dbf
channel ORA_DISK_1: restoring datafile 00026 to +DATA/g_xshis/tablespaces/tsp_outpbill.dbf
channel ORA_DISK_1: restoring datafile 00027 to +DATA/g_xshis/tablespaces/tsp_outpdoct.dbf
channel ORA_DISK_1: restoring datafile 00028 to +DATA/g_xshis/tablespaces/tsp_pharmacy.dbf
channel ORA_DISK_1: restoring datafile 00029 to +DATA/g_xshis/tablespaces/tsp_phyexam.dbf
channel ORA_DISK_1: restoring datafile 00030 to +DATA/g_xshis/tablespaces/tsp_report.dbf
channel ORA_DISK_1: restoring datafile 00031 to +DATA/g_xshis/tablespaces/tsp_surgery.dbf
channel ORA_DISK_1: restoring datafile 00032 to +DATA/g_xshis/tablespaces/tsp_tj.dbf
channel ORA_DISK_1: restoring datafile 00033 to +DATA/g_xshis/tablespaces/tsp_tjhisrpt.dbf
channel ORA_DISK_1: restoring datafile 00034 to +DATA/g_xshis/tablespaces/tsp_wsyy.dbf
channel ORA_DISK_1: restoring datafile 00035 to +DATA/g_xshis/tablespaces/tsp_exam.dbf
channel ORA_DISK_1: restoring datafile 00036 to +DATA/g_xshis/tablespaces/tsp_equipment.dbf
channel ORA_DISK_1: restoring datafile 00037 to +DATA/g_xshis/tablespaces/tsp_econstat.dbf