ITPub博客

首页 > 数据库 > Oracle > 数据库迁移至+ASM中

数据库迁移至+ASM中

Oracle 作者:zhengbao_jun 时间:2015-05-21 09:28:30 0 删除 编辑
环境描述
RAC使用的主机3台 os version   redhat as 6.2
cluster和database version     11.2.0.3


一.使用os的udev命令标识asm使用的磁盘文件
vi /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd*", SUBSYSTEM=="block", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36005076802810c1a5800000000000008", NAME="asm_a1_ocr1",  OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", SUBSYSTEM=="block", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36005076802810c1a5800000000000009", NAME="asm_a1_ocr2",  OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", SUBSYSTEM=="block", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36005076802810c1a580000000000000a", NAME="asm_a1_ocr3",  OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", SUBSYSTEM=="block", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36005076802810c1a580000000000000c", NAME="asm_a1_disk1",  OWNER="grid",  GROUP="asmadmin", MODE="0660"


--重新启动udev
/sbin/start_udev


二.创建磁盘组
    --以sysasm身份登陆创建磁盘组
    create diskgroup ocr external redundancy disk  '/dev/asm_a1_ocr1' attribute 'compatible.asm'='11.2';
    create diskgroup pay external redundancy disk  '/dev/asm_a1_disk1';
    --修改asm的属性(如果创建磁盘组的时候未加asm属性)
    alter diskgroup ocr set attribute 'COMPATIBLE.ASM'='11.2';
    --查看磁盘组
    select name,total_mb,free_mb,COMPATIBILITY,state from  v$asm_diskgroup;


    --在cluster的所有节点上启动创建的新磁盘组
    srvctl start diskgroup -g ocr 
    srvctl start diskgroup -g pay
    --检查cluster资源状态(以oracle用户执行)
    crsctl status resource -t
    crsctl status resource -t


三.以root用户换ocr
    --先增加一个镜像磁盘组,然后删除原来的磁盘组
    /oracle/11.2.0/grid/bin/ocrconfig -add +OCR
    /oracle/11.2.0/grid/bin/ocrconfig -delete +ocr_vote_pay1
    --检查ocr
    /oracle/11.2.0/grid/bin/ocrcheck


四.以grid用户换votedisk
    crsctl query css votedisk
    crsctl replace votedisk +OCR


五.更换asm实例的spfile
    --整个cluster最好只启动一个节点,将其它节点的cluster关闭(以root用户)
    /oracle/11.2.0/grid/bin/crsctl stop crs
    --更换asm实例的spfile
    create pfile='/tmp/initasm1.ora' from spfile;
    startup pfile='/oracle/11.2.0/grid/dbs/initasm1.ora'
    create spfile='+OCR' from pfile='/tmp/initasm1.ora';
    --重新启动本节点的高可用服务
    /oracle/11.2.0/grid/bin/crsctl stop has
    /oracle/11.2.0/grid/bin/crsctl start has


/***
如果没有关闭其他节点的cluster,那么更新asm的spfile文件时会报以下错误
SQL> create spfile='+OCR' from pfile='/oracle/11.2.0/grid/dbs/initasm.ora';
create spfile='+OCR' from pfile='/oracle/11.2.0/grid/dbs/initasm.ora'
*
ERROR at line 1:
ORA-29783: GPnP attribute SET failed with error [CLSGPNP_NOT_FOUND]


根据metalink解释:此问题还有另外一种解决方法:就是杀死不健康的gpnpd.bin进程,然GI自动重启动此进程.
***/


六.更换数据库的spfile 
    --生成临时的pfile文件
    create pfile='/tmp/initpay.ora' from spfile;
    --在新的磁盘组上创建spfile文件
    create spfile ='+PAY' from pfile='/tmp/initpay.ora';
    --修改cluster配置文件中的参数文件位置
    srvctl config database -d pay
    --spfile的具体位置可以使用asmcmd命令查看
    srvctl modify database -d pay -p +PAY/PAY/PARAMETERFILE/spfile.288.824166281'


