将文件系统数据库迁移到ASM中
使用裸设备配置ASM实例
http://www.cnblogs.com/myrunning/p/4270849.html
1.查看我们创建的磁盘组
[oracle@std ~]$ export ORACLE_SID=+ASM
[oracle@std ~]$ sqlplus '/as sysdba' SQL*Plus: Release 10.2.0.4. - Production on Mon Feb :: Copyright (c) , , Oracle. All Rights Reserved. Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4. - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> select name,total_mb,free_mb from v$asm_diskgroup; NAME TOTAL_MB FREE_MB
------------------------------ ---------- ----------
DATA
FLA
2.启动数据库实例查看数据文件等
SQL> select * from v$dbfile; FILE# NAME
---------- --------------------------------------------------
/u02/app/oradata/ZDJS/users01.dbf
/u02/app/oradata/ZDJS/sysaux01.dbf
/u02/app/oradata/ZDJS/undotbs01.dbf
/u02/app/oradata/ZDJS/system01.dbf
/u02/app/oradata/ZDJS/example01.dbf
/u02/app/oradata/ZDJS/rlsc01.dbf rows selected. SQL> select file#,name from v$tempfile; FILE# NAME
---------- --------------------------------------------------
/u02/app/oradata/ZDJS/temp01.dbf SQL> show parameter control_ NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer
control_files string /u02/app/oradata/ZDJS/control0
.ctl, /u02/app/oradata/ZDJS/c
ontrol02.ctl, /u02/app/oradata
/ZDJS/control03.ctl
SQL> show parameter spfile NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u02/app/product/10.2./db_1/d
bs/spfileZDJS.ora SQL> select group#,member from v$logfile; GROUP# MEMBER
---------- --------------------------------------------------
/u02/app/oradata/ZDJS/redo03.log
/u02/app/oradata/ZDJS/redo02.log
/u02/app/oradata/ZDJS/redo01.log
3.对RDBMS做一个备份
[oracle@std ~]$ rman target / Recovery Manager: Release 10.2.0.4. - Production on Mon Feb :: Copyright (c) , , Oracle. All rights reserved. connected to target database: ZDJS (DBID=) RMAN> backup as copy database format '+DATA'; Starting backup at -FEB-
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid= devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno= name=/u02/app/oradata/ZDJS/system01.dbf
output filename=+DATA/zdjs/datafile/system.256.870616471 tag=TAG20150202T135428 recid= stamp=
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
channel ORA_DISK_1: starting datafile copy
input datafile fno= name=/u02/app/oradata/ZDJS/undotbs01.dbf
output filename=+DATA/zdjs/datafile/undotbs1.257.870616525 tag=TAG20150202T135428 recid= stamp=
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
channel ORA_DISK_1: starting datafile copy
input datafile fno= name=/u02/app/oradata/ZDJS/sysaux01.dbf
output filename=+DATA/zdjs/datafile/sysaux.258.870616569 tag=TAG20150202T135428 recid= stamp=
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
channel ORA_DISK_1: starting datafile copy
input datafile fno= name=/u02/app/oradata/ZDJS/example01.dbf
output filename=+DATA/zdjs/datafile/example.259.870616605 tag=TAG20150202T135428 recid= stamp=
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
channel ORA_DISK_1: starting datafile copy
input datafile fno= name=/u02/app/oradata/ZDJS/rlsc01.dbf
output filename=+DATA/zdjs/datafile/rlsc.260.870616621 tag=TAG20150202T135428 recid= stamp=
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
channel ORA_DISK_1: starting datafile copy
input datafile fno= name=/u02/app/oradata/ZDJS/users01.dbf
output filename=+DATA/zdjs/datafile/users.261.870616635 tag=TAG20150202T135428 recid= stamp=
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=+DATA/zdjs/controlfile/backup.262.870616639 tag=TAG20150202T135428 recid= stamp=
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece at -FEB-
channel ORA_DISK_1: finished piece at -FEB-
piece handle=+DATA/zdjs/backupset/2015_02_02/nnsnf0_tag20150202t135428_0.263.870616647 tag=TAG20150202T135428 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: ::
Finished backup at -FEB-
4.修改RDBMS参数
SQL> alter system set db_recovery_file_dest_size=3g scope=both; System altered. SQL> alter system set db_recovery_file_dest='+FLA' scope=both; System altered. SQL> alter system set db_create_file_dest='+DATA' scope=both; System altered. SQL> alter system set db_create_online_log_dest_1='+DATA' scope=spfile; System altered.
5.迁移联机日志到ASM磁盘
SQL> select a.group#,a.status,b.member from v$log a,v$logfile b
where a.group#=b.group#; GROUP# STATUS MEMBER
---------- ---------------- --------------------------------------------------
INACTIVE /u02/app/oradata/ZDJS/redo03.log
INACTIVE /u02/app/oradata/ZDJS/redo02.log
CURRENT /u02/app/oradata/ZDJS/redo01.log SQL> alter database add logfile member '+DATA','+FLA' to group ; Database altered. SQL> alter database add logfile member '+DATA','+FLA' to group ; Database altered. SQL> alter database add logfile member '+DATA','+FLA' to group ; Database altered. SQL> select a.group#,a.status,b.member from v$log a,v$logfile b
where a.group#=b.group#; GROUP# STATUS MEMBER
---------- ---------------- --------------------------------------------------
INACTIVE /u02/app/oradata/ZDJS/redo03.log
INACTIVE /u02/app/oradata/ZDJS/redo02.log
CURRENT /u02/app/oradata/ZDJS/redo01.log
CURRENT +DATA/zdjs/onlinelog/group_1.264.870617701
CURRENT +FLA/zdjs/onlinelog/group_1.256.870617713
INACTIVE +DATA/zdjs/onlinelog/group_2.265.870617759
INACTIVE +FLA/zdjs/onlinelog/group_2.257.870617769
INACTIVE +DATA/zdjs/onlinelog/group_3.266.870618057
INACTIVE +FLA/zdjs/onlinelog/group_3.258.870618067 rows selected.
删除原来的状态为INACTIVE的联机日志,通过alter system switch logfile;命令切换日志
SQL> alter database drop logfile member '/u02/app/oradata/ZDJS/redo01.log'; Database altered. SQL> alter database drop logfile member '/u02/app/oradata/ZDJS/redo02.log'; Database altered. SQL> alter database drop logfile member '/u02/app/oradata/ZDJS/redo03.log'; Database altered. SQL> select a.group#,a.status,b.member from v$log a,v$logfile b
where a.group#=b.group# order by group#; GROUP# STATUS MEMBER
---------- ---------------- --------------------------------------------------
CURRENT +DATA/zdjs/onlinelog/group_1.264.870617701
CURRENT +FLA/zdjs/onlinelog/group_1.256.870617713
INACTIVE +DATA/zdjs/onlinelog/group_2.265.870617759
INACTIVE +FLA/zdjs/onlinelog/group_2.257.870617769
INACTIVE +DATA/zdjs/onlinelog/group_3.266.870618057
INACTIVE +FLA/zdjs/onlinelog/group_3.258.870618067 rows selected.
6.迁移临时表空间到ASM磁盘
SQL> select tablespace_name,file_name,bytes// size_m
from dba_temp_files; TABLESPACE_NAME FILE_NAME SIZE_M
-------------------- ---------------------------------------- ----------
TEMP /u02/app/oradata/ZDJS/temp01.dbf SQL> alter tablespace temp add tempfile size 100m; Tablespace altered. SQL> select tablespace_name,file_name,bytes// size_m
from dba_temp_files; TABLESPACE_NAME FILE_NAME SIZE_M
-------------------- ---------------------------------------- ----------
TEMP +DATA/zdjs/tempfile/temp.267.870619111
TEMP /u02/app/oradata/ZDJS/temp01.dbf SQL> alter database tempfile '/u02/app/oradata/ZDJS/temp01.dbf' drop ; Database altered. SQL> select tablespace_name,file_name,bytes// size_m
from dba_temp_files; TABLESPACE_NAME FILE_NAME SIZE_M
-------------------- ---------------------------------------- ----------
TEMP +DATA/zdjs/tempfile/temp.267.870619111
7.迁移控制文件、数据文件到ASM磁盘
在整个迁移过程中,只有这一步需要对数据库实例进行关闭、启动;这一步实际就是一个完全恢复的过程。
SQL> show parameter control NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer
control_files string /u02/app/oradata/ZDJS/control0
.ctl, /u02/app/oradata/ZDJS/c
ontrol02.ctl, /u02/app/oradata
/ZDJS/control03.ctl
SQL> alter system set control_files='+DATA/ZDJS/CONTROLFILE/control01.ctl',
'+DATA/ZDJS/CONTROLFILE/control02.ctl','+DATA/ZDJS/CONTROLFILE/control03.ctl'
scope=spfile; System altered. SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started. Total System Global Area bytes
Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes
把数据库启动到nomount状态后使用rman进行恢复:
[oracle@std ~]$ rman target / Recovery Manager: Release 10.2.0.4. - Production on Mon Feb :: Copyright (c) , , Oracle. All rights reserved. connected to target database: ZDJS (not mounted) RMAN> restore controlfile from '/u02/app/oradata/ZDJS/control01.ctl'; Starting restore at -FEB-
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid= devtype=DISK channel ORA_DISK_1: copied control file copy
output filename=+DATA/zdjs/controlfile/control01.ctl
output filename=+DATA/zdjs/controlfile/control02.ctl
output filename=+DATA/zdjs/controlfile/control03.ctl
Finished restore at -FEB-
使用rman从最近的控制文件直接恢复控制文件,我们使用asmcmd工具确认一下恢复的控制文件是否存在:
ASMCMD> pwd
+DATA/ZDJS/CONTROLFILE
ASMCMD> ls
Backup.262.870616639
control01.ctl
control02.ctl
control03.ctl
current.268.870620187
current.269.870620189
current.270.870620189
mount数据库后使用rman switch数据库:
SQL> alter database mount; Database altered.
[oracle@std ~]$ rman target / Recovery Manager: Release 10.2.0.4. - Production on Mon Feb :: Copyright (c) , , Oracle. All rights reserved. connected to target database: ZDJS (DBID=, not open) RMAN> list copy; using target database control file instead of recovery catalog List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
A -FEB- -FEB- +DATA/zdjs/datafile/system.256.870616471
A -FEB- -FEB- +DATA/zdjs/datafile/undotbs1.257.870616525
A -FEB- -FEB- +DATA/zdjs/datafile/sysaux.258.870616569
A -FEB- -FEB- +DATA/zdjs/datafile/users.261.870616635
A -FEB- -FEB- +DATA/zdjs/datafile/example.259.870616605
A -FEB- -FEB- +DATA/zdjs/datafile/rlsc.260.870616621 List of Control File Copies
Key S Completion Time Ckp SCN Ckp Time Name
------- - --------------- ---------- --------------- ----
A -FEB- -FEB- +DATA/zdjs/controlfile/backup.262.870616639
A -FEB- -FEB- +DATA/zdjs/controlfile/backup.256.870616081 List of Archived Log Copies
Key Thrd Seq S Low Time Name
------- ---- ------- - --------- ----
A -JAN- /u02/ZDJS_ARCH/1_35_869134589.dbf
A -FEB- /u02/ZDJS_ARCH/1_36_869134589.dbf
A -FEB- /u02/ZDJS_ARCH/1_37_869134589.dbf
A -FEB- /u02/ZDJS_ARCH/1_38_869134589.dbf
A -FEB- /u02/ZDJS_ARCH/1_39_869134589.dbf
A -FEB- /u02/ZDJS_ARCH/1_40_869134589.dbf
A -FEB- /u02/ZDJS_ARCH/1_41_869134589.dbf
A -FEB- /u02/ZDJS_ARCH/1_42_869134589.dbf
A -FEB- /u02/ZDJS_ARCH/1_43_869134589.dbf RMAN> switch database to copy;
datafile switched to datafile copy "+DATA/zdjs/datafile/system.256.870616471"
datafile switched to datafile copy "+DATA/zdjs/datafile/undotbs1.257.870616525"
datafile switched to datafile copy "+DATA/zdjs/datafile/sysaux.258.870616569"
datafile switched to datafile copy "+DATA/zdjs/datafile/users.261.870616635"
datafile switched to datafile copy "+DATA/zdjs/datafile/example.259.870616605"
datafile switched to datafile copy "+DATA/zdjs/datafile/rlsc.260.870616621" RMAN> recover database; --切换后现在使用的是磁盘组里的备份文件,所有我们需要进行恢复 Starting recover at -FEB-
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid= devtype=DISK starting media recovery archive log thread sequence is already on disk as file /u02/ZDJS_ARCH/1_35_869134589.dbf
archive log thread sequence is already on disk as file /u02/ZDJS_ARCH/1_36_869134589.dbf
archive log thread sequence is already on disk as file /u02/ZDJS_ARCH/1_37_869134589.dbf
archive log thread sequence is already on disk as file /u02/ZDJS_ARCH/1_38_869134589.dbf
archive log thread sequence is already on disk as file /u02/ZDJS_ARCH/1_39_869134589.dbf
archive log thread sequence is already on disk as file /u02/ZDJS_ARCH/1_40_869134589.dbf
archive log thread sequence is already on disk as file /u02/ZDJS_ARCH/1_41_869134589.dbf
archive log thread sequence is already on disk as file /u02/ZDJS_ARCH/1_42_869134589.dbf
archive log thread sequence is already on disk as file /u02/ZDJS_ARCH/1_43_869134589.dbf
archive log filename=/u02/ZDJS_ARCH/1_35_869134589.dbf thread= sequence=
archive log filename=/u02/ZDJS_ARCH/1_36_869134589.dbf thread= sequence=
archive log filename=/u02/ZDJS_ARCH/1_37_869134589.dbf thread= sequence=
archive log filename=/u02/ZDJS_ARCH/1_38_869134589.dbf thread= sequence=
archive log filename=/u02/ZDJS_ARCH/1_39_869134589.dbf thread= sequence=
archive log filename=/u02/ZDJS_ARCH/1_40_869134589.dbf thread= sequence=
archive log filename=/u02/ZDJS_ARCH/1_41_869134589.dbf thread= sequence=
media recovery complete, elapsed time: ::
Finished recover at -FEB- RMAN> alter database open; database opened
8.验证迁移后的文件
SQL> select * from v$dbfile; FILE# NAME
---------- --------------------------------------------------
+DATA/zdjs/datafile/users.261.870616635
+DATA/zdjs/datafile/sysaux.258.870616569
+DATA/zdjs/datafile/undotbs1.257.870616525
+DATA/zdjs/datafile/system.256.870616471
+DATA/zdjs/datafile/example.259.870616605
+DATA/zdjs/datafile/rlsc.260.870616621 rows selected. SQL> select file#,name from v$tempfile; FILE# NAME
---------- --------------------------------------------------
+DATA/zdjs/tempfile/temp.267.870619111 SQL> show parameter control_ NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer
control_files string +DATA/zdjs/controlfile/control
.ctl, +DATA/zdjs/controlfile
/control02.ctl, +DATA/zdjs/con
trolfile/control03.ctl SQL> select group#,member from v$logfile; GROUP# MEMBER
---------- --------------------------------------------------
+DATA/zdjs/onlinelog/group_1.264.870617701
+FLA/zdjs/onlinelog/group_1.256.870617713
+DATA/zdjs/onlinelog/group_2.265.870617759
+FLA/zdjs/onlinelog/group_2.257.870617769
+DATA/zdjs/onlinelog/group_3.266.870618057
+FLA/zdjs/onlinelog/group_3.258.870618067 rows selected.
#ASM和OS文件系统之间交换可以使用dbms_file_transfer包或rman的convert方法
将文件系统数据库迁移到ASM中的更多相关文章
- 将数据库从普通文件系统迁移到ASM中
数据库存储的是普通的文件系统,现在将数据库迁移到ASM存储中. 准备ASM环境: [oracle@kel ~]$ asmcmd ASMCMD> ls ASM/ KEL/ ASMCMD> 在 ...
- laravel执行数据库迁移的过程中出现Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] Operation timed out (SQL: select * from information_schema.tables where table_schema = shop and table_name = migrations
向customers表添加字段phone php artisan make:migration add_phone_to_customers_table 问题: 解决方法: 将DB_HOST配置项修改 ...
- 使用RMAN迁移文件系统数据库到ASM
--================================== -- 使用RMAN迁移文件系统数据库到ASM --================================== 在实际 ...
- Oracle从文件系统迁移到ASM存储
环境:RHEL 6.4 + Oracle 11.2.0.4 需求:数据库存储由文件系统迁移到ASM 数据库存储迁移到ASM磁盘组 1.1 编辑参数文件指定新的控制文件路径 1.2 启动数据库到nomo ...
- Flask项目中数据库迁移的使用
数据库迁移 在开发过程中,需要修改数据库模型,而且还要在修改之后更新数据库.最直接的方式就是删除旧表,但这样会丢失数据. 更好的解决办法是使用数据库迁移框架,它可以追踪数据库模式的变化,然后把变动应用 ...
- Code First 数据库迁移
当 Entity Framework Code First 的数据模型发生改变时,默认会引发一个System.InvalidOperationException 的异常.解决方法是使用DropCrea ...
- 使用 Code First 数据库迁移
当 Entity Framework Code First 的数据模型发生改变时,默认会引发一个System.InvalidOperationException 的异常.解决方法是使用DropCrea ...
- 2.EF中 Code-First 方式的数据库迁移
原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/code-first-migrations-with-entity-framework/ 系列目 ...
- 如何将已部署在ASM的资源迁移到ARM中
使用过Azure的读者都知道,Azure向客户提供了两个管理portal,一个是ASM,一个是ARM,虽然Azure官方没有宣布说淘汰ASM,两个portal可能会在很长的一段时间共存,但是考虑到AR ...
随机推荐
- LoadRunner检查点学习实例
LoadRunner只会检测脚本中事务的执行状态,而实际的事务执行结果则需要通过检查点来完成. 例如一个登录事务,LR只关心事务本身的执行状态,也就是说哪怕实际操作密码错误产生登录失败的业务操作,其事 ...
- filter应用案例三:解决全站编码问题
1 说明 乱码问题: 获取请求参数中的乱码问题: POST请求:request.setCharacterEncoding("utf-8"): GET请求:new String(re ...
- AOP动态代理解析4-jdk代理的实现
JDKProxy的使用关键是创建自定义的InvocationHandler,而InvocationHandler中包含了需要覆盖的函数getProxy,而当前的方法正是完成了这个操作.在此确认一下JD ...
- BootSrap学习
1.当row1里边有2个或多个col的时候,如果位置在后边的col的高度大于位置在前边的col,就可能会导致下一个row2在满足col-xs-*在满足和为12的情况下错乱分行.解决办法是强行给row1 ...
- css3 -- 伪类与伪元素
伪类: 1.结构伪类 A:E : first-child{} E : nth-*(n){} E : first-*(even){} E : first-*(odd){} B:nth-child 是根 ...
- Linux中cp覆盖不提示
cp覆盖时,无论加什么参数-f之类的还是提示是否覆盖,这在大量cp覆盖操作的时候是不能忍受的. 1. 把a目录下的文件复制到b目录 cp –r a/* b 2. 执行上面的命令时,b存在的每个文件都会 ...
- 贪心 Codeforces Round #287 (Div. 2) A. Amr and Music
题目传送门 /* 贪心水题 */ #include <cstdio> #include <algorithm> #include <iostream> #inclu ...
- 利用Hive实现求两条相邻数据时间差
1.Hive row_number() 函数的高级用法 row_num 按照某个字段分区显示第几条数据 select imei,ts,fuel_instant,gps_longitude,gps_la ...
- BZOJ4568 : [Scoi2016]幸运数字
树的点分治,每次求出重心后,求出重心到每个点路径上的数的线性基. 对于每个询问,只需要暴力合并两个线性基即可. 时间复杂度$O(60n\log n+60^2q)$. #include<cstdi ...
- [转]Mac 科研常用软件
转自:http://bbs.feng.com/read-htm-tid-7698336.html 我的 Mac 是 2012 年的 Pro Retina,现在主要用的是 Mac 系统,Windows ...