oracle11g windows迁移至linux
概述:跨操作系统平台数据库迁移,windows to linux 步骤记录;
实验步骤:
(一)、linux平台安装好数据库软件及配置好监听;
(二)、备份windows数据库;
(三)、linux平台进行数据库恢复操作;
(四)、linux平台进行数据库恢复后的相关操作;
windows 备份数据库:
run {
configure device type disk parallelism 4;
backup database format 'C:\bak\full_%U';
}
模拟数据库还在运行,多切换几个日志进行归档:
alter system switch logfile; (多次执行)
备份控制文件
alter database backup controlfile to 'C:\bak\ctl.bak';
将备份文件、备份控制文件、全量的归档 传输与linux平台
linux平台进行恢复操作:
启动linux至nomount状态:
[oracle@q2 dbs]$ cat initcube.ora
db_name='cube'
memory_target=500M
processes = 150
audit_file_dest='/u01/ora/app/admin/cube/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/ora/app/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/ora/app'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
control_files = (/u01/ora/app/data/control1.ctl, /u01/ora/app/data/control2.ctl)
compatible ='11.2.0'
恢复数据:
rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Fri Mar 2 03:09:56 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: CUBE (not mounted)
RMAN> restore controlfile from '/u01/ora/app/bak/CTL.BAK';
Starting restore at 02-MAR-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
channel ORA_DISK_1: copied control file copy
output file name=/u01/ora/app/data/control1.ctl
output file name=/u01/ora/app/data/control2.ctl
Finished restore at 02-MAR-18
RMAN> sql 'alter database mount';
sql statement: alter database mount
released channel: ORA_DISK_1
RMAN> catalog start with '/u01/ora/app/bak/';
Starting implicit crosscheck backup at 02-MAR-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=21 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=22 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=23 device type=DISK
Crosschecked 10 objects
Finished implicit crosscheck backup at 02-MAR-18
Starting implicit crosscheck copy at 02-MAR-18
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
Crosschecked 2 objects
Finished implicit crosscheck copy at 02-MAR-18
searching for all files in the recovery area
cataloging files...
no files cataloged
searching for all files that match the pattern /u01/ora/app/bak/
List of Files Unknown to the Database
=====================================
File Name: /u01/ora/app/bak/ARC0000000004_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000005_0968951521.0001
File Name: /u01/ora/app/bak/FULL_08SSP3N8_1_1
File Name: /u01/ora/app/bak/ARC0000000009_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000007_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000006_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000012_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000008_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000014_0968951521.0001
File Name: /u01/ora/app/bak/FULL_06SSP3N8_1_1
File Name: /u01/ora/app/bak/ARC0000000010_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000016_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000015_0968951521.0001
File Name: /u01/ora/app/bak/FULL_07SSP3N8_1_1
File Name: /u01/ora/app/bak/CTL.BAK
File Name: /u01/ora/app/bak/FULL_09SSP3N8_1_1
File Name: /u01/ora/app/bak/FULL_0ASSP3N9_1_1
File Name: /u01/ora/app/bak/ARC0000000013_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000011_0968951521.0001
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/ora/app/bak/ARC0000000004_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000005_0968951521.0001
File Name: /u01/ora/app/bak/FULL_08SSP3N8_1_1
File Name: /u01/ora/app/bak/ARC0000000009_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000007_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000006_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000012_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000008_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000014_0968951521.0001
File Name: /u01/ora/app/bak/FULL_06SSP3N8_1_1
File Name: /u01/ora/app/bak/ARC0000000010_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000016_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000015_0968951521.0001
File Name: /u01/ora/app/bak/FULL_07SSP3N8_1_1
File Name: /u01/ora/app/bak/CTL.BAK
File Name: /u01/ora/app/bak/FULL_09SSP3N8_1_1
File Name: /u01/ora/app/bak/FULL_0ASSP3N9_1_1
File Name: /u01/ora/app/bak/ARC0000000013_0968951521.0001
File Name: /u01/ora/app/bak/ARC0000000011_0968951521.0001
RMAN> report schema;
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema for database with db_unique_name CUBE
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 0 SYSTEM *** C:\DATA\ORADATA\CUBE\SYSTEM01.DBF
2 0 SYSAUX *** C:\DATA\ORADATA\CUBE\SYSAUX01.DBF
3 0 UNDOTBS1 *** C:\DATA\ORADATA\CUBE\UNDOTBS01.DBF
4 0 USERS *** C:\DATA\ORADATA\CUBE\USERS01.DBF
5 0 CUBE *** C:\DATA\ORADATA\CUBE\CUBE01.DBF
6 0 CUBE *** C:\DATA\ORADATA\CUBE\CUBE02.DBF
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 C:\DATA\ORADATA\CUBE\TEMP01.DBF
RMAN> run{
set newname for datafile 1 to '/u01/ora/app/data/SYSTEM01.DBF';
set newname for datafile 2 to '/u01/ora/app/data/SYSAUX01.DBF';
set newname for datafile 3 to '/u01/ora/app/data/UNDOTBS01.DBF';
set newname for datafile 4 to '/u01/ora/app/data/USERS01.DBF';
set newname for datafile 5 to '/u01/ora/app/data/CUBE01.DBF';
set newname for datafile 6 to '/u01/ora/app/data/CUBE02.DBF';
restore database;
switch datafile all;
}
RMAN> recover database;
SQL> alter database open resetlogs;
Database altered.
SQL> select * from v$tempfile;
FILE# CREATION_CHANGE# CREATION_ TS# RFILE# STATUS ENABLED
---------- ---------------- --------- ---------- ---------- ------- ----------
BYTES BLOCKS CREATE_BYTES BLOCK_SIZE
---------- ---------- ------------ ----------
NAME
--------------------------------------------------------------------------------
1 994247 24-FEB-18 3 1 ONLINE READ WRITE
0 0 20971520 8192
C:\DATA\ORADATA\CUBE\TEMP01.DBF
SQL> create temporary tablespace temp1 tempfile '/u01/ora/app/data/temp1.dbf' size 500M;
Tablespace created.
SQL> alter database default temporary tablespace temp1;
Database altered.
SQL> drop tablespace temp including contents;
Tablespace dropped.
SQL> select * from dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME BYTES BLOCKS STATUS
---------- ------------------------------ ---------- ---------- -------
RELATIVE_FNO AUT MAXBYTES MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS
------------ --- ---------- ---------- ------------ ---------- -----------
/u01/ora/app/data/temp1.dbf
2 TEMP1 524288000 64000 ONLINE
1 NO 0 0 0 523239424 63872
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/ora/app/product/11.2.0/dbs/C:DATAORADATACUBEREDO03.LOG
/u01/ora/app/product/11.2.0/dbs/C:DATAORADATACUBEREDO02.LOG
/u01/ora/app/product/11.2.0/dbs/C:DATAORADATACUBEREDO01.LOG
SQL> select group#,thread#,status,sequence# from v$log;
GROUP# THREAD# STATUS SEQUENCE#
---------- ---------- ---------------- ----------
1 1 CURRENT 1
2 1 UNUSED 0
3 1 UNUSED 0
SQL> select group#,thread# from v$log;
GROUP# THREAD#
---------- ----------
1 1
2 1
3 1
SQL> select group#,member from v$logfile;
GROUP#
----------
MEMBER
--------------------------------------------------------------------------------
3
/u01/ora/app/product/11.2.0/dbs/C:DATAORADATACUBEREDO03.LOG
2
/u01/ora/app/product/11.2.0/dbs/C:DATAORADATACUBEREDO02.LOG
1
/u01/ora/app/product/11.2.0/dbs/C:DATAORADATACUBEREDO01.LOG
SQL> alter database add logfile group 4 '/u01/ora/app/data/redo01.log' size 50M;
Database altered.
SQL> alter database add logfile group 5 '/u01/ora/app/data/redo02.log' size 50M;
Database altered.
SQL> alter database add logfile group 6 '/u01/ora/app/data/redo03.log' size 50M;
Database altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 CURRENT
2 UNUSED
3 UNUSED
4 UNUSED
5 UNUSED
6 UNUSED
6 rows selected.
SQL> alter database drop logfile group 2;
Database altered.
SQL> alter database drop logfile group 3;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 ACTIVE
4 CURRENT
5 UNUSED
6 UNUSED
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 ACTIVE
4 CURRENT
5 UNUSED
6 UNUSED
SQL> alter system switch logfile;
System altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 ACTIVE
4 ACTIVE
5 CURRENT
6 UNUSED
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 ACTIVE
4 ACTIVE
5 CURRENT
6 UNUSED
SQL> alter system checkpoint;
System altered.
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 INACTIVE
4 INACTIVE
5 CURRENT
6 UNUSED
SQL> alter database drop logfile group 1;
Database altered.
SQL> conn cube/cube
Connected.
SQL> select count(*) from t1;
COUNT(*)
----------
74511
总结:至此windows 迁移至linux 异机恢复完成。