七.更换数据库的磁盘组
--1.查询表空间及其数据文件
set linesize 300
col fname format A60
select ts.name tname,df.file#,df.name fname from v$tablespace ts,v$datafile df
 where ts.ts#=df.ts# order by 1;


--2.更换数据库非系统使用的磁盘组(system/sysaux/undo)[更换时,数据库可以是open状态]
sql 'alter tablespace USERS offline';
backup device type disk as copy datafile 5 format '+PAY';
switch tablespace USERS  to copy;
sql 'alter tablespace USERS online';


--3.更换数据库系统使用的磁盘组(system/sysaux/undo)[更换时,数据库不允许为open状态]
--先建立数据文件映像副本
backup as copy tablespace system format '+PAY';
backup as copy tablespace sysaux format '+PAY';
backup as copy tablespace UNDOTBS1 format '+PAY';
backup as copy tablespace UNDOTBS2 format '+PAY';
backup as copy tablespace UNDOTBS3 format '+PAY';
--启动数据库到mount
shutdown immediate; 
startup mount; 
--切换表空间数据文件到映像副本
switch tablespace system to copy; 
switch tablespace sysaux to copy; 
switch tablespace UNDOTBS1 to copy; 
switch tablespace UNDOTBS2 to copy; 
switch tablespace UNDOTBS3 to copy; 
--恢复数据库
recover database;
--打开数据库
alter database open;


--4.更换临时文件
alter tablespace temp add tempfile '+PAY';
alter tablespace temp drop tempfile '+PAY/pay/tempfile/temp.274.824146081';


--5.更换redo log
--查看重做日志组和成员
select * from v$Logfile order by group#;
select * from v$Log;
--增加重做日志成员
alter database add logfile member '+PAY' to group 1;
alter database add logfile member '+PAY' to group 2;
alter database add logfile member '+PAY' to group 3;
alter database add logfile member '+PAY' to group 4;
alter database add logfile member '+PAY' to group 5;
alter database add logfile member '+PAY' to group 6;
alter database add logfile member '+PAY' to group 7;
alter database add logfile member '+PAY' to group 8;
alter database add logfile member '+PAY' to group 9;
--删除旧的重做日志成员
alter database drop logfile member '+PAY_TMP/pay/onlinelog/group_7.263.820542373';
alter database drop logfile member '+PAY_TMP/pay/onlinelog/group_2.262.820542367';
alter database drop logfile member '+PAY_TMP/pay/onlinelog/group_1.261.820542365';
alter database drop logfile member '+PAY_TMP/pay/onlinelog/group_5.267.820542451';
alter database drop logfile member '+PAY_TMP/pay/onlinelog/group_6.268.820542453';
alter database drop logfile member '+PAY_TMP/pay/onlinelog/group_9.269.820542459';
alter database drop logfile member '+PAY_TMP/pay/onlinelog/group_3.270.820542463';
alter database drop logfile member '+PAY_TMP/pay/onlinelog/group_4.271.820542465';
alter database drop logfile member '+PAY_TMP/pay/onlinelog/group_8.272.820542467';


--6.更换control file
--更新spfile中的control_file参数
alter system set control_files='+PAY_TMP/trade/controlfile/control01.ctl','+TRADE' scope=spfile sid='*';
--重新启动数据库
shutdown immediate;
startup nomount;
--使用rman创建新的控制文件
RMAN> connect target /
RMAN> restore controlfile from '+PAY_TMP/trade/controlfile/control01.ctl';
--更新spfile中的control_file参数
alter system set control_files='+TRADE/trade/controlfile/current.275.824169817' scope=spfile sid='*';


八.下线旧的磁盘组
--1.旧的磁盘足离线
srvctl stop diskgroup -g PAY_TMP
跟踪一段时间如果确实没有问题再进行离线操作
--2.仅仅在一个asm实例上mount磁盘组
--mount要离线的磁盘组
alter diskgroup PAY_TMP mount;
--删除磁盘组
drop diskgroup PAY_TMP including contents;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/235507/viewspace-1664892/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-08-08

  • 博文量
    209
  • 访问量
    864904