参考了: http://blog.itpub.net/29654823/viewspace-1252777/
Oracle 利用RMAN 完成数据迁移
run
{
allocate channel ch1 device type disk format '/opt/oracle/bakdatabase/%U';
allocate channel ch2 device type disk format '/opt/oracle/bakdatabase/%U';
backup as backupset database include current controlfile plus archivelog delete all input;
}
整体流程:对A机的数据库来一个热备,并且是一个全备(备份了数据文件、控制文件、归档日志文件:
backup as backupset database include current controlfile plus archivelog delete all input;),然后通过scp命令把备份传到B机,
之后再把服务器参数文件的备份和redo在线日志从A传给B机,最后再在B库上 restore 和recover。
根据数据库的启动流程:
可以知道最先读取参数文件,所以应该先还原参数文件,
然后会读控制文件,所以你要再修复控制文件,
最后再修复数据文件。
环境信息
CentOS 6.5
Oracle database 12C
源端A机:主机名:centhost2,IP:192.168.1.146,数据库实例orcl
目的端B机:
主机名:centhost3,IP:192.168.1.147,且目的端已经存在一个数据库实例orclrman
具体操作流程:
一:对A库做一个热全备。
-
[laolv@centhost3 admin]$ rman
-
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Dec 6 23:52:04 2016
-
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
-
RMAN> connect target sys/forrest@orcl
-
connected to target database: ORCL (DBID=1429293327)
-
RMAN> connect catalog rman/forrest@orclrman
-
connected to recovery catalog database
-
RMAN> register database;
-
database registered in recovery catalog
-
starting full resync of recovery catalog
-
full resync complete
-
RMAN> resync catalog; --如果目标数据库的表空间和数据文件等发生变化,则会带动目标数据库的控制文件被改写,此时,可以执行如下命令进行恢复目录与目标数据库控制文件同步
-
starting full resync of recovery catalog
-
full resync complete
-
RMAN>
-
RMAN> run
-
2> {
-
3> allocate channel ch1 device type disk format '/opt/oracle/bakdatabase/%U';
-
4> allocate channel ch2 device type disk format '/opt/oracle/bakdatabase/%U';
-
5> backup as backupset database include current controlfile plus archivelog delete all input; --注意没有服务器参数文件
-
6> }
-
-
-
released channel: ORA_DISK_1
-
allocated channel: ch1
-
channel ch1: SID=32 device type=DISK
-
-
allocated channel: ch2
-
channel ch2: SID=266 device type=DISK
-
-
Starting backup at 10-DEC-16
-
current log archived
-
channel ch1: starting archived log backup set
-
channel ch1: specifying archived log(s) in backup set
-
input archived log thread=1 sequence=257 RECID=51 STAMP=930255168
-
channel ch1: starting piece 1 at 10-DEC-16
-
channel ch1: finished piece 1 at 10-DEC-16
-
piece handle=/opt/oracle/bakdatabase/1nrn54a1_1_1( 这个是备份的archive log ) tag=TAG20161210T201249 comment=NONE
-
channel ch1: backup set complete, elapsed time: 00:00:01
-
channel ch1: deleting archived log(s)
-
archived log file name=/opt/oracle/myarchive/1_257_901512594.dbf RECID=51 STAMP=930255168 (备份完archive log后,会删除目的数据库的自己的archive log)
-
Finished backup at 10-DEC-16
-
-
Starting backup at 10-DEC-16
-
channel ch1: starting full datafile backup set
-
channel ch1: specifying datafile(s) in backup set
-
input datafile file number=00003 name=/opt/oracle/oradata/orcl/sysaux01.dbf
-
input datafile file number=00004 name=/opt/oracle/oradata/orcl/undotbs01.dbf
-
channel ch1: starting piece 1 at 10-DEC-16
-
channel ch2: starting full datafile backup set
-
channel ch2: specifying datafile(s) in backup set
-
input datafile file number=00011 name=/opt/oracle/oradata/orcl/pdborcl/example01.dbf
-
input datafile file number=00010 name=/opt/oracle/oradata/orcl/pdborcl/SAMPLE_SCHEMA_users01.dbf
-
channel ch2: starting piece 1 at 10-DEC-16
-
channel ch1: finished piece 1 at 10-DEC-16
-
piece handle=/opt/oracle/bakdatabase/1orn54a4_1_1 tag=TAG20161210T201251 comment=NONE
-
channel ch1: backup set complete, elapsed time: 00:00:45
-
channel ch1: starting full datafile backup set
-
channel ch1: specifying datafile(s) in backup set
-
input datafile file number=00009 name=/opt/oracle/oradata/orcl/pdborcl/sysaux01.dbf
-
input datafile file number=00008 name=/opt/oracle/oradata/orcl/pdborcl/system01.dbf
-
channel ch1: starting piece 1 at 10-DEC-16
-
channel ch2: finished piece 1 at 10-DEC-16
-
piece handle=/opt/oracle/bakdatabase/1prn54a4_1_1 tag=TAG20161210T201251 comment=NONE
-
channel ch2: backup set complete, elapsed time: 00:00:53
-
channel ch2: starting full datafile backup set
-
channel ch2: specifying datafile(s) in backup set
-
input datafile file number=00001 name=/opt/oracle/oradata/orcl/system01.dbf
-
input datafile file number=00006 name=/opt/oracle/oradata/orcl/users01.dbf
-
channel ch2: starting piece 1 at 10-DEC-16
-
channel ch1: finished piece 1 at 10-DEC-16
-
piece handle=/opt/oracle/bakdatabase/1qrn54bi_1_1 tag=TAG20161210T201251 comment=NONE
-
channel ch1: backup set complete, elapsed time: 00:01:23
-
channel ch1: starting full datafile backup set
-
channel ch1: specifying datafile(s) in backup set
-
input datafile file number=00007 name=/opt/oracle/oradata/orcl/pdbseed/sysaux01.dbf
-
channel ch1: starting piece 1 at 10-DEC-16
-
channel ch2: finished piece 1 at 10-DEC-16
-
piece handle=/opt/oracle/bakdatabase/1rrn54bq_1_1 tag=TAG20161210T201251 comment=NONE
-
channel ch2: backup set complete, elapsed time: 00:01:15
-
channel ch2: starting full datafile backup set
-
channel ch2: specifying datafile(s) in backup set
-
input datafile file number=00005 name=/opt/oracle/oradata/orcl/pdbseed/system01.dbf
-
channel ch2: starting piece 1 at 10-DEC-16
-
channel ch1: finished piece 1 at 10-DEC-16
-
piece handle=/opt/oracle/bakdatabase/1srn54e5_1_1 tag=TAG20161210T201251 comment=NONE
-
channel ch1: backup set complete, elapsed time: 00:00:26
-
channel ch1: starting full datafile backup set
-
channel ch1: specifying datafile(s) in backup set
-
channel ch2: finished piece 1 at 10-DEC-16
-
piece handle=/opt/oracle/bakdatabase/1trn54e5_1_1 tag=TAG20161210T201251 comment=NONE
-
channel ch2: backup set complete, elapsed time: 00:00:26
-
including current control file in backup set
-
channel ch1: starting piece 1 at 10-DEC-16
-
channel ch1: finished piece 1 at 10-DEC-16
-
piece handle=/opt/oracle/bakdatabase/1urn54ev_1_1 tag=TAG20161210T201251 comment=NONE
-
channel ch1: backup set complete, elapsed time: 00:00:01
-
Finished backup at 10-DEC-16
-
-
Starting backup at 10-DEC-16
-
current log archived
-
starting full resync of recovery catalog
-
full resync complete
-
channel ch1: starting archived log backup set
-
channel ch1: specifying archived log(s) in backup set
-
input archived log thread=1 sequence=258 RECID=52 STAMP=930255329
-
channel ch1: starting piece 1 at 10-DEC-16
-
channel ch1: finished piece 1 at 10-DEC-16
-
piece handle=/opt/oracle/bakdatabase/1vrn54f4_1_1 (这个是备份的archive log)tag=TAG20161210T201532 comment=NONE
-
channel ch1: backup set complete, elapsed time: 00:00:01
-
channel ch1: deleting archived log(s)
-
archived log file name=/opt/oracle/myarchive/1_258_901512594.dbf RECID=52 STAMP=930255329 (备份完archive log后,会删除目的数据库的自己的archive log)
-
Finished backup at 10-DEC-16
-
-
Starting Control File and SPFILE Autobackup at 10-DEC-16
-
piece handle=/opt/oracle/fast_recovery_area/ORCL/autobackup/2016_12_10/o1_mf_s_930255335_d4qwh7mx_.bkp comment=NONE
-
Finished Control File and SPFILE Autobackup at 10-DEC-16
-
released channel: ch1
-
released channel: ch2
-
-
RMAN>
由以上输出信息可得:
数据文件datafile+控制文件current control file+归档日志文件archive log,是在backup set中的,存放在指定的/opt/oracle/bakdatabase目录下;
归档日志文件备份完后,会删除目的数据库自己的归档日志文件。
手动备份完后,目的数据库会自动备份其自己的Control File和SPFILE。
二:把所做的备份用scp传给B机。
1.
[laolv@centhost3 bakfromcenthost2]$ scp -r laolv@192.168.1.146:/opt/oracle/bakdatabase .
laolv@192.168.1.146's password:
1orn54a4_1_1 100% 770MB 2.4MB/s 05:18
1nrn54a1_1_1 100% 7222KB 7.1MB/s 00:01
1srn54e5_1_1 100% 456MB 12.7MB/s 00:36
1qrn54bi_1_1 100% 672MB 14.6MB/s 00:46
1urn54ev_1_1 100% 17MB 17.2MB/s 00:00
1trn54e5_1_1 100% 205MB 15.8MB/s 00:13
1vrn54f4_1_1 100% 26KB 26.0KB/s 00:00
1rrn54bq_1_1 100% 694MB 21.0MB/s 00:33
1prn54a4_1_1 100% 97MB 32.5MB/s 00:03
2.将正在使用的redo日志拷贝到目标端
查看redo日志的信息:
1) SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC
---------- ---------- ---------- ---------- ---------- ---------- ---
STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME CON_ID
---------------- ------------- --------- ------------ --------- ----------
1 1 259 52428800 512 1 NO
CURRENT 6430035 10-DEC-16 2.8147E+14 0 --GROUP#=1的正在被使用,所以只传它就行(因为别的已经被归档,)
2 1 257 52428800 512 1 YES
INACTIVE 6424841 10-DEC-16 6429930 10-DEC-16 0
3 1 258 52428800 512 1 YES
INACTIVE 6429930 10-DEC-16 6430035 10-DEC-16 0
2) SQL> select * from v$logfile; #查看日志的具体位置
GROUP# STATUS TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------
IS_ CON_ID
--- ----------
3 ONLINE
/opt/oracle/oradata/orcl/redo03.log
NO 0
2 ONLINE
/opt/oracle/oradata/orcl/redo02.log
NO 0
GROUP# STATUS TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------
IS_ CON_ID
--- ----------
1 ONLINE
/opt/oracle/oradata/orcl/redo01.log
NO 0
3)将正在使用的redo日志拷贝到目标端

