RMAN之CONVERT整庫遷移
RMAN之CONVERT整庫遷移
rman中的convert命令同樣可以遷移資料檔案,表空間和整個資料庫,此處演示整庫遷移的過程:
檢視一下支援convert有哪些平臺:
SQL> select PLATFORM_NAME,ENDIAN_FORMAT from v$DB_TRANSPORTABLE_PLATFORM;
PLATFORM_NAME ENDIAN_FORMAT
---------------------------------------- ----------------------------------------
Microsoft Windows IA (32-bit) Little
Linux IA (32-bit) Little
HP Tru64 UNIX Little
Linux IA (64-bit) Little
HP Open VMS Little
Microsoft Windows IA (64-bit) Little
Linux 64-bit for AMD Little
Microsoft Windows 64-bit for AMD Little
Solaris Operating System (x86) Little
9 rows selected.
將源庫置於READ ONLY
SQL> startup open read only;
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 100665588 bytes
Database Buffers 62914560 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
檢查是否支援跨平臺傳輸:
SQL> ed
1 declare
2 db_ready boolean;
3 begin
4 db_ready := dbms_tdb.check_db('Linux IA (32-bit)', 2);
5 if(db_ready) then
6 dbms_output.put_line('true');
7 else
8 dbms_output.put_line('false');
9 end if;
10* end;
SQL> set serverout on;
SQL> /
true
PL/SQL procedure successfully completed.
返回true視為正確
檢查是否存在外部物件:
SQL> declare
2 external boolean;
3 begin
4 external := dbms_tdb.check_external;
5 end;
6 /
The following external tables exist in the database:
SH.SALES_TRANSACTIONS_EXT
The following directories exist in the database:
SYS.EXPDP_DIR2, SYS.EXPDP_DIR, SYS.DATA_PUMP_DIR, SYS.SUBDIR, SYS.XMLDIR, SYS.MEDIA_DIR,
SYS.LOG_FILE_DIR, SYS.DATA_FILE_DIR, SYS.WORK_DIR, SYS.ADMIN_DIR
The following BFILEs exist in the database:
PM.PRINT_MEDIA
PL/SQL procedure successfully completed.
以上輸出的物件將不會傳輸到新的資料庫,如果有必要就需DBA手工的將這些物件建立到新的資料庫中
執行整庫轉換:
RMAN> convert database new database 'orcl2'
2> transport script '/u01/rman_convert/whole_db_script.sql'
3> to platform 'Linux IA (32-bit)'
4> db_file_name_convert '/u01/app/oracle/oradata/orcl' '/u01/app/oracle/oradata/orcl2'
5> ;
.
.
.
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:04
Run SQL script /u01/rman_convert/whole_db_script.sql on the target platform to create database
Edit init.ora file /u01/app/oracle/10.2.0/db_1/dbs/init_00p5armv_1_0.ora. This PFILE will be used to create the database on the target platform
To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target platform
To change the internal database identifier, use DBNEWID Utility
Finished backup at 09-APR-14
建立資料檔案和trace檔案的儲存路徑:
[oracle@localhost ~]$ mkdir -p /u01/app/oracle/oradata/orcl2
[oracle@localhost ~]$ mkdir -p /u01/app/oracle/admin/orcl2/{a,b,c,u}dump
將所以的轉換檔案和執行指令碼複製到目標資料庫:
[oracle@localhost ~]$ scp 10.37.100.100:/u01/app/oracle/oradata/orcl2/* /u01/app/oracle/oradata/orcl2/
oracle@10.37.100.100's password:
example01.dbf 100% 100MB 16.7MB/s 00:06
sysaux01.dbf 100% 330MB 13.8MB/s 00:24
system01.dbf 100% 500MB 11.4MB/s 00:44
tts01.dbf 100% 20MB 20.0MB/s 00:01
tts02.dbf 100% 20MB 20.0MB/s 00:00
undotbs001.dbf 100% 100MB 14.3MB/s 00:07
users01.dbf 100% 183MB 15.2MB/s 00:12
[oracle@localhost ~]$ scp 10.37.100.100:/u01/rman_convert/* /u01/rman_convert/
oracle@10.37.100.100's password:
whole_db_script.sql 100% 2853 2.8KB/s 00:00
[oracle@localhost ~]$ scp 10.37.100.100:/u01/app/oracle/10.2.0/db_1/dbs/init_00p5armv_1_0.ora /u01/rman_convert/
oracle@10.37.100.100's password:
init_00p5armv_1_0.ora 100% 1540 1.5KB/s 00:00
修改cupy過來的引數檔案:
[oracle@localhost ~]$ cp /u01/rman_convert/init_00p5armv_1_0.ora /u01/rman_convert/init_orcl2.ora
[oracle@localhost ~]$ vi /u01/rman_convert/init_orcl2.ora
將相關路徑修改成自己的配置:
主要的有以下幾個:
control_files = "/u01/app/oracle/oradata/orcl2/control01.ctl","/u01/app/oracle/oradata/orcl2/control02.ctl","/u01/app/oracle/oradata/orcl2/control03.ctl"
db_recovery_file_dest = "/u01/app/oracle/flash_recovery_area/orcl2"
db_recovery_file_dest_size = 5368709120
background_dump_dest = "/u01/app/oracle/admin/orcl2/bdump"
user_dump_dest = "/u01/app/oracle/admin/orcl2/udump"
core_dump_dest = "/u01/app/oracle/admin/orcl2/cdump"
audit_file_dest = "/u01/app/oracle/admin/orcl2/adump"
db_name = "ORCL2"
修改需要執行的指令碼:(也可按照指令碼一步一步去修改執行)
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT PFILE='/u01/rman_convert/init_orcl2.ora'
CREATE CONTROLFILE REUSE SET DATABASE "ORCL2" RESETLOGS FORCE LOGGING ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/orcl2/redo01.log' SIZE 50M,
GROUP 2 '/u01/app/oracle/oradata/orcl2/redo02.log' SIZE 50M,
GROUP 3 '/u01/app/oracle/oradata/orcl2/redo03' SIZE 50M
DATAFILE
'/u01/app/oracle/oradata/orcl2/system01.dbf',
'/u01/app/oracle/oradata/orcl2/sysaux01.dbf',
'/u01/app/oracle/oradata/orcl2/users01.dbf',
'/u01/app/oracle/oradata/orcl2/example01.dbf',
'/u01/app/oracle/oradata/orcl2/tts01.dbf',
'/u01/app/oracle/oradata/orcl2/tts02.dbf',
'/u01/app/oracle/oradata/orcl2/undotbs001.dbf'
CHARACTER SET WE8ISO8859P1
;
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/10.2.0/db_1/dbs/temp01.dbf'
SIZE 22020096 AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
-- End of tempfile additions.
--
set echo off
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prompt * Your database has been created successfully!
prompt * There are many things to think about for the new database. Here
prompt * is a checklist to help you stay on track:
prompt * 1. You may want to redefine the location of the directory objects.
prompt * 2. You may want to change the internal database identifier (DBID)
prompt * or the global database name for this database. Use the
prompt * NEWDBID Utility (nid).
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SHUTDOWN IMMEDIATE
STARTUP UPGRADE PFILE='/u01/rman_convert/init_orcl2.ora'
@@ ?/rdbms/admin/utlirp.sql
SHUTDOWN IMMEDIATE
STARTUP PFILE='/u01/rman_convert/init_orcl2.ora'
-- The following step will recompile all PL/SQL modules.
-- It may take serveral hours to complete.
@@ ?/rdbms/admin/utlrp.sql
set feedback 6;
修改指令碼相對操作簡單,但要認真,不然很出錯後差錯就麻煩了
設定新的環境變數,進入SQL*plus命令列
[oracle@localhost ~]$ export ORACLE_SID=orcl2
[oracle@localhost ~]$ sqlplus / as sysdba
執行修改後的指令碼:
SQL> @/u01/rman_convert/whole_db_script.sql
期間會重啟幾次資料庫,等待時間較長,要有耐心,尤其是這個時間點:
DOC> 1. Query showing jobs created by UTL_RECOMP
DOC> SELECT job_name FROM dba_scheduler_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
SQL>
SQL> DECLARE
2 threads pls_integer := &&1;
3 BEGIN
4 utl_recomp.recomp_parallel(threads);
5 END;
6 /
執行完成後測試結果:
SQL> conn scott/oracle
Connected.
SQL> select tname from tab;
TNAME
------------------------------
DEPT
EMP
BONUS
SALGRADE
TEST
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29320885/viewspace-1138997/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 用rman遷移資料庫資料庫
- Git 倉庫的整體遷移Git
- Oracle rman duplicate遷移測試Oracle
- Oracle使用RMAN從Windows遷移資料到LinuxOracleWindowsLinux
- 資料遷移的時候出現RMAN-03002,RMAN-06026
- Laravel 學習之資料庫遷移Laravel資料庫
- ORM實操之資料庫遷移ORM資料庫
- 達夢遷移工具之MySQL資料庫遷移到達夢MySql資料庫
- 資料庫遷移資料庫
- RMAN備份恢復典型案例——跨平臺遷移pdb
- git倉庫完整遷移Git
- redis資料庫遷移Redis資料庫
- 資料庫遷移 :理解資料庫
- laravel資料庫遷移Laravel資料庫
- 【RMAN】Oracle使用rman將11.2.0.4資料庫遷移至Oracle12c命令參考Oracle資料庫
- RMAN備份整庫和歸檔日誌的方法
- linux mysql資料庫遷移LinuxMySql資料庫
- django資料庫遷移-15Django資料庫
- 資料庫遷移手記資料庫
- 遷移MySQL 5.7資料庫MySql資料庫
- 資料庫遷移神器——Flyway資料庫
- dm資料庫遷移命令資料庫
- SQL Server資料庫遷移SQLServer資料庫
- Zabbix監控之遷移Zabbix
- MySQL備份遷移之mydumperMySql
- dnf資料庫備份&遷移資料庫
- OGG資料庫遷移方案(一)資料庫
- OGG資料庫遷移方案(二)資料庫
- OGG資料庫遷移方案(三)資料庫
- OGG資料庫遷移方案(四)資料庫
- 資料庫邏輯遷移方案資料庫
- 無外網Oracle資料庫遷移Oracle資料庫
- Oracle資料庫(DataGuard)遷移方案(上)Oracle資料庫
- Oracle資料庫(DataGuard)遷移方案(中)Oracle資料庫
- Oracle資料庫(DataGuard)遷移方案(下)Oracle資料庫
- Laravel migration (資料庫遷移) 的使用Laravel資料庫
- 騰訊雲 雲資料庫遷移資料庫
- laravel 資料庫遷移時報錯Laravel資料庫
- WindowsServer 2012資料庫遷移記錄WindowsServer資料庫