一、 更换环境
操作系统:AIX
数据库:10.2.0.4
数据文件存储方式:ASM
二、 前期准备
1、图形界面工具:Xmanager 4
2、确认新存储正常挂载映射,新存储lun划分规则需和当前使用存储一致(ocr、votingdisk所在盘,其他盘可以不一致),被his两台服务器识别。
3、提前格式化一块大盘,做成文件系统,挂载到一个服务器节点,用于存放全备。
注:ocr仲裁盘可在线进行替换,数据盘、归档盘由于使用的asmdg,需停机操作。
三、 规划
名称 原位置 新位置 属组属主权限 权限 大小
DATAVG_0001 /dev/rhdisk11 /dev/rhdiskpower1 oracle dba 660 500G
DATAVG_0002 /dev/rhdisk12 /dev/rhdiskpower2 oracle dba 660 500G
DATAVG_0003 /dev/rhdisk13 /dev/rhdiskpower3 oracle dba 660 500G
fra /dev/rhdisk14 /dev/rhdiskpower4 oracle dba 660 300G
ocr /dev/rhdisk8 /dev/rhdiskpower5 root oinstall 640 1G
ocr /dev/rhdisk21 /dev/rhdiskpower6 root oinstall 640 1G
vote /dev/rhdisk22 /dev/rhdiskpower7 oracle oinstall 644 1G
vote /dev/rhdisk23 /dev/rhdiskpower8 oracle oinstall 644 1G
vote /dev/rhdisk24 /dev/rhdiskpower0 oracle oinstall 644 405G
四、 具体实施步骤
1. 修改新盘权限(root用户修改,每个节点)
chown oracle:dba /dev/rhdiskpower1
chown oracle:dba /dev/rhdiskpower2
chown oracle:dba /dev/rhdiskpower3
chown oracle:dba /dev/rhdiskpower4
chown root:oinstall /dev/rhdiskpower5
chown root:oinstall /dev/rhdiskpower6
chown oracle:oinstall /dev/rhdiskpower7
chown oracle:oinstall /dev/rhdiskpower8
chown oracle:oinstall /dev/rhdiskpower0
chmod 660 /dev/rhdiskpower1
chmod 660 /dev/rhdiskpower2
chmod 660 /dev/rhdiskpower3
chmod 660 /dev/rhdiskpower4
chmod 640 /dev/rhdiskpower5
chmod 640 /dev/rhdiskpower6
chmod 644 /dev/rhdiskpower7
chmod 644 /dev/rhdiskpower8
chmod 644 /dev/rhdiskpower0
确认 ls -l /dev/rhdiskpowe*
2. 全备数据库
nohup /orabak/backup1126/backup.sh &
/orabak/backup1126/backup.sh
#!/usr/bin/ksh
. ~/.profile
/u01/app/oracle/product/10.2.0/db_1/bin/rman target / cmdfile /orabak/backup1126/backup.rcv log=/orabak/backup1126/rmanfull_log.txt
/orabak/backup1126/backup.rcv
run
{
allocate channel c1 type disk;
sql 'alter system archive log current';
backup as backupset database format '/orabak/backup1126/rmanfull_%d_%T_%s_%p.bak' include current controlfile;
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup format '/orabak/backup1126/rmanarch_full%T%U' archivelog all;
backup spfile format '/orabak/backup1126/spfile_%d_%T_%s_%p.bak';
backup current controlfile format '/orabak/backup1126/control_%d_%T_%s_%p.bak';
release channel c1;
}
3.在线更换ocr(su – oracle su root)
1) 确保OCR有最近的备份
A、查看OCR的健康状态
ocrcheck
ocrconfig -showbackup
B、如果没有,手工备份一下
ocrconfig -export /home/oracle/ocrbak.ocr -s online
C、使用OCR备份还原
ocrconfig -import /home/oracle/ocrbak.ocr
D、查看OCR的健康状态
ocrcheck
2) 添加新的OCR盘
该步骤会使用rhdiskpower5覆盖原有镜像rhdisk8
ocrconfig -replace ocrmirror /dev/rhdiskpower5
ocrcheck
3)移除原有OCR盘
该步骤会移除rhdisk4,并且rhdiskpower5成为OCR盘
ocrconfig -replace ocr
ocrcheck
4)添加新的镜像OCR盘
该步骤会使rhdiskpower6盘成为ocrmirror
ocrconfig -replace ocrmirror /dev/rhdiskpower6
ocrcheck
注:移除OCR镜像盘,用不到该命令
ocrconfig -replace ocrmirror
4. 做新的disk group
1) 使用oracle用户登陆Xmanager
2) 打开命令窗口输入oracle用户.profile中的内容后,绝对路径打开dbca
3) 添加新的Disk Group,要与之前对应的DG属性完全一致
创建完新DiskGroup后会自动mount到左右节点
如果没有,选中新DG后单击低下的mount键对新DG进行mount
添加完后:
5.查询并记录数据库失效对象
set linesize 300 pagesize 150;
column owner format a20;
column object_name format a60;
column status format a20;
column object_type format a60;
select owner,object_name,status,object_type from dba_objects where status='INVALID' and owner in ('ZYHIS','ABW','HIS_ADT');
6.更换vote盘
当添加新的vote盘、或者替换时,vote盘的内容自动从备份恢复
添加vote盘时,必须以root用户停止整个集群
1)备份vote盘(备份一份即可,无需全部备份)
dd if=/dev/rhdisk22 of=/home/oracle/votebak6.vote
dd if=/dev/rhdisk23 of=/home/oracle/votebak7.vote
dd if=/dev/rhdisk24 of=/home/oracle/votebak8.vote
2)停止集群
crsctl stop crs
注:所有节点都执行
3)添加vote盘
crsctl add css votedisk /dev/rhdiskpower7 -force
crsctl add css votedisk /dev/rhdiskpower8 -force
crsctl add css votedisk /dev/rhdiskpower0 -force
# crsctl add css votedisk /dev/rhdiskpower7 -force
Now formatting voting disk: /dev/rhdiskpower7
successful addition of votedisk /dev/rhdiskpower7.
# crsctl add css votedisk /dev/rhdiskpower8 -force
Now formatting voting disk: /dev/rhdiskpower8
successful addition of votedisk /dev/rhdiskpower8.
# crsctl add css votedisk /dev/rhdiskpower0 -force
Now formatting voting disk: /dev/rhdiskpower0
successful addition of votedisk /dev/rhdiskpower0.
4)移除原vote盘
crsctl delete css votedisk /dev/rhdisk22 -force
crsctl delete css votedisk /dev/rhdisk23 -force
crsctl delete css votedisk /dev/rhdisk24 -force
5)启动集群
crsctl start crs
所有节点都执行
6)验证当前vote盘路径
crsctl query css votedisk
select name, path, mode_status, state from v$asm_disk order by name;
7)手工启动集群未自启动的服务
srvctl start -d orcl -s orclmz
srvctl start -d orcl -s orclzy
8)检查集群资源状态
crs_stat –t
7.停机,切换redo,备份归档
1) 停机
关闭监听:lsnrctl stop
杀进程LOCAL = NO:
查出并杀掉进程
$ ps -ef | grep LOCAL=NO | more
oracle 208986 1 0 17:15:06 - 0:18 oracleorcl1 (LOCAL=NO)
oracle 467168 1 0 16:43:30 - 0:09 oracleorcl1 (LOCAL=NO)
oracle 552974 1 0 17:16:43 - 0:12 oracleorcl1 (LOCAL=NO)
oracle 606432 1 0 15:43:02 - 0:08 oracleorcl1 (LOCAL=NO)
oracle 618502 1 0 Nov 26 - 0:13 oracleorcl1 (LOCAL=NO)
oracle 622680 1 0 15:59:12 - 0:17 oracleorcl1 (LOCAL=NO)
oracle 639134 1 0 Nov 26 - 0:47 oracleorcl1 (LOCAL=NO)
oracle 688356 1 0 13:58:59 - 0:19 oracleorcl1 (LOCAL=NO)
oracle 708658 1 0 15:08:36 - 0:10 oracleorcl1 (LOCAL=NO)
oracle 716928 1 0 08:56:38 - 0:22 oracleorcl1 (LOCAL=NO)
oracle 725062 1 0 16:53:51 - 0:01 oracleorcl1 (LOCAL=NO)
oracle 790686 1 0 17:17:24 - 0:04 oracleorcl1 (LOCAL=NO)
oracle 806974 1 0 17:03:18 - 0:11 oracleorcl1 (LOCAL=NO)
oracle 839906 1 0 Nov 25 - 0:18 oracleorcl1 (LOCAL=NO)
$ kill -9 208986
1) 所有节点切换redo,确保所有的redo都已经归档
查询redolog日志状态
set pagesize 200;
column TBS_NAME format a20;
c column DBF_NAME format a60;
sselect l.group#,l.THREAD#,l.SEQUENCE#,l.status,l.FIRST_CHANGE#,l.NEXT_CHANGE#,l.NEXT_TIME from v$log l;
Rodo归档命令
alter system archive log current
alter system checkpoint;
3)备份归档日志
nohup /orabak/backup1126/arch_last.sh &
/orabak/backup1126/arch_last.sh
#!/usr/bin/ksh
. ~/.profile
/u01/app/oracle/product/10.2.0/db_1/bin/rman target / cmdfile /orabak/backup1126/arch_last.rcv log=/orabak/backup1126/arch_last.txt
/orabak/backup1126/arch_last.rcv
run
{
allocate channel c1 type disk;
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup format '/orabak/backup1126/Last_rmanarch_full%T%U' archivelog all;
release channel c1;
}
4)查询并记录最后的一个在线日志的时间点
select l.GROUP#,l.THREAD#,l.SEQUENCE#,l.STATUS,to_number(l.FIRST_CHANGE#) "FIRST_CHANGE#",to_char(l.FIRST_TIME,'yyyy/mm/dd hh24:mi:ss') "First_Time" from v$log l order by l.FIRST_CHANGE# desc;
5)查询并记录最后一个归档日志的时间点
column name format a70;
set linesize 300 pagesize 100;
select l.name,l.THREAD#,l.SEQUENCE#,l.FIRST_CHANGE#,to_char(l.FIRST_TIME,'yyyy/mm/dd hh24:mi:ss') "First_Time",l.NEXT_CHANGE#,to_char(l.NEXT_TIME,'yyyy/mm/dd hh24:mi:ss') "Next_Time" from v$archived_log l order by l.FIRST_CHANGE# desc;
8.关闭数据库,dismount原DG
1)使用集群命令关闭数据库
srvctl stop database -d orcl
如果关不了所有节点执行shutdown immediate关闭
2)dismount原DG(一定要确保原DG在所有节点都已经DISMOUNT再进行后续操作)
注:11g通过srvctl命令dismount
此操作所有节点都要做,以下以节点1为例
Export ORACLE_SID=+ASM1
Sqlplus / as sysdba
ALTER DISKGROUP DATAVG DISMOUNT;
ALTER DISKGROUP FRA DISMOUNT;
3)检查确保原DG已经mount
ASMCA图像界面确认
登陆到每个节点通过asmcmd =>lsdg再次确认
9.修改参数文件
1)创建pfile并进行修改
create pfile = '/orabak/initorcl.ora' from spfile;
修改pfile,将其中带原DG的路径换为新DG的路径
修改前后参数文件对比
$ diff initorcl.ora initorcl_change.ora
17c17
< *.control_files='+DATAVG/orcl/control01.ctl','+DATAVG/orcl/control02.ctl','+DATAVG/orcl/control03.ctl'
---
> *.control_files='+NEWDATA/orcl/control01.ctl','+NEWDATA/orcl/control02.ctl','+NEWDATA/orcl/control03.ctl'
22c22
< *.db_file_name_convert='/oradata/standby/','+DATAVG/ORCL/'
---
> *.db_file_name_convert='/oradata/standby/','+NEWDATA/ORCL/'
34c34
< *.log_archive_dest_1='LOCATION=+FRA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl'
---
> *.log_archive_dest_1='LOCATION=+NEWFAR VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl'
40c40
< *.log_file_name_convert='/oradata/standby/','+DATAVG/ORCL/ONLINELOG/'
---
> *.log_file_name_convert='/oradata/standby/','+NEWDATA/ORCL/ONLINELOG/'
2)创建spfile到新DG
create spfile='+NEWDATA' from pfile='/orabak/initorcl_change.ora';
3) 修改pfile,让pfile指向spfile(所有节点都要做,以节点一为例)
vi /u01/app/oracle/product/10.2.0/db_1/dbs/initorcl1.ora
spfile='+NEWDATA/ORCL/PARAMETERFILE/spfile.313.896992587'
4)打开数据库到nomount状态,查看spfile是否指向新DG(所有节点都要做,以节点一为例)
startup nomount
show parameter spfile
10.恢复控制文件
1)恢复控制文件
rman target /
restore controlfile from '/orabak/ctlbackup_c-1282382613-20151128-04';
alter database mount;
2)查询数据文件及redolog位置
rman target /
report schema;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 570 SYSTEM *** +DATAVG/standby/datafile/system.272.802055609
2 2605 UNDOTBS1 *** +DATAVG/standby/datafile/undotbs1.257.802055607
3 1990 SYSAUX *** +DATAVG/standby/datafile/sysaux.258.802055607
4 4705 USERS *** +DATAVG/standby/datafile/users.273.802055609
5 1150 UNDOTBS2 *** +DATAVG/standby/datafile/undotbs2.256.802055609
6 32717 HIS_DATA *** +DATAVG/orcl/datafile/his01.dbf
7 32767 HIS_DATA *** +DATAVG/orcl/datafile/his02.dbf
8 32767 HIS_DATA *** +DATAVG/orcl/datafile/his03.dbf
9 32767 HIS_DATA *** +DATAVG/orcl/datafile/his04.dbf
10 32767 HIS_DATA *** +DATAVG/orcl/datafile/his05.dbf
11 32767 IDXTBS *** +DATAVG/orcl/datafile/idxtbs01.dbf
12 32767 IDXTBS *** +DATAVG/orcl/datafile/idxtbs02.dbf
13 4096 HIS_ADT_SP *** +DATAVG/orcl/datafile/his_adt_sp.dbf
14 4096 LIS_DATA *** +DATAVG/orcl/datafile/lis_data.dbf
15 32767 IDXTBS *** +DATAVG/orcl/datafile/idxtbs03.dbf
16 29564 IDXTBS *** +DATAVG/orcl/datafile/idxtbs04.dbf
17 32761 HIS_DATA *** +DATAVG/orcl/datafile/his06.dbf
18 32767 IDXTBS *** +DATAVG/orcl/datafile/idxtbs05.dbf
19 30720 HIS_DATA *** +DATAVG/orcl/datafile/his07.dbf
20 30720 IDXTBS *** +DATAVG/orcl/datafile/idxtbs06.dbf
21 30720 HIS_DATA *** +DATAVG/orcl/datafile/his08.dbf
22 30720 IDXTBS *** +DATAVG/orcl/datafile/idxtbs07.dbf
23 4096 HIS_ADT_SP *** +DATAVG/orcl/datafile/his_adt_sp02.dbf
24 1024 HIS_ADT_SP *** +DATAVG/orcl/datafile/his_adt_sp.281.894963895
25 4096 HIS_DATA *** +DATAVG/orcl/datafile/his_data.300.894964351
26 512 SYSAUX *** +DATAVG/orcl/datafile/sysaux.301.894964475
27 512 SYSTEM *** +DATAVG/orcl/datafile/system.302.894964533
28 2048 USERS *** +DATAVG/orcl/datafile/users.303.894964571
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 32767 TEMP 32767 +DATAVG/standby/tempfile/temp.287.802083423
sqlplus / as sysdba
SQL> set pagesize 200;
SQL> column TBS_NAME format a20;
SQL> column DBF_NAME format a60;
SQL> select dbf.FILE#,tbs.NAME TBS_NAME,dbf.NAME DBF_NAME from v$tablespace tbs,v$datafile dbf where tbs.TS#=dbf.TS#;
FILE# TBS_NAME
---------- --------------------
DBF_NAME
------------------------------------------------------------
1 SYSTEM
+DATAVG/standby/datafile/system.272.802055609
27 SYSTEM
+DATAVG/orcl/datafile/system.302.894964533
2 UNDOTBS1
+DATAVG/standby/datafile/undotbs1.257.802055607
3 SYSAUX
+DATAVG/standby/datafile/sysaux.258.802055607
26 SYSAUX
+DATAVG/orcl/datafile/sysaux.301.894964475
4 USERS
+DATAVG/standby/datafile/users.273.802055609
28 USERS
+DATAVG/orcl/datafile/users.303.894964571
5 UNDOTBS2
+DATAVG/standby/datafile/undotbs2.256.802055609
9 HIS_DATA
+DATAVG/orcl/datafile/his04.dbf
8 HIS_DATA
+DATAVG/orcl/datafile/his03.dbf
10 HIS_DATA
+DATAVG/orcl/datafile/his05.dbf
6 HIS_DATA
+DATAVG/orcl/datafile/his01.dbf
7 HIS_DATA
+DATAVG/orcl/datafile/his02.dbf
25 HIS_DATA
+DATAVG/orcl/datafile/his_data.300.894964351
21 HIS_DATA
+DATAVG/orcl/datafile/his08.dbf
19 HIS_DATA
+DATAVG/orcl/datafile/his07.dbf
17 HIS_DATA
+DATAVG/orcl/datafile/his06.dbf
18 IDXTBS
+DATAVG/orcl/datafile/idxtbs05.dbf
16 IDXTBS
+DATAVG/orcl/datafile/idxtbs04.dbf
12 IDXTBS
+DATAVG/orcl/datafile/idxtbs02.dbf
15 IDXTBS
+DATAVG/orcl/datafile/idxtbs03.dbf
11 IDXTBS
+DATAVG/orcl/datafile/idxtbs01.dbf
20 IDXTBS
+DATAVG/orcl/datafile/idxtbs06.dbf
22 IDXTBS
+DATAVG/orcl/datafile/idxtbs07.dbf
13 HIS_ADT_SP
+DATAVG/orcl/datafile/his_adt_sp.dbf
24 HIS_ADT_SP
+DATAVG/orcl/datafile/his_adt_sp.281.894963895
23 HIS_ADT_SP
+DATAVG/orcl/datafile/his_adt_sp02.dbf
14 LIS_DATA
+DATAVG/orcl/datafile/lis_data.dbf
28 rows selected.
SQL> select dbf.FILE#,BYTES/1024/1024 "M",tbs.NAME TBS_NAME,dbf.NAME DBF_NAME from v$tablespace tbs,v$tempfile dbf where tbs.TS#=dbf.TS#;
FILE# M TBS_NAME
---------- ---------- --------------------
DBF_NAME
------------------------------------------------------------
1 32767 TEMP
+DATAVG/standby/tempfile/temp.287.802083423
SQL> set linesize 150;
SQL> set pagesize 50;
SQL> column TYPE format a8;
SQL> column MEMBER format a60;
SQL> select lf.GROUP#,l.THREAD#,lf.TYPE,l.BYTES/1024/1024 MB,lf.MEMBER from v$logfile lf,v$log l where lf.GROUP#=l.GROUP#;
GROUP# THREAD# TYPE MB MEMBER
---------- ---------- -------- ---------- ------------------------------------------------------------
1 1 ONLINE 512 +DATAVG/orcl/onlinelog/group_1.279.879447445
2 2 ONLINE 512 +DATAVG/orcl/onlinelog/group_2.277.879447463
3 1 ONLINE 512 +DATAVG/orcl/onlinelog/group_3.278.879447453
4 2 ONLINE 512 +DATAVG/orcl/onlinelog/group_4.276.879447469
5 1 ONLINE 512 +DATAVG/orcl/onlinelog/group_5.296.879447083
6 2 ONLINE 512 +DATAVG/orcl/onlinelog/group_6.297.879447109
7 1 ONLINE 512 +DATAVG/orcl/onlinelog/group_7.298.879447309
8 2 ONLINE 512 +DATAVG/orcl/onlinelog/group_8.299.879447321
11.恢复数据文件
1)恢复数据文件
nohup /orabak/backup1126/restore_db.sh &
/orabak/backup1126/restore_db.sh
#!/usr/bin/ksh
. ~/.profile
/u01/app/oracle/product/10.2.0/db_1/bin/rman target / cmdfile /orabak/backup1126/restore_db.rcv log=/orabak/backup1126/restore_db.txt
/orabak/backup1126/backup.rcv
run
{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
set newname for datafile 1 to '+NEWDATA';
set newname for datafile 2 to '+NEWDATA';
set newname for datafile 3 to '+NEWDATA';
set newname for datafile 4 to '+NEWDATA';
set newname for datafile 5 to '+NEWDATA';
set newname for datafile 6 to '+NEWDATA';
set newname for datafile 7 to '+NEWDATA';
set newname for datafile 8 to '+NEWDATA';
set newname for datafile 9 to '+NEWDATA';
set newname for datafile 10 to '+NEWDATA';
set newname for datafile 11 to '+NEWDATA';
set newname for datafile 12 to '+NEWDATA';
set newname for datafile 13 to '+NEWDATA';
set newname for datafile 14 to '+NEWDATA';
set newname for datafile 15 to '+NEWDATA';
set newname for datafile 16 to '+NEWDATA';
set newname for datafile 17 to '+NEWDATA';
set newname for datafile 18 to '+NEWDATA';
set newname for datafile 19 to '+NEWDATA';
set newname for datafile 20 to '+NEWDATA';
set newname for datafile 21 to '+NEWDATA';
set newname for datafile 22 to '+NEWDATA';
set newname for datafile 23 to '+NEWDATA';
set newname for datafile 24 to '+NEWDATA';
set newname for datafile 25 to '+NEWDATA';
set newname for datafile 26 to '+NEWDATA';
set newname for datafile 27 to '+NEWDATA';
set newname for datafile 28 to '+NEWDATA';
restore database;
switch datafile all;
release channel c1;
release channel c2;
release channel c3;
}
2)修改控制文件中redolog路径(注意一定要指定到新盘的确切路径下)
alter database rename file '+DATAVG/orcl/onlinelog/group_1.299.896932437' to '+NEWDATA/orcl/onlinelog/group_1';
alter database rename file '+DATAVG/orcl/onlinelog/group_3.297.896932441' to '+NEWDATA/orcl/onlinelog/group_3';
alter database rename file '+DATAVG/orcl/onlinelog/group_2.298.896932439' to '+NEWDATA/orcl/onlinelog/group_2';
alter database rename file '+DATAVG/orcl/onlinelog/group_4.296.896932443' to '+NEWDATA/orcl/onlinelog/group_4';
alter database rename file '+DATAVG/orcl/onlinelog/group_5.276.896932445' to '+NEWDATA/orcl/onlinelog/group_5';
alter database rename file '+DATAVG/orcl/onlinelog/group_6.277.896932445' to '+NEWDATA/orcl/onlinelog/group_6';
alter database rename file '+DATAVG/orcl/onlinelog/group_7.278.896932447' to '+NEWDATA/orcl/onlinelog/group_7';
alter database rename file '+DATAVG/orcl/onlinelog/group_8.279.896932449' to '+NEWDATA/orcl/onlinelog/group_8';
alter database rename file '+DATAVG/orcl/onlinelog/group_21.286.879451249' to '+NEWDATA/orcl/onlinelog/group_21';
alter database rename file '+DATAVG/orcl/onlinelog/group_22.285.879451285' to '+NEWDATA/orcl/onlinelog/group_22';
alter database rename file '+DATAVG/orcl/onlinelog/group_23.284.879451325' to '+NEWDATA/orcl/onlinelog/group_23';
alter database rename file '+DATAVG/orcl/onlinelog/group_24.283.879451333' to '+NEWDATA/orcl/onlinelog/group_24';
alter database rename file '+DATAVG/orcl/onlinelog/group_25.282.879451339' to '+NEWDATA/orcl/onlinelog/group_25';
3)将关库时备份出的归档注册到控制文件中
catalog start with ‘/orabak/backup1126/’;
4)查看所有数据文件scn号,是否一致
set numwidth 20
select checkpoint_change#,file# from v$datafile_header;
5)跑归档恢复数据库
nohup /orabak/backup1126/restor_arch.sh &
/orabak/backup1126/restor_arch.sh
#!/usr/bin/ksh
. ~/.profile
/u01/app/oracle/product/10.2.0/db_1/bin/rman target / cmdfile /orabak/backup1126/restor_arch.rcv log=/orabak/backup1126/restor_arch.txt
/orabak/backup1126/restor_arch.rcv
run
{
ALLOCATE CHANNEL disk1 DEVICE TYPE disk;
recover database;
release channel disk1;
}
6)查看所有数据文件scn号,是否一致
set numwidth 20
select checkpoint_change#,file# from v$datafile_header;
7)对应数据文件SCN号查看日志文件,确认恢复的时间点(与关库时间点对应)
归档备份查看
list backup of archivelog all;
归档日志SCN号及对应时间
column name format a70;
set linesize 300 pagesize 100;
select l.name,l.THREAD#,l.SEQUENCE#,l.FIRST_CHANGE#,to_char(l.FIRST_TIME,'yyyy/mm/dd hh24:mi:ss') "First_Time",l.NEXT_CHANGE#,to_char(l.NEXT_TIME,'yyyy/mm/dd hh24:mi:ss') "Next_Time" from v$archived_log l order by l.FIRST_CHANGE# desc;
8)再次查询数据文件和redolog位置
set pagesize 200;
column TBS_NAME format a20;
column DBF_NAME format a60;
select dbf.FILE#,tbs.NAME TBS_NAME,dbf.NAME DBF_NAME from v$tablespace tbs,v$datafile dbf where tbs.TS#=dbf.TS#;
select dbf.FILE#,BYTES/1024/1024 "M",tbs.NAME TBS_NAME,dbf.NAME DBF_NAME from v$tablespace tbs,v$tempfile dbf where tbs.TS#=dbf.TS#;
set linesize 150;
set pagesize 50;
column TYPE format a8;
column MEMBER format a60;
select lf.GROUP#,l.THREAD#,lf.TYPE,l.BYTES/1024/1024 MB,lf.MEMBER from v$logfile lf,v$log l where lf.GROUP#=l.GROUP#;
9)确认数据恢复时间点没问题后,打开数据库(两个节点都要做)
alter database open;
alter database open resetlogs;
12.后续操作
1)替换tempfile
alter tablespace temp add tempfile '+NEWDATA' size 32767M autoextend off;
alter tablespace temp drop tempfile '+DATAVG/standby/tempfile/temp.287.802083423';
select dbf.FILE#,BYTES/1024/1024 "M",tbs.NAME TBS_NAME,dbf.NAME DBF_NAME from v$tablespace tbs,v$tempfile dbf where tbs.TS#=dbf.TS#;
2)修改归档路径到新盘
archive log list;
alter system set LOG_ARCHIVE_DEST_1='LOCATION=+NEWFAR';
archive log list;
3)检查数据库失效对象
查询数据库失效对象,并比对与关库前是否一致
set linesize 300 pagesize 150;
column owner format a20;
column object_name format a60;
column status format a20;
column object_type format a60;
select owner,object_name,status,object_type from dba_objects where status='INVALID' and owner in ('ZYHIS','ABW','HIS_ADT');
4)验证日志是否可用
select * from v$log;
create table t as select * from dbs_objects;
alter system archive log current;
alter system checkpoint;
5)集群层面验证集群所有服务是否正常开启
crs_stat –t –v
crs_stat
crsctl stat res –t
可能会用到的操作
srvctl start service -d orcl -s orclmz
srvctl start service -d orcl -s orclzy
阅读(3359) | 评论(0) | 转发(2) |