至于归档嘛 我在测试的时候没有切换日志+不存在日志组写满的情况=>所以没有产生归档;
又因为我在备份的时候加上了delete all input 所以会把已经备份的归档删掉,所以你不会看到新的归档也就不用传了。
三、将自动备份的参数文件也拷贝到B机
四、在B机操作
1.开启伪实例,注意可不要把B机的数据库实例给打开了因为我的测试B机也有数据库。
--先停掉B机上已经有的数据库实例
--启动伪实例orcl
[laolv@centhost3 admin]$ export ORACLE_SID=orcl
[laolv@centhost3 admin]$ echo $ORACLE_SID
orcl
[laolv@centhost3 admin]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Sat Dec 10 21:47:30 2016
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> startup nomount; #启动伪实例
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/opt/oracle/product/12.1.0/dbhome_1/dbs/initorcl.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 1073741824 bytes
Fixed Size 2932632 bytes
Variable Size 281018472 bytes
Database Buffers 784334848 bytes
Redo Buffers 5455872 bytes
RMAN>
2.恢复服务参数文件spfile,然后再关闭伪实例orcl
3.然后再起真正的实例,恢复控制文件
1)参看恢复的参数文件

要先创建audit_file_dest对应的目录,然后启动实例orcl

2)根据前面的备份信息,可知控制问价内存放在
1urn54ev_1_1备份中:
channel ch1: starting full datafile backup set
channel ch1: specifying datafile(s) in backup set
(channel ch2: finished piece 1 at 10-DEC-16
piece handle=/opt/oracle/bakdatabase/1trn54e5_1_1 tag=TAG20161210T201251 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:26)
including
current control file in backup set
channel ch1: starting piece 1 at 10-DEC-16
channel ch1: finished piece 1 at 10-DEC-16
piece handle=/opt/oracle/bakdatabase/
1urn54ev_1_1 tag=TAG20161210T201251 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:01
Finished backup at 10-DEC-16
[laolv@centhost3 bakfromcenthost2]$ ll /opt/oracle/bakfromcenthost2/bakdatabase/1urn54ev_1_1
-rw-rw----. 1 laolv laolv 18055168 Dec 10 20:51 /opt/oracle/bakfromcenthost2/bakdatabase/1urn54ev_1_1
3)另外还需要创建目录
/opt/oracle/oradata/orcl
/opt/oracle/fast_recovery_area/orcl,且oracle的安装用户具有读写权限

