资深Oracle数据库专家 OCM认证大师 10年数据库相关服务及开发经验 各类数据库相关方案的编写,管理及实施 数据中心数据库日常运维、大型项目割接、性能优化等方面有丰富的实战经验 客户包括: 电信,银行,保险,航空,国网,汽车,烟草等 想要一起学习探讨数据安全技术的请加qq群 256041954
全部博文(163)
分类: Oracle
2015-01-07 11:26:05
迁移步骤
1. 原端mount NFS (目的是存放备份文件) 172.16.1.1 root2012(哈电ip)
mount -F nfs -o hard,rw,noac,rsize=32768,wsize=32768,suid,proto=tcp,vers=3 192.168.112.2:/SMSdg/bossbackupdata /bossbackupdata
2. 创建pfile文件 create pfile=/opt/oracle/initstarboss1.ora from spfile;
注:将pfile传到目标端后,再根据路径生成spfile
3. 备份数据库:(备份时注意:在全备份之前记录一下max(sequence#),备份全备份之后记录一下max(sequence#))
4. run {
allocate channel t1 type disk;
backup full skip inaccessible tag db_bk_full_20130508 filesperset 15 format '/bossbackupdata/%U_%s-20130508.bak' database ;
backup format '/bossbackupdata/%U_%s_20130508.ctl' current controlfile;
release channel t1;
}
5. 备份完整数据库后备份控制文件:
backup current controlfile format=$ORACLE_HOME/dbs/control01.ctl;
6. 更改pfile中controlfile存放位置为 +BOSSDATA/starboss/controlfile/controlfile01
7. 在目标端恢复控制文件
8. restore controlfile to '+RAC_DB/starboss/controlfile/controlfile01' from ' /bossdata/rmanbackup/controlfile20140420.ctl';
9. Restore数据库 参见恢复服务器上的rman.sh脚本
10. 备份归档日志(查看一下日志组个数,最好多切换几次)
Alter system switch logfile;
Alter system switch logfile;
Alter system switch logfile;
Alter system switch logfile;
11. 查看sequence 语句:
select max(sequence#) from v$archived_log; (结合归档日志文件名)
backup archivelog from sequence 4144 until sequence 94412 thread 1 format ' /bossbackupdata/archive /20130521%U_%s.bak';
9.1 恢复端:
catalog backuppiece '/bossbackupdata/archive/2013052183oa7ial_1_1_9475.bak';
catalog backuppiece '/bossbackupdata/archive/2013052184oa7ial_1_1_9476.bak';
catalog backuppiece '/bossbackupdata/archive/2013052185oa7ial_1_1_9477.bak';
catalog backuppiece '/bossbackupdata/archive/2013052186oa7ial_1_1_9478.bak';
catalog backuppiece '/bossbackupdata/archive/2013052187oa7ial_1_1_9479.bak';
catalog backuppiece '/bossbackupdata/archive/2013052188oa7ial_1_1_9480.bak';
catalog backuppiece '/bossbackupdata/archive/2013052189oa7ial_1_1_9481.bak';
catalog backuppiece '/bossbackupdata/archive/201305218aoa7ial_1_1_9482.bak';
catalog backuppiece '/bossbackupdata/archive/201305218boa7ial_1_1_9483.bak';
catalog backuppiece '/bossbackupdata/archive/201305218coa7ial_1_1_9484.bak';
catalog backuppiece '/bossbackupdata/archive/201305218doa7im3_1_1_9485.bak';
catalog backuppiece '/bossbackupdata/archive/201305218eoa7inh_1_1_9486.bak';
catalog backuppiece '/bossdata/rmanbackup/archlog_91400_91412t845423278_s65020_p1';
在恢复库恢复归档
run{
set archivelog destination to ' +FRA/arch';
restore archivelog from logseq 91285 until logseq 4233;
}
restore archivelog time between "to_date('2014-06-13 10:00:00','yyyy-mm-dd hh24:mi:ss')" and "to_date('2008-08-13 11::00','yyyy-mm-dd hh24:mi:ss')" preview;
run {
set archivelog destination to '/smsdata/oradata/arch';
restore archivelog from time 'sysdate -1';
}
alter system set log_archive_dest_1='location= +fra/arch' scope =both;
12. Recover database
recover database using backup controlfile until cancel;
alter database open resetlogs;
recover database until sequence 34879;
13. 见文档单节点升级Rac
改temp表空间路径,改redo路径,创建线程2 redo,创建undotbs2.
注意:升级前一定要创建临时表空间,否则报错
select member from v$logfile;
select name from v$tempfile;
create temporary tablespace tv_temp tempfile '/bossdata/emp.dbf' size 20480M autoextend on next 500M;
Alter database rename file '/bossdata/Stardb_vodidx/smsstat_temp02.dbf' to '+bossdata/starboss/Stardb_sysdata/temp02.dbf';
Alter database rename file '/bossdata/Stardb_crmdata/smsstat_temp.dbf' to '+bossdata/starboss/Stardb_sysdata/smsstat_temp.dbf';
Alter database rename file '/bossdata/Stardb_pmsdata/TEMP11.dbf' to '+bossdata/starboss/Stardb_sysdata/TEMP11.dbf';
Alter database rename file '/bossdata/Stardb_crmdata/smsstat_temp01.dbf' to '+bossdata/starboss/Stardb_sysdata/smsstat_temp01.dbf ';
Alter database rename file '/bossdata/Stardb_pmsdata/TEMP12.dbf' to '+bossdata/starboss/Stardb_sysdata/TEMP12.dbf ';
Alter database rename file '/bossdata/Stardb_vodidx/smsstat_temp03.dbf' to '+bossdata/starboss/Stardb_sysdata/smsstat_temp03.dbf';
13:2
改变redo 路径
alter database rename file '/bossdata/Redo_log1/redo11.log' to '+bossdata/starboss/Redo_log1/redo11.log';
alter database rename file '/bossdata/Redo_log1/redo12.log' to '+bossdata/starboss/Redo_log2/redo12.log';
alter database rename file '/bossdata/Redo_log1/redo13.log' to '+bossdata/starboss/Redo_log3/redo13.log';
alter database rename file '/bossdata/Redo_log2/redo21.log' to '+bossdata/starboss/Redo_log1/redo21.log';
alter database rename file '/bossdata/Redo_log2/redo22.log' to '+bossdata/starboss/Redo_log2/redo22.log';
alter database rename file '/bossdata/Redo_log2/redo23.log' to '+bossdata/starboss/Redo_log3/redo23.log';
alter database rename file '/bossdata/Redo_log3/redo31.log' to '+bossdata/starboss/Redo_log1/redo31.log';
alter database rename file '/bossdata/Redo_log3/redo32.log' to '+bossdata/starboss/Redo_log2/redo32.log';
alter database rename file '/bossdata/Redo_log3/redo33.log' to '+bossdata/starboss/Redo_log3/redo33.log';
注意:在备份恢复归档日志时,再更改控制文件时后,恢复增量时,会报前期的数据库文件找不到,需要按照下面命令更改数据库文件路径
recover database using backup controlfile until cancel;
14. alter database open resetlogs
15. 升级数据库为10.2.0.5
(1): 启动数据库到UPGRADE模式
Startup upgrade
(2): nohup sqlplus “ /as sysdba” @$ORACLE_HOME/rdbms/admin/catupgrd.sql &
Shutdown immediate;
startup
(3): @?/rdbms/admin/utlrp.sql
16. 单实例升级为RAC
(1):将pfile文件复制到节点二并修改相应的参数
(2):为节点二添加redo
alter database add logfile thread 2
group 4 ('+BOSSDATA/starboss/redo_log1/redo41.log', '+BOSSDATA/starboss/redo_log2/redo42.log') size 600M,
group 5 ('+BOSSDATA/starboss/redo_log2/redo51.log', '+BOSSDATA/starboss/redo_log3/redo52.log') size 600M,
group 6 ('+BOSSDATA/starboss/redo_log3/redo61.log', '+BOSSDATA/starboss/redo_log1/redo62.log') size 600M;
srvctl modify database -d starboss -p '+rac_db/bossdata/spfile/spfilestarboss.ora'
alter database enable public thread 2;
(2):创建2节点undo(只能打开db后创建)
alter database enable thread 2;
(3): create spfile='+bossdata/starboss/parameterfile/spfilestarboss.ora' from pfile='$ORACLE_HOME/dbs/initstarboss.ora';
注意:要使用spfile来启动实例及数据库(重启)
17:如果事先没有dbca创建数据库,然后在目录下rm –rf 方式删除数据库文件的话,需要将资源注册到crs中。
将其他信息注册到CRS里
[oracle@rac1 u01]$ srvctl add database -d anqing -o $ORACLE_HOME -p +DATA/ANQING/PARAMETERFILE/spfileanqing.ora
[oracle@rac1 u01]$ srvctl add instance -d anqing -i anqing1 -n rac1
[oracle@rac1 u01]$ srvctl add instance -d anqing -i anqing2 -n rac2
修改instance 和 asm 之间的依赖关系:
srvctl modify instance -d
[oracle@rac1 u01]$ srvctl modify instance -d anqing -i anqing1 -s +ASM1
[oracle@rac1 u01]$ srvctl modify instance -d anqing -i anqing2 -s +ASM2
17. 升级完成
1:全备份时间:
大约10个小时(备份数据大约600G)
2:恢复时间 大约6个小时
3:恢复增量大约20分钟(归档量大约6G)
4:升级前一定要创建临时表空间,否则报错
create temporary tablespace temp tempfile '+BOSSDATA/Stardb_crmdata/temp01.dbf' size 1000m;
5:注意:在备份恢复归档日志时,再更改控制文件时后,恢复增量时,会报前期的数据库文件找不到,需要按照下面命令更改数据库文件路径
Alter database rename file '/bossdata/Stardb_crmdata/system01.dbf' to '+bossdata/starboss/Stardb_sysdata/system01.dbf';
(所有执行语句见文档)