四. 升级实例
升级实例有两种方法:
1. DBUA
2. 手动执行脚本
4.1 用脚本升级
After you install the patch set, you must perform the following steps on every database associated with the upgraded Oracle home:
Note:
If you do not run the catupgrd.sql script as described in this section and you start up a database for normal operation, then ORA-01092: ORACLE instance terminated. Disconnection forced errors will occur and the error ORA-39700: database must be opened with UPGRADE option will be in the alert log.
Log in as the Oracle software owner user.
For Oracle RAC installations, start listener on each node of the cluster as follows:
$ srvctl start listener -n node
If you are using Automatic Storage Management, start the Automatic Storage Management instance.
For Oracle RAC installations:
Use SQL*Plus to log in to the database as the SYS user with SYSDBA privileges:
$ sqlplus /nolog
SQL> CONNECT SYS AS SYSDBA
Enter password: SYS_password
SQL> STARTUP NOMOUNT
Set the CLUSTER_DATABASE initialization parameter to FALSE:
SQL> ALTER SYSTEM SET CLUSTER_DATABASE=FALSE SCOPE=spfile;
Shut down the database:
SQL> SHUTDOWN
Enter the following SQL*Plus commands:
SQL> STARTUP UPGRADE
SQL> SPOOL patch.log
SQL> @?/rdbms/admin/catupgrd.sql
SQL> SPOOL OFF
Review the patch.log file for errors and inspect the list of components that is displayed at the end of catupgrd.sql script.
This list provides the version and status of each SERVER component in the database.
If necessary, rerun the catupgrd.sql script after correcting any problems.
Restart the database:
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP
Run the utlrp.sql script to recompile all invalid PL/SQL packages now instead of when the packages are accessed for the first time. This step is optional but recommended.
SQL> @?/rdbms/admin/utlrp.sql
Note:
When the 10.2.0.4 patch set is applied to an Oracle Database 10g Standard Edition database, there may be 54 invalid objects after the utlrp.sql script runs. These objects belong to the unsupported components and do not affect the database operation.
Ignore any messages indicating that the database contains invalid recycle bin objects similar to the following:
BIN$4lzljWIt9gfgMFeM2hVSoA==$0
Run the following command to check the status of all the components after the upgrade:
SQL> select comp_name, version, status from sys.dba_registry;
In the output of the preceding command, the status of all the components should be VALID for a successful upgrade.
If you are using the Oracle Recovery Manager catalog, enter the following command:
$ rman catalog username/password@alias
For Oracle RAC installations:
Set the CLUSTER_DATABASE initialization parameter to TRUE:
SQL> ALTER SYSTEM SET CLUSTER_DATABASE=TRUE SCOPE=spfile;
Restart the database:
SQL> SHUTDOWN
SQL> STARTUP
Start any database services that you want to use:
$ srvctl start service -d db_name -s service_name
To configure and secure Enterprise Manager follow these steps:
Ensure the database and Listener are operational.
In the case of a single instance, execute
emca -upgrade db
In the case of Oracle Real Application Clusters (RAC), execute
emca -upgrade db -cluster
4.2 用DBUA升级
使用DBUA工具的话,会把升级的一些代码封装起来,我们只需要在界面上点点就可以了。所以比较方便。在一个节点运行DBUA即可。 会同时升级2个节点的实例。
4.2.1 启动相关的进程
[oracle@rac1 bin]$ crs_start -all
4.2.2 运行dbua
[oracle@rac1 ~]$ export DISPLAY=192.168.1.111:0.0
[oracle@rac1 ~]$ dbua
说明:
(1)启动dbua工具后,会提示选择升级ASM还是数据库,这里是从10.2.0.1的基础上升级,不需要升级ASM,直接跳过,如低于此版本而是必须先升级ASM。
(2)运行过程中有选项是否编译无效的对象。默认勾上。在升级之后会自己编译无效对象。
(3)运行需要一个小时左右。
安装结束后会提示安装日志存放目录:
/u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/dbua/orcl/upgrade/
五. 验证
我们还是从客户端来验证,监听之前已经配好了。
C:\Users\Administrator.DavidDai>sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 9月 16 12:18:32 2010
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL> conn sys/oracle@rac as sysdba;
已连接。
SQL> select instance_name from V$instance;
INSTANCE_NAME
--------------------------------
orcl2
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> select comp_name, version, status from sys.dba_registry;
COMP_NAME VERSION STATUS
-------------------------------------------------- -------------------- --------
Oracle Enterprise Manager 10.2.0.4.0 VALID
Spatial 10.2.0.4.0 VALID
Oracle interMedia 10.2.0.4.0 VALID
OLAP Catalog 10.2.0.4.0 VALID
Oracle XML Database 10.2.0.4.0 VALID
Oracle Text 10.2.0.4.0 VALID
Oracle Expression Filter 10.2.0.4.0 VALID
Oracle Rule Manager 10.2.0.4.0 VALID
Oracle Workspace Manager 10.2.0.4.3 VALID
Oracle Data Mining 10.2.0.4.0 VALID
Oracle Database Catalog Views 10.2.0.4.0 VALID
COMP_NAME VERSION STATUS
-------------------------------------------------- -------------------- --------
Oracle Database Packages and Types 10.2.0.4.0 VALID
JServer JAVA Virtual Machine 10.2.0.4.0 VALID
Oracle XDK 10.2.0.4.0 VALID
Oracle Database Java Packages 10.2.0.4.0 VALID
OLAP Analytic Workspace 10.2.0.4.0 VALID
Oracle OLAP API 10.2.0.4.0 VALID
Oracle Real Application Clusters 10.2.0.4.0 VALID
已选择18行。
顺便验证一下RAC的性能,我们看到现在连的是oracl2. 我们上服务器,把这个实例停掉。在查看连哪个实例。
[oracle@rac1 upgrade]$ export ORACLE_SID=orcl2
[oracle@rac1 upgrade]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Sep 16 00:48:47 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
SQL> conn / as sysdba;
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
我们在客户端在查询一下看看:
SQL> select instance_name from V$instance;
INSTANCE_NAME
--------------------------------
orcl1
注意:这里自动切换到了orcl1 实例。 这个就体现RAC的价值,当一个实例宕掉后,不会影响系统的运行。
至此,RAC的升级结束。