4)恢复控制文件
4.把数据库开到mount状态,修复数据文件
--指定备份集,catalog start with '备份集目录'
-
RMAN>
-
RMAN> catalog start with '/opt/oracle/bakfromcenthost2/bakdatabase'; --重新指定备份集,catalog start with '备份集目录'
-
-
searching for all files that match the pattern /opt/oracle/bakfromcenthost2/bakdatabase
-
-
List of Files Unknown to the Database
-
=====================================
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1orn54a4_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1prn54a4_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1trn54e5_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1vrn54f4_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1rrn54bq_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1srn54e5_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1qrn54bi_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1urn54ev_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1nrn54a1_1_1
-
-
Do you really want to catalog the above files (enter YES or NO)? YES
-
cataloging files...
-
cataloging done
-
-
List of Cataloged Files
-
=======================
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1orn54a4_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1prn54a4_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1trn54e5_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1vrn54f4_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1rrn54bq_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1srn54e5_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1qrn54bi_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1urn54ev_1_1
-
File Name: /opt/oracle/bakfromcenthost2/bakdatabase/1nrn54a1_1_1
-
-
RMAN>
恢复数据库
-
Starting restore at 10-DEC-16
-
allocated channel: ORA_DISK_1
-
channel ORA_DISK_1: SID=12 device type=DISK
-
-
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 00003 to /opt/oracle/oradata/orcl/sysaux01.dbf
-
channel ORA_DISK_1: restoring datafile 00004 to /opt/oracle/oradata/orcl/undotbs01.dbf
-
channel ORA_DISK_1: reading from backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1orn54a4_1_1
-
channel ORA_DISK_1: piece handle=/opt/oracle/bakfromcenthost2/bakdatabase/1orn54a4_1_1 tag=TAG20161210T201251
-
channel ORA_DISK_1: restored backup piece 1
-
channel ORA_DISK_1: restore complete, elapsed time: 00:04:45
-
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 00010 to /opt/oracle/oradata/orcl/pdborcl/SAMPLE_SCHEMA_users01.dbf
-
channel ORA_DISK_1: restoring datafile 00011 to /opt/oracle/oradata/orcl/pdborcl/example01.dbf
-
channel ORA_DISK_1: reading from backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1prn54a4_1_1
-
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1prn54a4_1_1
-
ORA-19504: failed to create file "/opt/oracle/oradata/orcl/pdborcl/example01.dbf"
-
ORA-27040: file create error, unable to create file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 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 00008 to /opt/oracle/oradata/orcl/pdborcl/system01.dbf
-
channel ORA_DISK_1: restoring datafile 00009 to /opt/oracle/oradata/orcl/pdborcl/sysaux01.dbf
-
channel ORA_DISK_1: reading from backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1qrn54bi_1_1
-
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1qrn54bi_1_1
-
ORA-19504: failed to create file "/opt/oracle/oradata/orcl/pdborcl/sysaux01.dbf"
-
ORA-27040: file create error, unable to create file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 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 /opt/oracle/oradata/orcl/system01.dbf
-
channel ORA_DISK_1: restoring datafile 00006 to /opt/oracle/oradata/orcl/users01.dbf
-
channel ORA_DISK_1: reading from backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1rrn54bq_1_1
-
channel ORA_DISK_1: piece handle=/opt/oracle/bakfromcenthost2/bakdatabase/1rrn54bq_1_1 tag=TAG20161210T201251
-
channel ORA_DISK_1: restored backup piece 1
-
channel ORA_DISK_1: restore complete, elapsed time: 00:05:03
-
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 00005 to /opt/oracle/oradata/orcl/pdbseed/system01.dbf
-
channel ORA_DISK_1: reading from backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1trn54e5_1_1
-
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1trn54e5_1_1
-
ORA-19504: failed to create file "/opt/oracle/oradata/orcl/pdbseed/system01.dbf"
-
ORA-27040: file create error, unable to create file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 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 00007 to /opt/oracle/oradata/orcl/pdbseed/sysaux01.dbf
-
channel ORA_DISK_1: reading from backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1srn54e5_1_1
-
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1srn54e5_1_1
-
ORA-19504: failed to create file "/opt/oracle/oradata/orcl/pdbseed/sysaux01.dbf"
-
ORA-27040: file create error, unable to create file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 1
-
-
failover to previous backup
-
-
RMAN-00571: ===========================================================
-
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
-
RMAN-00571: ===========================================================
-
RMAN-03002: failure of restore command at 12/10/2016 22:49:20
-
RMAN-06026: some targets not found - aborting restore
-
RMAN-06023: no backup or copy of datafile 11 found to restore
-
RMAN-06023: no backup or copy of datafile 10 found to restore
-
RMAN-06023: no backup or copy of datafile 9 found to restore
-
RMAN-06023: no backup or copy of datafile 8 found to restore
-
RMAN-06023: no backup or copy of datafile 7 found to restore
-
RMAN-06023: no backup or copy of datafile 5 found to restore
-
-
RMAN>
根据源环境,在目标端创建对应的目录
重新恢复数据文件
-
RMAN> restore database;
-
-
Starting restore at 10-DEC-16
-
using channel ORA_DISK_1
-
-
skipping datafile 1; already restored to file /opt/oracle/oradata/orcl/system01.dbf
-
skipping datafile 6; already restored to file /opt/oracle/oradata/orcl/users01.dbf
-
skipping datafile 3; already restored to file /opt/oracle/oradata/orcl/sysaux01.dbf
-
skipping datafile 4; already restored to file /opt/oracle/oradata/orcl/undotbs01.dbf
-
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 00010 to /opt/oracle/oradata/orcl/pdborcl/SAMPLE_SCHEMA_users01.dbf
-
channel ORA_DISK_1: restoring datafile 00011 to /opt/oracle/oradata/orcl/pdborcl/example01.dbf
-
channel ORA_DISK_1: reading from backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1prn54a4_1_1
-
channel ORA_DISK_1: piece handle=/opt/oracle/bakfromcenthost2/bakdatabase/1prn54a4_1_1 tag=TAG20161210T201251
-
channel ORA_DISK_1: restored backup piece 1
-
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
-
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 00008 to /opt/oracle/oradata/orcl/pdborcl/system01.dbf
-
channel ORA_DISK_1: restoring datafile 00009 to /opt/oracle/oradata/orcl/pdborcl/sysaux01.dbf
-
channel ORA_DISK_1: reading from backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1qrn54bi_1_1
-
channel ORA_DISK_1: piece handle=/opt/oracle/bakfromcenthost2/bakdatabase/1qrn54bi_1_1 tag=TAG20161210T201251
-
channel ORA_DISK_1: restored backup piece 1
-
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
-
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 00005 to /opt/oracle/oradata/orcl/pdbseed/system01.dbf
-
channel ORA_DISK_1: reading from backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1trn54e5_1_1
-
channel ORA_DISK_1: piece handle=/opt/oracle/bakfromcenthost2/bakdatabase/1trn54e5_1_1 tag=TAG20161210T201251
-
channel ORA_DISK_1: restored backup piece 1
-
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
-
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 00007 to /opt/oracle/oradata/orcl/pdbseed/sysaux01.dbf
-
channel ORA_DISK_1: reading from backup piece /opt/oracle/bakfromcenthost2/bakdatabase/1srn54e5_1_1
-
channel ORA_DISK_1: piece handle=/opt/oracle/bakfromcenthost2/bakdatabase/1srn54e5_1_1 tag=TAG20161210T201251
-
channel ORA_DISK_1: restored backup piece 1
-
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
-
Finished restore at 10-DEC-16
-
-
RMAN>
5. 放置在线日志文件redo.log,然后恢复数据库
将我前面从源目标数据库拷贝的STATUS=CURRENT的在线日志文件redo01.log 放到 目的目录下

