記一次資料遷移
本次試驗將完成一次源資料庫到目標資料庫的遷移
源資料庫所在系統ip地址:192.168.133.128
目標資料庫所在系統ip地址:192.168.133.132
源資料庫檔案位置:/u01/app/oracle/oradata/orcl
目標資料庫檔案位置: /u01/app/oracle/oradata/orcl
(二者目錄最好相同,以避免不必要的麻煩)
在目標資料庫所在的系統上要建立相應的目錄
資料檔案和控制檔案的目錄:
[oracle@localhost oracle]$ mkdir -p oradata/orcl
[oracle@localhost oradata]$ pwd
/u01/app/oracle/oradata
/u01/app/oracle/oradata
日誌檔案和跟蹤檔案的目錄:
[oracle@localhost oracle]$ mkdir -p diag/rdbms/orcl/orcl/trace
[oracle@localhost trace]$ pwd
/u01/app/oracle/diag/rdbms/orcl/orcl/trace
/u01/app/oracle/diag/rdbms/orcl/orcl/trace
閃回區:
[oracle@localhost oracle]$ mkdir -p flash_recovery_area/orcl
[oracle@localhost orcl]$ pwd
/u01/app/oracle/flash_recovery_area/orcl
/u01/app/oracle/flash_recovery_area/orcl
歸檔日誌檔案目錄:
[oracle@localhost app]$ mkdir -p archivelog/dest1
[oracle@localhost dest1]$ pwd
/u01/app/archivelog/dest1
/u01/app/archivelog/dest1
審計相關目錄:
[oracle@localhost oracle]$ mkdir -p admin/orcl/adump
[oracle@localhost adump]$ pwd
/u01/app/oracle/admin/orcl/adump
/u01/app/oracle/admin/orcl/adump
備份目錄:
[oracle@localhost orcl]$ pwd
/backup/orcl
/backup/orcl
使用rman將源資料庫做一次全備:
在備份之前要做一次歸檔
開啟rman進行全庫備份:
[oracle@oracle /]$ rman target sys/oracle nocatalog
Recovery Manager: Release 11.2.0.1.0 - Production on Tue Oct 28 05:21:06 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1383986269)
using target database control file instead of recovery catalog
Recovery Manager: Release 11.2.0.1.0 - Production on Tue Oct 28 05:21:06 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1383986269)
using target database control file instead of recovery catalog
RMAN> run{
2> configure device type disk parallelism 2;
3> configure controlfile autobackup on;
4> configure controlfile autobackup format for device type disk to '/u01/app/backup/mvbackup/controlfile_%F';
5> allocate channel c1 type disk format '/u01/app/backup/mvbackup/fulldb_%U';
6> backup spfile format '/u01/app/backup/mvbackup/spfile_%d_%s';
7> backup database plus archivelog tag 'fulldb' delete input;
8> release channel c1;
9> }
接下來就可以使用scp命令將生成的備份檔案傳送到目標系統192.168.133.132:
[oracle@oracle mvbackup]$ scp ./* oracle@192.168.133.132:/backup/orcl/
在目標系統/backup/orcl下執行watch -n 1 du -sh *可以看到檔案正在複製:
Recovery Manager: Release 11.2.0.1.0 - Production on Tue Oct 28 20:18:06 2014
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorcl.ora'
Oracle instance started
Variable Size 75497576 bytes
Database Buffers 79691776 bytes
Redo Buffers 2494464 bytes
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 28-OCT-14
在目標系統/backup/orcl下執行watch -n 1 du -sh *可以看到檔案正在複製:
到相應目錄下檢視是否傳完:
[oracle@localhost orcl]$ pwd
/backup/orcl
[oracle@localhost orcl]$ ls
controlfile_c-1383986269-20141028-01 fulldb_4cpm5oqc_1_1 fulldb_4dpm5p1c_1_1 fulldb_4epm5p6g_1_1 fulldb_4fpm5pa7_1_1 spfile_ORCL_138 spfile_ORCL_139
/backup/orcl
[oracle@localhost orcl]$ ls
controlfile_c-1383986269-20141028-01 fulldb_4cpm5oqc_1_1 fulldb_4dpm5p1c_1_1 fulldb_4epm5p6g_1_1 fulldb_4fpm5pa7_1_1 spfile_ORCL_138 spfile_ORCL_139
首先透過rman恢復spfile:
Copyright (c) 1982, 2009, 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
starting Oracle instance without parameter file for retrieval of spfile
Total System Global Area 159019008 bytes
Fixed Size 1335192 bytes
RMAN> restore spfile to '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl.ora' from '/backup/orcl/spfile_ORCL_139';
Starting restore at 28-OCT-14
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /backup/orcl/spfile_ORCL_139
由於與目標伺服器路徑不相同,所以恢復完spfile之後,需要生成pfile檔案進行編輯修改引數值:
[oracle@localhost orcl]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Tue Oct 28 20:19:50 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> create pfile from spfile;
File created.
SQL*Plus: Release 11.2.0.1.0 Production on Tue Oct 28 20:19:50 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> create pfile from spfile;
File created.
[oracle@localhost dbs]$ vi initorcl.ora
orcl.__db_cache_size=201326592
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=297795584
orcl.__sga_target=553648128
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=331350016
orcl.__streams_pool_size=4194304
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/flash_recovery_area/orcl/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_flashback_retention_target=240
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.fast_start_mttr_target=300
*.job_queue_processes=1000
*.log_archive_dest_1='location=/u01/app/archivelog/dest1'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=848297984
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
*.resource_limit=TRUE
*.undo_tablespace='UNDOTBS1'
orcl.__db_cache_size=201326592
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=297795584
orcl.__sga_target=553648128
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=331350016
orcl.__streams_pool_size=4194304
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/flash_recovery_area/orcl/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_flashback_retention_target=240
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.fast_start_mttr_target=300
*.job_queue_processes=1000
*.log_archive_dest_1='location=/u01/app/archivelog/dest1'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=848297984
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
*.resource_limit=TRUE
*.undo_tablespace='UNDOTBS1'
存檔退出。
將修改應用到spfile中:
SQL> create spfile from pfile;
File created.
啟動資料庫到nomount:
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 849530880 bytes
Fixed Size 1339824 bytes
Variable Size 641732176 bytes
Database Buffers 201326592 bytes
Redo Buffers 5132288 bytes
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/11.2.0
/dbhome_1/dbs/spfileorcl.ora
恢復控制檔案:
RMAN> restore controlfile from '/backup/orcl/controlfile_c-1383986269-20141028-01';
Starting restore at 28-OCT-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/orcl/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/orcl/control02.ctl
Finished restore at 28-OCT-14
檢查物理上的控制檔案是否已經恢復:
[oracle@localhost orcl]$ ls
control02.ctl
[oracle@localhost orcl]$ pwd
/u01/app/oracle/flash_recovery_area/orcl
control02.ctl
[oracle@localhost orcl]$ pwd
/u01/app/oracle/flash_recovery_area/orcl
啟動資料庫到mount:
SQL> alter database mount;
Database altered.
恢復資料檔案:
由於在源伺服器中我的備份集是在/u01/app/backup/mvbackup目錄下的,而這些備份資訊又是存放在控制檔案中。
我們在目標伺服器恢復的控制檔案是來源於源資料庫的,而我們在目標伺服器中的備份集存放的目錄(/backup/orcl)和源伺服器是不同的,因此在目標伺服器中使用rman進行資料檔案恢復的時候,rman讀取的還是原控制檔案中記錄的位置資訊,我們要讓rman去讀取/backup/orcl中的備份集,所以執行以下步驟通知rman備份集的存放位置已經改變了:
RMAN> catalog start with '/backup/orcl';
searching for all files that match the pattern /backup/orcl
List of Files Unknown to the Database
=====================================
File Name: /backup/orcl/spfile_ORCL_138
File Name: /backup/orcl/spfile_ORCL_139
File Name: /backup/orcl/fulldb_4fpm5pa7_1_1
File Name: /backup/orcl/controlfile_c-1383986269-20141028-01
File Name: /backup/orcl/fulldb_4cpm5oqc_1_1
File Name: /backup/orcl/fulldb_4epm5p6g_1_1
File Name: /backup/orcl/fulldb_4dpm5p1c_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: /backup/orcl/spfile_ORCL_138
File Name: /backup/orcl/spfile_ORCL_139
File Name: /backup/orcl/fulldb_4fpm5pa7_1_1
File Name: /backup/orcl/controlfile_c-1383986269-20141028-01
File Name: /backup/orcl/fulldb_4cpm5oqc_1_1
File Name: /backup/orcl/fulldb_4epm5p6g_1_1
File Name: /backup/orcl/fulldb_4dpm5p1c_1_1
接著開始進行資料檔案的恢復(由於目標資料庫中資料檔案存放的位置和目標資料庫相同,所以這裡無須rename file):
RMAN> restore database;
Starting restore at 28-OCT-14
using channel ORA_DISK_1
using channel ORA_DISK_2
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 /u01/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/data02.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/orcl/test01.dbf
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/orcl/hh01.dbf
channel ORA_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/orcl/goods01.dbf
channel ORA_DISK_1: restoring datafile 00009 to /u01/app/oracle/oradata/orcl/data01a.dbf
channel ORA_DISK_1: restoring datafile 00010 to /u01/app/oracle/oradata/orcl/data01b.dbf
channel ORA_DISK_1: restoring datafile 00012 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: reading from backup piece /backup/orcl/fulldb_4epm5p6g_1_1
channel ORA_DISK_1: piece handle=/backup/orcl/fulldb_4epm5p6g_1_1 tag=TAG20141028T053200
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:23
Finished restore at 28-OCT-14
最後recover database:
RMAN> recover database;
Starting recover at 28-OCT-14
using channel ORA_DISK_1
using channel ORA_DISK_2
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=68
channel ORA_DISK_1: reading from backup piece /backup/orcl/fulldb_4fpm5pa7_1_1
channel ORA_DISK_1: piece handle=/backup/orcl/fulldb_4fpm5pa7_1_1 tag=FULLDB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/archivelog/dest1/1_68_861508222.dbf thread=1 sequence=68
unable to find archived log
archived log thread=1 sequence=69
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/28/2014 21:05:08
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 69 and starting SCN of 2941977
這裡出現找不到某個序列號的歸檔日誌屬於正常現象。因為我們在備份源資料庫的時候資料庫處於執行的狀態,就會有些歸檔日誌內容沒有備份到。
RMAN> recover database until sequence 69;
Starting recover at 28-OCT-14
using channel ORA_DISK_1
using channel ORA_DISK_2
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 28-OCT-14
接下來就可以使用alter database open resetlogs;開啟資料庫了:
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-19751: could not create the change tracking file
ORA-19750: change tracking file: '/u01/app/datafile/change_tracking.dbf'
ORA-27040: file create error, unable to create file
Linux Error: 2: No such file or directory
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
遇到這個問題是由於源資料庫中使用了塊變化跟蹤,這裡我們只需要把它disable掉就可以解決問題了。
SQL> alter database disable block change tracking;
Database altered.
接下來就可以開啟資料庫了。
資料庫成功開啟之後要進行檢查:
SQL> select name from v$datafile
2 union
3 select member from v$logfile
4 union
5 select name from v$controlfile
6 union
7 select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/flash_recovery_area/orcl/control02.ctl
/u01/app/oracle/oradata/orcl/control01.ctl
/u01/app/oracle/oradata/orcl/data01a.dbf
/u01/app/oracle/oradata/orcl/data01b.dbf
/u01/app/oracle/oradata/orcl/data02.dbf
/u01/app/oracle/oradata/orcl/example01.dbf
/u01/app/oracle/oradata/orcl/goods01.dbf
/u01/app/oracle/oradata/orcl/hh01.dbf
/u01/app/oracle/oradata/orcl/redo01.log
/u01/app/oracle/oradata/orcl/redo02.log
/u01/app/oracle/oradata/orcl/redo03.log
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/redo04.log
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/temp02.dbf
/u01/app/oracle/oradata/orcl/test01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
18 rows selected.
最後配置監聽檔案listener.ora:
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
# )
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle
~
~
啟動監聽:
[oracle@localhost ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 28-OCT-2014 21:22:39
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 28-OCT-2014 21:22:39
Uptime 0 days 0 hr. 0 min. 2 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 28-OCT-2014 21:22:39
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 28-OCT-2014 21:22:39
Uptime 0 days 0 hr. 0 min. 2 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29800581/viewspace-1312980/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【Golang+mysql】記一次mysql資料庫遷移(一)GolangMySql資料庫
- 資料庫遷移手記資料庫
- 一次艱難的oracle資料遷移Oracle
- 安全警示錄---記一次oracle資料檔案遷移過程Oracle
- bi資料庫遷移小記資料庫
- [Database Migration] 記一次未達預期的資料庫遷移Database資料庫
- 遷移資料.
- 【遷移】使用rman遷移資料庫資料庫
- 一次dg資料檔案及archive log遷移Hive
- 【資料遷移】使用傳輸表空間遷移資料
- Oracle遷移資料庫過程記錄Oracle資料庫
- Kafka資料遷移Kafka
- 資料庫遷移資料庫
- redis資料遷移Redis
- 轉資料遷移
- ORACLE 資料遷移Oracle
- DXWB 資料遷移
- 資料的遷移
- Harbor資料遷移
- 記一次 GitLab 的遷移過程Gitlab
- 記一次遷移和效能最佳化
- 一次資料庫上雲遷移效能下降的排查資料庫
- 【資料遷移】RMAN遷移資料庫到ASM(三)遷移onlinelog等到ASM資料庫ASM
- 百萬級資料遷移方案測評小記
- Mysql百萬級資料遷移實戰筆記MySql筆記
- 資料遷移(1)——通過資料泵表結構批量遷移
- 記錄一次XTTS遷移碰到的問題TTS
- 最近的一次ASM diskgroup線上遷移記錄ASM
- 一次用rman做資料遷移的實戰經歷
- gitlab資料遷移Gitlab
- 資料庫遷移 :理解資料庫
- Mysql資料遷移方法MySql
- Fastdfs資料遷移方案AST
- 【Redis】 redis資料遷移Redis
- 【Hive】hive資料遷移Hive
- laravel資料庫遷移Laravel資料庫
- Odoo遷移資料庫Odoo資料庫
- exp,imp 遷移資料