11GR2 DATAGUARD环境下的DATABASE升级(11.2.0.2升级到11.2.0.3)(1)

简介:

 

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.升级完成后,做切换测试。

下面是详细的操作步骤
1.安装11.2.0.3的软件。
      这里安装就不写了,主要使用的CLONE方式安装数据库,没有使用relink all方式。
2.RMAN 备份原主库。
   我这里只是测试步骤,所以没有做RMAN的备份。在生产数据库一定记得做RMAN备份,数据重于一切。
3.在备库创建restore point
   为什么在这里就要创建一个restore point呢?主要是预防主备使用了flashback到原来的restore point后,备库也使用flashback到这个restore point,那样,整个DG环境都不用重新搭建。

4 正常关闭主库,启动到mount,创建restore point.

 
  1. 4.1 正常关闭主库
  2. SQL> set lines 100 
  3. #查看数据库的状态。 
  4. #注意这里我启用了flashback 
  5. SQL>  select open_mode,log_mode,switchover_status,database_role,flashback_on from v$database
  6.  
  7. OPEN_MODE            LOG_MODE     SWITCHOVER_STATUS    DATABASE_ROLE    FLASHBACK_ON 
  8. -------------------- ------------ -------------------- ---------------- ------------------ 
  9. READ WRITE           ARCHIVELOG   TO STANDBY           PRIMARY          YES 
  10. #关闭数据库 
  11. SQL> shutdown immediate; 
  12. Database closed. 
  13. Database dismounted. 
  14. ORACLE instance shut down. 
 
  1. 4.2 启动到mount
  2. SQL> startup mount; 
  3. ORACLE instance started. 
  4.  
  5. Total System Global Area  313159680 bytes 
  6. Fixed Size                  2227944 bytes 
  7. Variable Size             255852824 bytes 
  8. Database Buffers           50331648 bytes 
  9. Redo Buffers                4747264 bytes 
  10. Database mounted. 
 
  1. 4.3 创建restore point
  2. SQL> create restore point update_standby_test_1 guarantee flashback database;  
  3.   
  4. Restore point created.  

5. open数据库,切换到physical standby。

 
  1. 5.1 open数据库 
  2. SQL> alter database open
  3.  
  4. Database altered. 
  5. 5.2 切换到physical standby 
  6. SQL> alter database commit to switchover to physical standby with session shutdown; 
  7.  
  8. Database altered. 
  9. 5.3 关闭数据库 
  10. SQL> shutdown immediate; 
  11. ORA-01092: ORACLE instance terminated. Disconnection forced 
  12. SQL> exit 
  13. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production 
  14. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  15. 5.4 启动数据库到open read only 
  16. [oracle@11gdg ~]$ sqlplus / as sysdba 
  17.  
  18. SQL*Plus: Release 11.2.0.2.0 Production on Mon Sep 10 22:44:45 2012 
  19.  
  20. Copyright (c) 1982, 2011, Oracle.  All rights reserved. 
  21.  
  22. Connected to an idle instance. 
  23.  
  24. SQL> startup  
  25. ORACLE instance started. 
  26.  
  27. Total System Global Area  313159680 bytes 
  28. Fixed Size                  2227944 bytes 
  29. Variable Size             255852824 bytes 
  30. Database Buffers           50331648 bytes 
  31. Redo Buffers                4747264 bytes 
  32. Database mounted. 
  33. Database opened. 
  34. 5.5 查询数据库的状态 
  35. SQL> set lines 100 
  36. SQL> select open_mode,log_mode,switchover_status,database_role,flashback_on from v$database
  37.  
  38. OPEN_MODE            LOG_MODE     SWITCHOVER_STATUS    DATABASE_ROLE    FLASHBACK_ON 
  39. -------------------- ------------ -------------------- ---------------- ------------------ 
  40. READ ONLY            ARCHIVELOG   TO PRIMARY           PHYSICAL STANDBY YES 
  41. 已经是physical standby,一切正常 

6 备库切换成主库,创建restore point。

 
  1. 6.1 查看备库的状态 
  2. SQL> set lines 100 
  3. SQL> select open_mode,log_mode,switchover_status,database_role,flashback_on from v$database
  4.  
  5. OPEN_MODE            LOG_MODE     SWITCHOVER_STATUS    DATABASE_ROLE    FLASHBACK_ON 
  6. -------------------- ------------ -------------------- ---------------- ------------------ 
  7. READ ONLY WITH APPLY ARCHIVELOG   TO PRIMARY           PHYSICAL STANDBY YES 
  8. 6.2 创建restore point 
  9. SQL> alter database commit to switchover to primary with session shutdown; 
  10.  
  11. Database altered. 
  12. 6.3 切换成主库 
  13. SQL> alter database commit to switchover to primary with session shutdown; 
  14.  
  15. Database altered. 
  16. 6.4 查看切换后的状态 
  17. SQL> select open_mode,log_mode,switchover_status,database_role,flashback_on from v$database
  18.  
  19. OPEN_MODE            LOG_MODE     SWITCHOVER_STATUS    DATABASE_ROLE    FLASHBACK_ON 
  20. -------------------- ------------ -------------------- ---------------- ------------------ 
  21. MOUNTED              ARCHIVELOG   NOT ALLOWED          PRIMARY          YES 
  22. 6.4  