6. 启动数据库实例orcl
[laolv@centhost3 admin]$ echo $ORACLE_SID
orcl
[laolv@centhost3 admin]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Sat Dec 10 23:21:39 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down
SQL>
startup;
ORACLE instance started.
Total System Global Area 1493172224 bytes
Fixed Size 2924592 bytes
Variable Size 486543312 bytes
Database Buffers 989855744 bytes
Redo Buffers 13848576 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> select * from dual;
ADDR INDX INST_ID CON_ID D
---------------- ---------- ---------- ---------- -
000000000E07DD5C 0 1 0 X
SQL> desc dba_users;
ERROR:
ORA-04043: object dba_users does not exist
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open NORESETLOGS;
alter database open NORESETLOGS
*
ERROR at line 1:
ORA-01588: must use RESETLOGS option for database open
SQL>
alter database open RESETLOGS;
Database altered.
SQL>
SQL> desc dba_users;
Name Null? Type
----------------------------------------- -------- ----------------------------
USERNAME NOT NULL VARCHAR2(128)
USER_ID NOT NULL NUMBER
PASSWORD VARCHAR2(4000)
ACCOUNT_STATUS NOT NULL VARCHAR2(32)
LOCK_DATE DATE
EXPIRY_DATE DATE
DEFAULT_TABLESPACE NOT NULL VARCHAR2(30)
TEMPORARY_TABLESPACE NOT NULL VARCHAR2(30)
CREATED NOT NULL DATE
PROFILE NOT NULL VARCHAR2(128)
INITIAL_RSRC_CONSUMER_GROUP VARCHAR2(128)
EXTERNAL_NAME VARCHAR2(4000)
PASSWORD_VERSIONS VARCHAR2(12)
EDITIONS_ENABLED VARCHAR2(1)
AUTHENTICATION_TYPE VARCHAR2(8)
PROXY_ONLY_CONNECT VARCHAR2(1)
COMMON VARCHAR2(3)
LAST_LOGIN TIMESTAMP(9) WITH TIME ZONE
ORACLE_MAINTAINED VARCHAR2(1)
五.测试
tnsnames.ora和listener.ora文件的信息

