oracle11g windows迁移至linux

原创cube_six_hujw 最后发布于2018-03-02 11:46:06

概述:跨操作系统平台数据库迁移,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状态:

[[email protected] 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 异机恢复完成。

cube_six_hujw

发布了65 篇原创文章 · 获赞 4 · 访问量 4万+

私信关注

展开阅

原文地址:https://www.cnblogs.com/yaoyangding/p/12221395.html

时间: 2024-10-05 12:30:26

oracle11g windows迁移至linux的相关文章

MySQL数据库从windows迁移到linux

前几天搭建了lamp环境,想把之前写的小东西迁到linux上运行,涉及到把mysql数据库的文件迁移到linux上,直接用fileZilla传过去应该不行,我试了下,反正没成功.下面是我采用的方法: (一)用mysqldump命令导出数据库文件: 在windows下cd到Mysql的bin目录: c:/data.txt这个目录和导出的文本名可以自己随便取,-B 后面的是表名,我要导出的表明叫user.输入密码之后,就可以去保存的目录下看看有没有数据文件了,有的话就成功了,感觉可能失败的地方就是没

Mysql从Windows迁移到Linux,遇到的坑

最近有个项目从Windows上迁移到Linux上,数据库在迁移成功,但是项目无法启动 [BPM] 2018-09-23 17:04:52 ERROR [localhost-startStop-1] ContextLoader.initWebApplicationContext(307) | Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating be

将mysql数据从Windows迁移到Linux中

1.先在windows上将数据都导出一个文件.(这里以某个数据库为例) 导出整个数据库 mysqldump -u 用户名 -p密码 数据库名 > 导出的文件名 导出指定表 mysqldump -u 用户名 -p密码 数据库名 表名1 表名2 ... > 导出的 文件名 2.将数据从Windows拷贝到Linux中. 3.登录Linux的MySql数据库 4.创建与windows同名的数据库名. mysql> create database qt; 查看字符集是否与windows一致,不一

MYSQL大小写(由于数据由windows迁移到Linux导致)

今日从sqlserver上迁移了一个数据库到Linux的MySQL中,迁移成功了,但是应用却跑不通,查看日志发现,提示找不到表,我注意到,表名都是存在大小写的,而MySQL中的表名都是小写的.这提醒了我,莫非MySQL 中表名是大小写敏感的?一查果然如此.解决方案如下: 1.用ROOT登录,修改/etc/my.cnf 2.在[mysqld]下加入一行:lower_case_table_names=1 3.重新启动数据库即可 其中 lower_case_table_names=1 参数缺省地在 W

Windows下Svn服务器迁移至linux

Svn windows迁移至linux 需求:svn服务器从windows系统无缝迁移至linux系统中 实施: 一:准备工作 1,linux服务器一台 2,原svn-windows服务器安装代码及配置文件一份. 二:步骤 01:windows服务器操作 如图为windows svn 服务器图例 查找他的目录地址为:D:\Repositories 因为只有一个项目故进入此项目里找到需要的文件 注释:  conf  为用户账户及密码配置文件 Dav   为web认证文件 Db   为数据文件 Ho

将程序从windows平台迁移到Linux平台

Windows生产环境: OS: Windows 2003 Web服务器:Apache Tomcat/6.0.26 Java虚拟(JVM):1.6.0_10-rc2-b32 程序语言:Java+JSP Linux生产环境: OS: CentOS release 6.7 (Final) Web服务器:Apache Tomcat/7.0.57 Java虚拟(JVM):1.7.0_71-b14 程序语言:Java+JSP 任务:将从Windows平台上的成绩上传监控程序迁移到Linux平台上. 操作务

如何利用mono把.net windows service程序迁移到linux上

How to migrate a .NET Windows Service application to Linux using mono? 写在最前:之所以用要把windows程序迁移到Linux上,主要是由于一些成本问题,这个就不多解释了. 如何把之前用.net写的windows服务程序迁移到linux上运行.答案是有很多种的,今天我只提一下mono(我只实验了mono,呵呵). 如何在Linux部署mono,并成功的运行.net程序,还请大家多多查询吧,我在这方面也只是搭建成功了,遇到的问

从Windows迁移SQL Server到Linux

原文:从Windows迁移SQL Server到Linux 前一篇博客关于SQL Server on Linux的安装,地址:http://www.cnblogs.com/fishparadise/p/8057650.html,现在测试把Windows平台下的一个数据库迁移到Linux平台下. 1. 环境 Windows: Microsoft SQL Server 2008 R2 (SP3) - 10.50.6000.34 (X64) Linux: CentOS 7.4,SQL Server 2

SVN从win迁移到Linux上

工作需要把SVN从win迁移到Linux上,花了几天时间看资料搞定,简单记录一下: 公司用的SVN环境为 Windows server 2003 ,VisualSVN 2.1.5版本 1.dump出SVN数据并上传到Linux 在Repositories处先导出其项目名列表,然后编写一个简单的bat脚本进行dump: 比如: @echo off svnadmin dump C:\Repositories\baijiu > C:/test/baijiu.dump svnadmin dump C:\