11GR2 DATAGUARD环境下的DATABASE升级(11.2.0.2升级到11.2.0.3)(1)
http://luoping.blog.51cto.com/534596/988073
11GR2 DATAGUARD环境下的DATABASE升级(11.2.0.2升级到11.2.0.3)(2)
http://luoping.blog.51cto.com/534596/988108
11GR2 DATAGUARD环境下的DATABASE升级(11.2.0.2升级到11.2.0.3)(3)
http://luoping.blog.51cto.com/534596/988024
今天主要测试是11GR2 PHYSICAL STANDBY DATABAES环境下面的数据库升级,从11.2.0.2升级到11.2.0.3。在DG环境下面的升级方法有很多.如:
1,升级主库,主库完成后再RECOVER备库。
2,把PHYSICAL转临时的逻辑备库,升级逻辑备库后,切换,再RECOVER原主库。
这里我采用的是第1种方式,这个在10G中也是最常用的升级方法。不过我这里的主库,不是正式运行的主库,而是在升级前做了一次切换,把备库变成主备的,是为了确保原主库在升级失败后,可以快速的还原(使用flashback方法),减少停机时机。在整个升级过程中,备库是一直对外提供读的服务。
本次只是测试环境测试,千万不能用于生产环境。因为有很多地方没有考虑周到的,比如在切换的时候没有考虑是否有大事务这些在运行,升级前的无效对象检查等。
测试环境:OS RHEL 5.6 X86_64 ,DB 11.2.0.2 11.2.0.3
升级步骤
1.安装11.2.0.3的软件。
2.RMAN备份原主库。
3.在备库创建restore point。
4.正常关闭主库,启动到mount,创建restore point.
5.open数据库,切换到physical standby。
6.备库切换成主库,创建restore point。
7.关闭主库,停监听。
8.修改主库上的ORACLE_HOME与相关的文件。
9.启动数据库,启动监听,运行升级脚本。
10.关闭备库与停监听
11.修改备库的ORACLE_HOME与相关文件
12.启动到mount与recover数据库
13.升级完成后,做切换测试。
4 正常关闭主库,启动到mount,创建restore point.
- 4.1 正常关闭主库
- SQL> set lines 100
- #查看数据库的状态。
- #注意这里我启用了flashback
- SQL> select open_mode,log_mode,switchover_status,database_role,flashback_on from v$database;
- OPEN_MODE LOG_MODE SWITCHOVER_STATUS DATABASE_ROLE FLASHBACK_ON
- -------------------- ------------ -------------------- ---------------- ------------------
- READ WRITE ARCHIVELOG TO STANDBY PRIMARY YES
- #关闭数据库
- SQL> shutdown immediate;
- Database closed.
- Database dismounted.
- ORACLE instance shut down.
- 4.2 启动到mount
- SQL> startup mount;
- ORACLE instance started.
- Total System Global Area 313159680 bytes
- Fixed Size 2227944 bytes
- Variable Size 255852824 bytes
- Database Buffers 50331648 bytes
- Redo Buffers 4747264 bytes
- Database mounted.
- 4.3 创建restore point
- SQL> create restore point update_standby_test_1 guarantee flashback database;
- Restore point created.
5. open数据库,切换到physical standby。
- 5.1 open数据库
- SQL> alter database open;
- Database altered.
- 5.2 切换到physical standby
- SQL> alter database commit to switchover to physical standby with session shutdown;
- Database altered.
- 5.3 关闭数据库
- SQL> shutdown immediate;
- ORA-01092: ORACLE instance terminated. Disconnection forced
- SQL> exit
- Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- 5.4 启动数据库到open read only
- [oracle@11gdg ~]$ sqlplus / as sysdba
- SQL*Plus: Release 11.2.0.2.0 Production on Mon Sep 10 22:44:45 2012
- Copyright (c) 1982, 2011, Oracle. All rights reserved.
- Connected to an idle instance.
- SQL> startup
- ORACLE instance started.
- Total System Global Area 313159680 bytes
- Fixed Size 2227944 bytes
- Variable Size 255852824 bytes
- Database Buffers 50331648 bytes
- Redo Buffers 4747264 bytes
- Database mounted.
- Database opened.
- 5.5 查询数据库的状态
- SQL> set lines 100
- SQL> select open_mode,log_mode,switchover_status,database_role,flashback_on from v$database;
- OPEN_MODE LOG_MODE SWITCHOVER_STATUS DATABASE_ROLE FLASHBACK_ON
- -------------------- ------------ -------------------- ---------------- ------------------
- READ ONLY ARCHIVELOG TO PRIMARY PHYSICAL STANDBY YES
- 已经是physical standby,一切正常
6 备库切换成主库,创建restore point。
- 6.1 查看备库的状态
- SQL> set lines 100
- SQL> select open_mode,log_mode,switchover_status,database_role,flashback_on from v$database;
- OPEN_MODE LOG_MODE SWITCHOVER_STATUS DATABASE_ROLE FLASHBACK_ON
- -------------------- ------------ -------------------- ---------------- ------------------
- READ ONLY WITH APPLY ARCHIVELOG TO PRIMARY PHYSICAL STANDBY YES
- 6.2 创建restore point
- SQL> alter database commit to switchover to primary with session shutdown;
- Database altered.
- 6.3 切换成主库
- SQL> alter database commit to switchover to primary with session shutdown;
- Database altered.
- 6.4 查看切换后的状态
- SQL> select open_mode,log_mode,switchover_status,database_role,flashback_on from v$database;
- OPEN_MODE LOG_MODE SWITCHOVER_STATUS DATABASE_ROLE FLASHBACK_ON
- -------------------- ------------ -------------------- ---------------- ------------------
- MOUNTED ARCHIVELOG NOT ALLOWED PRIMARY YES
- 6.4
7 关闭主库,停监听
- 7.1 修改参数
- #这里配置成defer是为了不让arch日志传到备库去。
- #因为如果在flashback的时候,传这些日志就浪费了。
- SQL> alter system set log_archive_dest_state_2=defer scope=spfile;
- System altered.
- 7.2 关闭数据库
- SQL> shutdown abort;
- ORACLE instance shut down.
- 7.3 停监听
- [oracle@11g ~]$ lsnrctl stop
- LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 11-SEP-2012 05:27:22
- Copyright (c) 1991, 2010, Oracle. All rights reserved.
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.30)(PORT=1521)))
- The command completed successfully
- [oracle@11g ~]$ ps -ef|grep lsn
- oracle 3853 2734 0 05:27 pts/0 00:00:00 grep lsn
8 修改ORACLE_HOME与相关的文件
- 8.1 修改oracle_home
- [oracle@11g ~]$ cat .bash_profile
- # .bash_profile
- # Get the aliases and functions
- if [ -f ~/.bashrc ]; then
- . ~/.bashrc
- fi
- # User specific environment and startup programs
- PATH=$PATH:$HOME/bin
- export PATH
- export ORACLE_SID=htz
- export ORACLE_BASE=/u01/app/oracle
- export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_2
- export PATH=$ORACLE_HOME/bin:$PATH
- stty erase ^h
- set -o vi
- export DISPLAY=192.168.100.1:0.0
- export SHELL_HOME=$HOME/rs
- export PATH=$PATH:$SHELL_HOME/bin:$SHELL_HOME/dbmonitor:$SHELL_HOME/asm:$SHELL_HOME/rman:$SHELL_HOME/tune:$SHELL_HOME/dump:$SHELL_HOME/event
- export TRACE=/u01/app/oracle/diag/rdbms/htz/htz/trace
- [oracle@11g ~]$ . !$
- 8.2 CP相关的文件
- [oracle@11g ~]$ cp /u01/app/oracle/product/11.2.0/db_1/dbs/* /u01/app/oracle/product/11.2.0/db_2/dbs/
- [oracle@11g ~]$ cp -r /u01/app/oracle/product/11.2.0/db_1/network/admin/* /u01/app/oracle/product/11.2.0/db_2/network/admin/
- 8.3 修改listener.ora文件
- [oracle@11g ~]$ cd $ORACLE_HOME
- [oracle@11g db_2]$ cd network/admin
- [oracle@11g admin]$ cat listener.ora
- SID_LIST_LISTENER =
- (SID_LIST =
- (SID_DESC =
- (GLOBAL_DBNAME = htz)
- (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_2)
- (SID_NAME = htz)
- )
- )
- LISTENER =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.30)(PORT = 1521))
- )
- 8.4 修改/etc/oratab
- [oracle@11g admin]$ tail -1 /etc/oratab
htz:/u01/app/oracle/product/11.2.0/db_1:N
9 启动数据库,启动监听,运行升级脚本。
- 9.1 启动监听
- [oracle@11g ~]$ lsnrctl start
- LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 11-SEP-2012 05:30:07
- Copyright (c) 1991, 2011, Oracle. All rights reserved.
- Starting /u01/app/oracle/product/11.2.0/db_2/bin/tnslsnr: please wait...
- TNSLSNR for Linux: Version 11.2.0.3.0 - Production
- System parameter file is /u01/app/oracle/product/11.2.0/db_2/network/admin/listener.ora
- Log messages written to /u01/app/oracle/diag/tnslsnr/11g/listener/alert/log.xml
- Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.30)(PORT=1521)))
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.30)(PORT=1521)))
- STATUS of the LISTENER
- ------------------------
- Alias LISTENER
- Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
- Start Date 11-SEP-2012 05:30:07
- Uptime 0 days 0 hr. 0 min. 0 sec
- Trace Level off
- Security ON: Local OS Authentication
- SNMP OFF
- Listener Parameter File /u01/app/oracle/product/11.2.0/db_2/network/admin/listener.ora
- Listener Log File /u01/app/oracle/diag/tnslsnr/11g/listener/alert/log.xml
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.30)(PORT=1521)))
- Services Summary...
- Service "htz" has 1 instance(s).
- Instance "htz", status UNKNOWN, has 1 handler(s) for this service...
- The command completed successfully
- 9.2 启动数据库upgrade
- [oracle@11g ~]$ sqlplus / as sysdba
- SQL*Plus: Release 11.2.0.3.0 Production on Tue Sep 11 05:37:57 2012
- Copyright (c) 1982, 2011, Oracle. All rights reserved.
- Connected to an idle instance.
- SQL> startup upgrade;
- ORACLE instance started.
- Total System Global Area 730714112 bytes
- Fixed Size 2231952 bytes
- Variable Size 658506096 bytes
- Database Buffers 67108864 bytes
- Redo Buffers 2867200 bytes
- Database mounted.
- Database opened.
本文转自7343696 51CTO博客,原文链接:http://blog.51cto.com/luoping/988073,如需转载请自行联系原作者