可是数据库实例orcl就是不能成功向B机本地的监听器,动态注册数据库实例服务
[laolv@centhost3 admin]$ lsnrctl status
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 10-DEC-2016 23:14:50
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=centhost3)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 06-DEC-2016 22:34:05
Uptime 4 days 0 hr. 40 min. 45 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/centhost3/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=centhost3)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
数据库实例服务动态注册:
数据库实例服务动态注册的动作是监听器所在主机上数据库实例完成。
动态注册是Oracle上一个不能关闭的功能。实例的background process PMON,每隔一段时间(一到两分钟)就会将实例的参数信息注册到监听器上,实现动态注册。
注册的信息是数据库参数service_names和instance_name。可以通过Show Parameter命令查看。
一般数据库在建立的时候,这两个参数都是已经设置好的,不会轻易的发生变化。
如果instance_name参数没设置,则系统会取参数db_name作为实例名称返回。
如果service_names没设置,则会将db_name和db_domain两个参数组合成服务名实现注册。
值得注意的一个问题是,service_names参数是一个可以指定多个服务名称的参数,以逗号分隔。也就是说,一个Oracle实例时可以同时作为多个服务名向外提供服务的。Service_name是Oracle在新近版本中提出,替代SID_NAME的概念。使用Service的指定方式,多个Oracle实例就可以统一提供一致的数据访问服务(也就是RAC)。

