在oracle10g开始,可以使用sql apply在堆数据库进行滚动升级。
使用sql apply滚动升级的好处
1数据库的停机时间很短,停机的时间也就是switchover的时间
2排出了由于重新编译pl/sql的停止时间
3可以再不影响主库的情况下验证升级的数据库版本。
使用sql apply滚动升级的要求
1数据库不能使dg broker配置的一部分
2dg保护模式必须要不是最高可用,要不是最大性能
3逻辑库的log_archive_dest_n初始化参数必须设置成optional来确保当逻辑备库在升级的时候,主库可以处理
4compatible初始化参数设置,要升级x到y,那么在主库和备库上都要设置compatible成x.
在滚动升级期间,dg配置有混合的数据库版本,数据库保护模式在这期间不可用,考虑在dg配置中有第二个备库来提供数据保护。
准备升级
1设置compatible初始化参数
2获取未支持表的信息
3找出不支持的数据类型
4创建一个逻辑备库
升级数据库
Table 11-1Step-by-Step Procedure to Upgrade Oracle Database Software
Step |
Description |
1 |
Stop SQL Apply and upgrade the logical standby database |
2 |
Restart SQL Apply |
3 |
Monitor events on the upgraded standby database |
4 |
Begin a switchover |
5 |
Determine if unsupported objects were modified during the upgrade |
6 |
Complete the switchover and activate user applications |
7 |
Upgrade the former primary database |
8 |
Start SQL Apply |
9 |
Optionally, raise the compatibility level on both databases |
10 |
Monitor events on the new logical standby database |
11 |
Optionally, perform another switchover |
1停止sql apply
SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY;
2重启sql apply
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;
3监控
SELECT SYSDATE, APPLIED_TIME FROM V$LOGSTDBY_PROGRESS;
SELECT EVENT_TIMESTAMP, EVENT, STATUS FROM DBA_LOGSTDBY_EVENTS
ORDER BY EVENT_TIMESTAMP;
4开始切换
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO LOGICAL STANDBY;
5检查对象是否修改
6完成转换并激活用户程序
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO LOGICAL PRIMARY;
7升级前主库
8开始sql apply
ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE NEW PRIMARY db_link_to_b;
9提高compatible
10监控新逻辑备库的事件
11可选的在来次转换
Optionally, perform another switchover of the databases so Database A is once again running in the primary database role (as shown in Figure 11-1).
To begin the switchover, issue the following statement on Database B:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO LOGICAL STANDBY;
This command waits for existing transactions to complete. After existing transactions have completed, users still connected to Database B will get errors when they try to run transactions on Database B. They should log off immediately and reconnect to Database A.
On Database A issue the following query:
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE; SWITCHOVER_STATUS -------------------- TO PRIMARY
When the query returns TO PRIMARY
, complete the switchover by issuing the following statement on Database A:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO LOGICAL PRIMARY;
Database A is again running in the primary database role. Users can log in to Database A and begin their work.
Start SQL Apply by issuing the following statement on Database B:
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;