使用RMAN遷移單庫到RAC
一、源庫
create pfile='/home/oracle/rman_bk/pfile.ora' from spfile;
backup incremental level 0 format '/home/oracle/rman_bk/orcl_%U' database plus archivelog delete all input;
backup current controlfile format '/home/oracle/rman_bk/control_%U';
將/home/oracle/rman_bk目錄下檔案複製到目標庫相應目錄下
二、目標庫(其中一個節點上操作)
1、根據源庫生成的pfile建立rac的spfile
(1)修改引數檔案
[oracle@centosnode1 rman]$ vim pfile.ora
*.__db_cache_size=104857600
*.__java_pool_size=4194304
*.__large_pool_size=4194304
*.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.__pga_aggregate_target=192937984
*.__sga_target=343932928
*.__shared_io_pool_size=0
*.__shared_pool_size=213909504
*.__streams_pool_size=8388608
db021.instance_name='db021'
db022.instance_name='db022'
db021.instance_number=1
db022.instance_number=2
*.audit_file_dest='/u01/app/oracle/admin/db02/adump'
*.audit_trail='db'
*.cluster_database=true
*.cluster_database_instances=2
db021.thread=1
*.compatible='11.2.0.1.0'
*.control_files='+DATA/db02/controlfile/current.1214.911838439'#Restore Controlfile
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='db02'
*.db_recovery_file_dest=''
*.log_archive_dest_1='location=+DATA/db02/arch'
*.log_archive_format='%t_%s_%r.dbf'
*.job_queue_processes=10
*.remote_login_passwordfile='EXCLUSIVE'
*.memory_target=1606418432
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
db022.undo_tablespace='UNDOTBS2'
db021.undo_tablespace='UNDOTBS1'
注意:1、這個時候不能加orcl2.thread=2引數,否則後面無法將資料庫啟動到mount狀態
2、*.compatible='11.2.0.1.0'指定的版本號一定要和源庫的版本號一致,否則後面恢復控制檔案後,啟動例項到mount狀態是報錯:
ORA-00201: control file version 11.2.0.1.0 incompatible with ORACLE version11.2.0.0.0
(2)建立共享引數檔案spfile
SQL> create spfile='+DATA/db02/parameterfile/spfiledb02.ora' from pfile='/home/oracle/rman/pfile.ora';
(3)在兩個節點上分別建立審計目錄、pfile以及密碼檔案
[oracle@centosnode1 rman]$ mkdir -p /u01/app/oracle/admin/db02/adump
[oracle@centosnode1 rman]$ cd $ORACLE_HOME/dbs
[oracle@centosnode1 dbs]$ echo 'spfile=+DATA/db02/parameterfile/spfiledb02.ora' > initdb021.ora
[oracle@centosnode1 dbs]$ orapwd file=orapwdb021 password=oracle
2、將節點例項啟動到nomount狀態,然後從備份中恢復控制檔案
RMAN> restore controlfile from '/home/oracle/rman/control_0sr5lmfp_1_1';
3、恢復控制檔案後重新啟動例項到mount狀態,恢復資料檔案
run{
set newname for datafile 1 to '+DATA/db02/datafile/system01.dbf';
set newname for datafile 2 to '+DATA/db02/datafile/sysaux01.dbf';
set newname for datafile 3 to '+DATA/db02/datafile/undotbs01.dbf';
set newname for datafile 4 to '+DATA/db02/datafile/users01.dbf';
set newname for datafile 5 to '+DATA/db02/datafile/tbs01.dbf';
set newname for datafile 6 to '+DATA/db02/datafile/citibank.dbf';
set newname for tempfile 1 to '+DATA/db02/tempfile/temp01.dbf';
restore database;
switch datafile all;
switch tempfile all;
}
recover database;
4、對線上重做日誌檔案進行更名,新增thread 2日誌組
SQL> alter database rename file '/u01/app/oracle/oradata/db02/redo01.log' to '+DATA/db02/onlinelog/redo01.log';
SQL> alter database rename file '/u01/app/oracle/oradata/db02/redo02.log' to '+DATA/db02/onlinelog/redo02.log';
SQL> alter database rename file '/u01/app/oracle/oradata/db02/redo03.log' to '+DATA/db02/onlinelog/redo03.log';
SQL> alter database add logfile thread 2 group 4 '+DATA' size 50M;
SQL> alter database add logfile thread 2 group 5 '+DATA' size 50M;
SQL> alter database add logfile thread 2 group 6 '+DATA' size 50M;
SQL> select thread#,bytes/(1024*1024),status from v$log;
THREAD# BYTES/(1024*1024) STATUS
---------- ----------------- ----------------
1 50 CURRENT
1 50 INACTIVE
1 50 INACTIVE
2 50 UNUSED
2 50 UNUSED
2 50 UNUSED
5、使用open resetlogs方式開啟資料庫
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 2609022 generated at 05/15/2016 16:05:49 needed for thread 1
ORA-00289: suggestion : +DATA/db02/arch/1_60_908532301.dbf
ORA-00280: change 2609022 for thread 1 is in sequence #60
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL> alter database open resetlogs;
Database altered.
SQL> select open_mode,name from gv$database;
OPEN_MODE NAME
-------------------- ---------
READ WRITE DB02
6、修改相關的初始化引數,建立undotbs2表空間,啟用thread 2日誌組
SQL> alter system set thread=1 scope=spfile sid='db021';
SQL> alter system set thread=2 scope=spfile sid='db022';
SQL> select bytes/(1024*1024) MB from dba_data_files where tablespace_name='UNDOTBS1';
MB
----------
75
SQL> create undo tablespace undotbs2 datafile '+DATA/db02/datafile/undotbs02.dbf' size 75M;
SQL> alter system set undo_tablespace=undotbs2 sid='db022';
SQL> alter database enable thread 2;
alter database enable thread 2
*
ERROR at line 1:
ORA-01612: instance UNNAMED_INSTANCE_2 (thread 2) is already enabled
注:此處已經啟動,如果沒有啟動需要手動啟動日誌程式thread 2
7、重新啟動節點1例項,再啟動節點2例項
三、新增db02庫到srvctl管理
[oracle@centosnode1 ~]$ srvctl add database -d db02 -o /u01/app/oracle/product/11.2.0/db_1 -p +DATA/orcl/spfileorcl.ora
[oracle@centosnode1 ~]$ srvctl add instance -d db02 -i db021 -n centosnode1
[oracle@centosnode1 ~]$ srvctl add instance -d db02 -i db022 -n centosnode2
[oracle@centosnode1 ~]$ srvctl start database -d db02
[oracle@centosnode1 ~]$ srvctl status database -d db02
Instance db021 is running on node centosnode1
Instance db022 is running on node centosnode2
注意:要使用oracle使用者新增
備註:srvctl刪除資料庫資訊命令:
[oracle@rac1 ~]$ srvctl stop database -d db02
[oracle@rac1 ~]$ srvctl remove database -d db02
create pfile='/home/oracle/rman_bk/pfile.ora' from spfile;
backup incremental level 0 format '/home/oracle/rman_bk/orcl_%U' database plus archivelog delete all input;
backup current controlfile format '/home/oracle/rman_bk/control_%U';
將/home/oracle/rman_bk目錄下檔案複製到目標庫相應目錄下
二、目標庫(其中一個節點上操作)
1、根據源庫生成的pfile建立rac的spfile
(1)修改引數檔案
[oracle@centosnode1 rman]$ vim pfile.ora
*.__db_cache_size=104857600
*.__java_pool_size=4194304
*.__large_pool_size=4194304
*.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.__pga_aggregate_target=192937984
*.__sga_target=343932928
*.__shared_io_pool_size=0
*.__shared_pool_size=213909504
*.__streams_pool_size=8388608
db021.instance_name='db021'
db022.instance_name='db022'
db021.instance_number=1
db022.instance_number=2
*.audit_file_dest='/u01/app/oracle/admin/db02/adump'
*.audit_trail='db'
*.cluster_database=true
*.cluster_database_instances=2
db021.thread=1
*.compatible='11.2.0.1.0'
*.control_files='+DATA/db02/controlfile/current.1214.911838439'#Restore Controlfile
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='db02'
*.db_recovery_file_dest=''
*.log_archive_dest_1='location=+DATA/db02/arch'
*.log_archive_format='%t_%s_%r.dbf'
*.job_queue_processes=10
*.remote_login_passwordfile='EXCLUSIVE'
*.memory_target=1606418432
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
db022.undo_tablespace='UNDOTBS2'
db021.undo_tablespace='UNDOTBS1'
注意:1、這個時候不能加orcl2.thread=2引數,否則後面無法將資料庫啟動到mount狀態
2、*.compatible='11.2.0.1.0'指定的版本號一定要和源庫的版本號一致,否則後面恢復控制檔案後,啟動例項到mount狀態是報錯:
ORA-00201: control file version 11.2.0.1.0 incompatible with ORACLE version11.2.0.0.0
(2)建立共享引數檔案spfile
SQL> create spfile='+DATA/db02/parameterfile/spfiledb02.ora' from pfile='/home/oracle/rman/pfile.ora';
(3)在兩個節點上分別建立審計目錄、pfile以及密碼檔案
[oracle@centosnode1 rman]$ mkdir -p /u01/app/oracle/admin/db02/adump
[oracle@centosnode1 rman]$ cd $ORACLE_HOME/dbs
[oracle@centosnode1 dbs]$ echo 'spfile=+DATA/db02/parameterfile/spfiledb02.ora' > initdb021.ora
[oracle@centosnode1 dbs]$ orapwd file=orapwdb021 password=oracle
2、將節點例項啟動到nomount狀態,然後從備份中恢復控制檔案
RMAN> restore controlfile from '/home/oracle/rman/control_0sr5lmfp_1_1';
3、恢復控制檔案後重新啟動例項到mount狀態,恢復資料檔案
run{
set newname for datafile 1 to '+DATA/db02/datafile/system01.dbf';
set newname for datafile 2 to '+DATA/db02/datafile/sysaux01.dbf';
set newname for datafile 3 to '+DATA/db02/datafile/undotbs01.dbf';
set newname for datafile 4 to '+DATA/db02/datafile/users01.dbf';
set newname for datafile 5 to '+DATA/db02/datafile/tbs01.dbf';
set newname for datafile 6 to '+DATA/db02/datafile/citibank.dbf';
set newname for tempfile 1 to '+DATA/db02/tempfile/temp01.dbf';
restore database;
switch datafile all;
switch tempfile all;
}
recover database;
4、對線上重做日誌檔案進行更名,新增thread 2日誌組
SQL> alter database rename file '/u01/app/oracle/oradata/db02/redo01.log' to '+DATA/db02/onlinelog/redo01.log';
SQL> alter database rename file '/u01/app/oracle/oradata/db02/redo02.log' to '+DATA/db02/onlinelog/redo02.log';
SQL> alter database rename file '/u01/app/oracle/oradata/db02/redo03.log' to '+DATA/db02/onlinelog/redo03.log';
SQL> alter database add logfile thread 2 group 4 '+DATA' size 50M;
SQL> alter database add logfile thread 2 group 5 '+DATA' size 50M;
SQL> alter database add logfile thread 2 group 6 '+DATA' size 50M;
SQL> select thread#,bytes/(1024*1024),status from v$log;
THREAD# BYTES/(1024*1024) STATUS
---------- ----------------- ----------------
1 50 CURRENT
1 50 INACTIVE
1 50 INACTIVE
2 50 UNUSED
2 50 UNUSED
2 50 UNUSED
5、使用open resetlogs方式開啟資料庫
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 2609022 generated at 05/15/2016 16:05:49 needed for thread 1
ORA-00289: suggestion : +DATA/db02/arch/1_60_908532301.dbf
ORA-00280: change 2609022 for thread 1 is in sequence #60
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL> alter database open resetlogs;
Database altered.
SQL> select open_mode,name from gv$database;
OPEN_MODE NAME
-------------------- ---------
READ WRITE DB02
6、修改相關的初始化引數,建立undotbs2表空間,啟用thread 2日誌組
SQL> alter system set thread=1 scope=spfile sid='db021';
SQL> alter system set thread=2 scope=spfile sid='db022';
SQL> select bytes/(1024*1024) MB from dba_data_files where tablespace_name='UNDOTBS1';
MB
----------
75
SQL> create undo tablespace undotbs2 datafile '+DATA/db02/datafile/undotbs02.dbf' size 75M;
SQL> alter system set undo_tablespace=undotbs2 sid='db022';
SQL> alter database enable thread 2;
alter database enable thread 2
*
ERROR at line 1:
ORA-01612: instance UNNAMED_INSTANCE_2 (thread 2) is already enabled
注:此處已經啟動,如果沒有啟動需要手動啟動日誌程式thread 2
7、重新啟動節點1例項,再啟動節點2例項
三、新增db02庫到srvctl管理
[oracle@centosnode1 ~]$ srvctl add database -d db02 -o /u01/app/oracle/product/11.2.0/db_1 -p +DATA/orcl/spfileorcl.ora
[oracle@centosnode1 ~]$ srvctl add instance -d db02 -i db021 -n centosnode1
[oracle@centosnode1 ~]$ srvctl add instance -d db02 -i db022 -n centosnode2
[oracle@centosnode1 ~]$ srvctl start database -d db02
[oracle@centosnode1 ~]$ srvctl status database -d db02
Instance db021 is running on node centosnode1
Instance db022 is running on node centosnode2
注意:要使用oracle使用者新增
備註:srvctl刪除資料庫資訊命令:
[oracle@rac1 ~]$ srvctl stop database -d db02
[oracle@rac1 ~]$ srvctl remove database -d db02
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29067253/viewspace-2127179/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 用rman遷移資料庫資料庫
- Oracle 12c 使用RMAN搭建物理備庫(RAC to RAC)Oracle
- Oracle使用RMAN從Windows遷移資料到LinuxOracleWindowsLinux
- Oracle rman duplicate遷移測試Oracle
- Oracle搭建rac到單庫的adgOracle
- Oracle RAC 遷移替換 OCR 盤Oracle
- 使用GoldenGate 遷移Oracle到PostgreSQL/LightDBGoOracleSQL
- 【RMAN】Oracle使用rman將11.2.0.4資料庫遷移至Oracle12c命令參考Oracle資料庫
- 資料遷移的時候出現RMAN-03002,RMAN-06026
- Oracle 11G RAC複製備庫RMAN-03002 RMAN-05501 RMAN-03015 RMAN-03009 RMAN-10038Oracle
- 如何從SVN遷移原始碼到Git倉庫原始碼Git
- Laravel migration (資料庫遷移) 的使用Laravel資料庫
- RMAN Duplicate RAC to Single Instance
- Solaris 10下遷移10G RAC (六)
- Solaris 10下遷移10G RAC (八)
- Solaris 10下遷移10G RAC (四)
- oracle RAC 更換儲存遷移資料Oracle
- Solaris 10下遷移10G RAC (二)
- Solaris 10下遷移10G RAC (七)
- Solaris 10下遷移10G RAC (三)
- Solaris 10下遷移10G RAC (一)
- Solaris 10下遷移10G RAC (五)
- 簡單分析Flask 資料庫遷移詳情Flask資料庫
- 如何使用 abp 建立 module 並應用單獨的資料庫遷移資料庫
- 金倉資料庫資料遷移實戰:從MySQL到KES的順利遷移資料庫MySql
- 資料庫遷移資料庫
- RAC恢復到單機
- RMAN備份恢復典型案例——跨平臺遷移pdb
- 遷移資料庫的檔案到不同路徑(轉)資料庫
- 從 SQL Server 到 MySQL (一):異構資料庫遷移ServerMySql資料庫
- 【MOS】如何利用RMAN可傳輸表空間遷移資料庫到不同位元組序的平臺(文件 ID 1983639.1)資料庫
- git倉庫完整遷移Git
- redis資料庫遷移Redis資料庫
- 資料庫遷移 :理解資料庫
- laravel資料庫遷移Laravel資料庫
- rac恢復到單例項單例
- 如何完整遷移git倉庫到另一個遠端地址Git
- 使用資料泵(expdp、impdp)遷移資料庫流程資料庫
- 使用RMAN備份資料庫資料庫