instance_name和service_names参数信息都对,还是动态注册不了数据库服务!
[laolv@centhost3 bakfromcenthost2]$ tailf /opt/oracle/diag/tnslsnr/centhost3/listener/trace/listener.log --没有service_register和service_update动作
原因:数据库实例的PMON去向监听动态注册数据库服务时,依据的简体器是local_listener指定的监听器,而解析listener参数指定的监听器依据的是tnsnames.ora文件。
参考了:http://blog.sina.com.cn/s/blog_4bde435b01015jnf.html Oracle参数—local_listener参数作用
向tnsnames.ora加入LISTENER_ORCL后,重新alter system register
-
export ORACLE_SID=orcl
-
sqlplus / as sysdba
-
SQL>alter system register
照样
[laolv@centhost3 admin]$ lsnrctl stat LISTENER
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 11-DEC-2016 15:08:59
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=centhost3)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 11-DEC-2016 13:44:10
Uptime 0 days 1 hr. 24 min. 49 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/centhost3/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=centhost3)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
重启数据库实例,并在另外的窗口[laolv@centhost3 bakfromcenthost2]$ tailf /opt/oracle/diag/tnslsnr/centhost3/listener/trace/listener.log
可以看到service_register * orcl 和service_update * orcl了
必须要重启,在tnsnames.ora中添加了LISTENR_ORCL解析记录,alter system register都不会在listner.log中看到注册信息;
说明=>LISTENR_ORCL解析记录,只是在数据库实例启动的时候才使用到的/生效的
登录orcl,查询表t1,进行测试:
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25097694/viewspace-2130241/
,如需转载,请注明出处,否则将追究法律责任。