某客户有套RAC系统,需要一个主机迁移到另一主机,并且要求升级到11.2.0.3。这项任务其实包含了2个工作,迁移和升级。如果单纯的迁移,直接rman过去就好了;如果单纯的升级,其实比较好做,GI可以滚动升级,DB升级需要downtime。但是配合着迁移来做,就要考虑下如何更好的减少downtime。
传统意义上,我们的做法是:
1 2 |
1.先在新机器准备一个和老机器一样的环境(迁移) 2.在新机器升级(GI和DB)(升级) |
实际操作的具体步骤是:
1 2 3 4 5 6 7 8 |
1.1.新机器上安装11.2.0.1的软件(数据库和gi)。 1.2.rman backup老机器的数据库 1.3.将备份集传到新机器 1.4.在新机器上rman restore 1.5.在新机器上做rman recover 1.6.open数据库 2.1.在新机器上升级gi到11.2.0.3 2.2.升级db到11.2.0.3 |
结合生产的停机时间:
1 2 3 4 5 6 7 8 9 10 11 12 |
1.1.新机器上安装11.2.0.1的软件(数据库和gi)。 1.2.rman backup老机器的数据库 1.3.将备份集传到新机器 1.4.在新机器上rman restore 1.5.1在新机器上做rman recover 1.5.2.追加日志,做recover 1.5.3.======>停机窗口开始<======= 1.6.1剩余日志追加,recover,open 1.6.2.create restore point 2.1.升级gi到11.2.0.3 2.2.升级db到11.2.0.3 2.3.======>停机窗口结束<======= |
但是由于在停机窗口需要做2个升级的操作,担心时间有点慢,我们在做如下修改,去掉了升级gi,直接安装11.2.0.3的gi和11.2.0.3的db软件,直接升级数据字典。直接变成rman恢复后的升级:
步骤变为:
1 2 3 4 5 6 7 8 9 10 |
1.1.新机器上直接安装11.2.0.3的软件(数据库和gi)。 1.2.rman backup老机器的数据库 1.3.将备份集传到新机器 1.4.在新机器上rman restore 1.5.1在新机器上做rman recover 1.5.2.追加日志,做recover 1.5.3.======>停机窗口开始<======= 1.6.剩余日志追加,recover,open 2.1.升级db到11.2.0.3 2.2.======>停机窗口结束<======= |
注,在rman备份前,需要在原系统先运行一下pre-upgrade check script,即11.2.0.3软件目录下的$ORACLE_HOME/rdbms/admin/utlu112i.sql
好了,我们现在开始操作。
1.1.新机器上直接安装11.2.0.3的软件(数据库和gi)。
1 |
这个步骤就略了,就是搭建一个11.2.0.3的rac环境而已。 |
1.2.rman backup老机器的数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
RMAN> run{ 2> allocate CHANNEL c1 type DISK; 3> allocate CHANNEL c2 type DISK; 4> allocate CHANNEL c3 type DISK; 5> allocate CHANNEL c4 type DISK; 6> allocate CHANNEL c5 type DISK; 7> BACKUP spfile FORMAT '/u01/ora_install/rman/spfile.rmn'; 8> backup database format '/u01/ora_install/rman/full_%d%t%s%p.rmn' tag 'fullbackup'; 9> BACKUP FORMAT '/u01/ora_install/rman/arch_%d_%s_%p_%h.rmn' ARCHIVELOG ALL; 10> backup format '/u01/ora_install/rman/cfile.rmn' (current controlfile); 11> RELEASE CHANNEL c1; 12> RELEASE CHANNEL c2; 13> RELEASE CHANNEL c3; 14> RELEASE CHANNEL c4; 15> RELEASE CHANNEL c5; 16> } |
1.3.将备份集传到新机器
1 |
略,注意放共享存储上 |
1.4.在新机器上rman restore
1 2 3 4 5 6 |
RMAN> restore spfile from '/u01/ora_install/rman/spfile.rmn'; RMAN> restore controlfile from '/u01/ora_install/rman/cfile.rmn'; --检查controlfile的正在路径,修改restore出来的spfile或pfile, --另外,也注意修改一下spfile或pfile中的相关参数是否符合本机,如*.audit_file_dest路径,如*.db_domain,如*.remote_listener --启动数据库到mount RMAN> restore database; |
1.5.1~1.5.3
1 |
RMAN> recover database; |
1.6.剩余日志追加,recover,open
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
RMAN> alter database open resetlogs ; RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 06/30/2013 20:28:27 ORA-01092: ORACLE instance terminated. Disconnection forced ORA-00704: bootstrap process failure ORA-39700: database must be opened with UPGRADE option Process ID: 3878 Session ID: 1 Serial number: 13 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== ORA-03114: not connected to ORACLE RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 06/30/2013 20:28:27 ORA-01092: ORACLE instance terminated. Disconnection forced ORA-00704: bootstrap process failure ORA-39700: database must be opened with UPGRADE option Process ID: 3878 Session ID: 1 Serial number: 13 [oracle@ol6-112-rac2 ~]$ |
上面的报错没关系,打开不了就是需要升级。
2.1.升级db到11.2.0.3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
--修改初始化参数*.cluster_database=false,不然启动报错ORA-39701: database must be mounted EXCLUSIVE for UPGRADE or DOWNGRADE --注,只需在一个节点启动、执行 SQL> startup upgrade SQL> @?/rdbms/admin/utlu112i.sql SQL> @?/rdbms/admin/catupgrd.sql SQL> @?/rdbms/admin/utlu112s.sql SQL> @?/rdbms/admin/catuppst.sql SQL> @?/rdbms/admin/utlrp --upgrade timezone --全部升级完毕后,将pfile放入到asm和把rac资源加到crs SQL> create spfile='+DATA' from pfile='?/dbs/initRAC1.ora'; [oracle@ol6-112-rac2 dbs]$ cat initRAC2.ora spfile=+DATA/rac/PARAMETERFILE/spfile.336.819670727 --加入到crs [oracle@ol6-112-rac1 dbs]$ srvctl status database -d RAC PRCD-1120 : The resource for database RAC could not be found. PRCR-1001 : Resource ora.rac.db does not exist [oracle@ol6-112-rac1 dbs]$ [oracle@ol6-112-rac1 dbs]$ srvctl add database -d RAC -o $ORACLE_HOME [oracle@ol6-112-rac1 dbs]$ srvctl add instance -d RAC -i RAC1 -n ol6-112-rac1 [oracle@ol6-112-rac1 dbs]$ srvctl add instance -d RAC -i RAC2 -n ol6-112-rac2 [oracle@ol6-112-rac1 dbs]$ srvctl start instance -d RAC -i RAC1 [oracle@ol6-112-rac1 dbs]$ srvctl start instance -d RAC -i RAC2 [oracle@ol6-112-rac1 dbs]$ srvctl status database -d RAC Instance RAC1 is running on node ol6-112-rac1 Instance RAC2 is running on node ol6-112-rac2 [oracle@ol6-112-rac1 dbs]$ |
升级完毕。