7 关闭主库,停监听

 
  1. 7.1 修改参数 
  2. #这里配置成defer是为了不让arch日志传到备库去。 
  3. #因为如果在flashback的时候,传这些日志就浪费了。 
  4. SQL> alter system set log_archive_dest_state_2=defer scope=spfile; 
  5.  
  6. System altered. 
  7. 7.2 关闭数据库 
  8. SQL> shutdown abort; 
  9. ORACLE instance shut down. 
  10. 7.3 停监听 
  11. [oracle@11g ~]$ lsnrctl stop 
  12.  
  13. LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 11-SEP-2012 05:27:22 
  14.  
  15. Copyright (c) 1991, 2010, Oracle.  All rights reserved. 
  16.  
  17. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.30)(PORT=1521))) 
  18. The command completed successfully 
  19. [oracle@11g ~]$ ps -ef|grep lsn 
  20. oracle    3853  2734  0 05:27 pts/0    00:00:00 grep lsn 

8 修改ORACLE_HOME与相关的文件

 
  1. 8.1 修改oracle_home 
  2. [oracle@11g ~]$ cat .bash_profile 
  3. # .bash_profile 
  4.  
  5. # Get the aliases and functions 
  6. if [ -f ~/.bashrc ]; then 
  7.         . ~/.bashrc 
  8. fi 
  9.  
  10. User specific environment and startup programs 
  11.  
  12. PATH=$PATH:$HOME/bin 
  13.  
  14. export PATH 
  15. export ORACLE_SID=htz 
  16. export ORACLE_BASE=/u01/app/oracle 
  17. export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_2 
  18. export PATH=$ORACLE_HOME/bin:$PATH 
  19. stty erase ^h 
  20. set -o vi 
  21. export DISPLAY=192.168.100.1:0.0 
  22.  
  23. export SHELL_HOME=$HOME/rs 
  24. export PATH=$PATH:$SHELL_HOME/bin:$SHELL_HOME/dbmonitor:$SHELL_HOME/asm:$SHELL_HOME/rman:$SHELL_HOME/tune:$SHELL_HOME/dump:$SHELL_HOME/event 
  25.  
  26. export TRACE=/u01/app/oracle/diag/rdbms/htz/htz/trace 
  27. [oracle@11g ~]$ . !$ 
  28. 8.2 CP相关的文件 
  29. [oracle@11g ~]$ cp /u01/app/oracle/product/11.2.0/db_1/dbs/* /u01/app/oracle/product/11.2.0/db_2/dbs/ 
  30. [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/ 
  31. 8.3 修改listener.ora文件  
  32. [oracle@11g ~]$ cd $ORACLE_HOME 
  33. [oracle@11g db_2]$ cd network/admin 
  34. [oracle@11g admin]$ cat listener.ora 
  35. SID_LIST_LISTENER = 
  36.   (SID_LIST = 
  37.     (SID_DESC = 
  38.      (GLOBAL_DBNAME = htz) 
  39.      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_2) 
  40.      (SID_NAME = htz) 
  41.     ) 
  42.    ) 
  43.  
  44. LISTENER = 
  45.   (DESCRIPTION = 
  46.     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.30)(PORT = 1521)) 
  47.   )  
  48. 8.4 修改/etc/oratab
  49. [oracle@11g admin]$ tail -1 /etc/oratab
    htz:/u01/app/oracle/product/11.2.0/db_1:N

9 启动数据库,启动监听,运行升级脚本。

 
  1. 9.1 启动监听 
  2. [oracle@11g ~]$ lsnrctl start 
  3.  
  4. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 11-SEP-2012 05:30:07 
  5.  
  6. Copyright (c) 1991, 2011, Oracle.  All rights reserved. 
  7.  
  8. Starting /u01/app/oracle/product/11.2.0/db_2/bin/tnslsnr: please wait... 
  9.  
  10. TNSLSNR for Linux: Version 11.2.0.3.0 - Production 
  11. System parameter file is /u01/app/oracle/product/11.2.0/db_2/network/admin/listener.ora 
  12. Log messages written to /u01/app/oracle/diag/tnslsnr/11g/listener/alert/log.xml 
  13. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.30)(PORT=1521))) 
  14.  
  15. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.30)(PORT=1521))) 
  16. STATUS of the LISTENER 
  17. ------------------------ 
  18. Alias                     LISTENER 
  19. Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production 
  20. Start Date                11-SEP-2012 05:30:07 
  21. Uptime                    0 days 0 hr. 0 min. 0 sec 
  22. Trace Level               off 
  23. Security                  ONLocal OS Authentication 
  24. SNMP                      OFF 
  25. Listener Parameter File   /u01/app/oracle/product/11.2.0/db_2/network/admin/listener.ora 
  26. Listener Log File         /u01/app/oracle/diag/tnslsnr/11g/listener/alert/log.xml 
  27. Listening Endpoints Summary... 
  28.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.30)(PORT=1521))) 
  29. Services Summary... 
  30. Service "htz" has 1 instance(s). 
  31.   Instance "htz", status UNKNOWN, has 1 handler(s) for this service... 
  32. The command completed successfully 
  33. 9.2 启动数据库upgrade 
  34. [oracle@11g ~]$ sqlplus / as sysdba 
  35.  
  36. SQL*Plus: Release 11.2.0.3.0 Production on Tue Sep 11 05:37:57 2012 
  37.  
  38. Copyright (c) 1982, 2011, Oracle.  All rights reserved. 
  39.  
  40. Connected to an idle instance. 
  41.  
  42. SQL> startup upgrade; 
  43. ORACLE instance started. 
  44.  
  45. Total System Global Area  730714112 bytes 
  46. Fixed Size                  2231952 bytes 
  47. Variable Size             658506096 bytes 
  48. Database Buffers           67108864 bytes 
  49. Redo Buffers                2867200 bytes 
  50. Database mounted. 
  51. Database opened. 

 

      本文转自7343696 51CTO博客,原文链接:http://blog.51cto.com/luoping/988073,如需转载请自行联系原作者



相关文章
|
关系型数据库 数据库
|
29天前
|
Oracle 关系型数据库
19c 开启Oracle Database Vault
19c 开启Oracle Database Vault
17 1
|
12天前
|
人工智能 Oracle 关系型数据库
一篇文章弄懂Oracle和PostgreSQL的Database Link
一篇文章弄懂Oracle和PostgreSQL的Database Link
|
29天前
|
SQL Oracle 安全
Oracle Database Vault Access Control Components
Oracle Database Vault Access Control Components
10 0
|
29天前
|
Oracle 安全 关系型数据库
What Is Oracle Database Vault?
The Oracle Database Vault security controls protect application data from unauthorized access, and helps you to comply with privacy and regulatory requirements. You can deploy controls to block privileged account access to application data and control sensitive operations inside the database using
11 0
|
2月前
|
Oracle 关系型数据库 Linux
服务器Centos7 静默安装Oracle Database 12.2
服务器Centos7 静默安装Oracle Database 12.2
100 0
|
5月前
|
Oracle 关系型数据库 数据库
windows Oracle Database 19c 卸载教程
打开任务管理器 ctrl+Shift+Esc可以快速打开任务管理器,找到oracle所有服务然后停止。 停止数据库服务 在开始卸载之前,确保数据库服务已经停止。你可以使用以下命令停止数据库服务: net stop OracleServiceORCL Universal Installer 卸载Oracle数据库程序 一般情况运行Oracle自带的卸载程序,如使用Universal Installer 工具卸载。 点击开始菜单找到Oracle,然后点击Oracle安装产品,再点击Universal Installer。 点击之后稍等一会然后会进入进入下图界面,点击卸载产品。 选中要删除的Orac
131 1
|
6月前
|
存储 Oracle 关系型数据库
windows 使用 Oracle Database 19c
Oracle数据库是由美国Oracle Corporation(甲骨文公司)开发和提供的一种关系型数据库管理系统,它是一种强大的关系型数据库管理系统(RDBMS)。它使用表格(表)组织和存储数据,通过SQL语言进行数据管理。数据以表格形式存储,表之间可以建立关系。支持事务处理、多版本并发控制、安全性和权限控制。具有高可用性、容错性,支持分布式数据库和可扩展性。Oracle Corporation提供全面的支持和服务,使其成为企业级应用的首选数据库系统。
61 0
|
11月前
|
Oracle 关系型数据库 Linux
服务器Centos7 静默安装Oracle Database 12.2(下)
服务器Centos7 静默安装Oracle Database 12.2(下)
244 0

热门文章

最新文章