11201 PHYSICAL STANDBY rolling upgrade 11203
2012-04-28 16:19
661 查看
测试使用11的新特性将数据库从11201升级到11203
1、备库上安装11203的软件,使用silent方式安装
2、将备库上的密码文件,参数文件,监听文件等,cp到新路径下
[oracle@oracle11g-std dbs]$ cp spfileora11.ora snapcf_ora11.f orapwora11 initora11.ora hc_ora11.dat /home/oracle/app/product/11.2.0.3/dbs/
[oracle@oracle11g-std admin]$ cp listener.ora tnsnames.ora /home/oracle/app/product/11.2.0.3/network/admin/
3、主库打开flashback功能
做这一步的主要作用是:因为建立日志字典表的时候需要打开flashback功能
SQL> select DATABASE_ROLE from v$database;
DATABASE_ROLE
----------------
PRIMARY
SQL> select FLASHBACK_ON from v$database;
FLASHBACK_ON
------------------
NO
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2212856 bytes
Variable Size 184552456 bytes
Database Buffers 113246208 bytes
Redo Buffers 4796416 bytes
Database mounted.
SQL> ALTER DATABASE FLASHBACK ON;
下面就是讲物理库转化为逻辑库:
取消物理库的日志应用
SQL> alter database recover managed standby database cancel;
Database altered.
备库的日志输出
ORA-16037: user requested cancel of managed recovery operation
MRP0: Background Media Recovery process shutdown (ora11)
Waiting for MRP0 pid 1897 to terminate
Managed Standby Recovery Canceled (ora11)
Completed: alter database recover managed standby database cancel
SQL> shut immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2212856 bytes
Variable Size 134220808 bytes
Database Buffers 163577856 bytes
Redo Buffers 4796416 bytes
Database mounted.
SQL> EXECUTE DBMS_LOGSTDBY.BUILD;
PL/SQL procedure successfully completed.
接下来就是讲物理库转化为逻辑库:
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> ALTER DATABASE RECOVER TO LOGICAL STANDBY KEEP IDENTITY;
Database altered.
SQL>
注意在进行转化的时候必须关闭日志应用,否则会报错
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
LOGICAL STANDBY
SQL> EXECUTE DBMS_LOGSTDBY.APPLY_SET('LOG_AUTO_DELETE', 'FALSE');
BEGIN DBMS_LOGSTDBY.APPLY_SET('LOG_AUTO_DELETE', 'FALSE'); END;
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'DBMS_LOGSTDBY.APPLY_SET' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
SQL> @?/rdbms/admin/dbmslsby.sql
CREATE OR REPLACE PACKAGE sys.dbms_logstdby AUTHID CURRENT_USER IS
*
ERROR at line 1:
ORA-01109: database not open
禁止删除日志的时候报:dbms包没有,创建的时候说数据库没有打开,接下来就打开数据库
SQL> alter database open;
Database altered.
SQL> @?/rdbms/admin/dbmslsby.sql
Package created.
No errors.
Synonym created.
PL/SQL procedure successfully completed.
Grant succeeded.
CREATE ROLE logstdby_administrator
*
ERROR at line 1:
ORA-01921: role name 'LOGSTDBY_ADMINISTRATOR' conflicts with another user or
role name
Grant succeeded.
Grant succeeded.
Grant succeeded.
Library created.
SQL> EXECUTE DBMS_LOGSTDBY.APPLY_SET('LOG_AUTO_DELETE', 'FALSE');
PL/SQL procedure successfully completed.
SQL> EXECUTE DBMS_LOGSTDBY.APPLY_SET('MAX_EVENTS_RECORDED',DBMS_LOGSTDBY.MAX_EVENTS);
PL/SQL procedure successfully completed.
以下是输出日志
Thread 1 advanced to log sequence 4 (LGWR switch)
Current log# 1 seq# 4 mem# 0: /home/oracle/app/oradata/ora11/redo01.log
Wed May 02 00:01:29 2012
Archived Log entry 25 added for thread 1 sequence 3 ID 0x2b47d37c dest 1:
Wed May 02 00:01:36 2012
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_TAB$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_TS$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_OBJ$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_IND$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_ICOL$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_COL$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_USER$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_CDEF$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_CCOL$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_LOB$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_PROPS$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_ENC$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_COLTYPE$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_SUBCOLTYPE$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_ATTRCOL$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_TYPE$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_ATTRIBUTE$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_NTAB$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_REFCON$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_OPQTYPE$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_KOPM$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_PARTOBJ$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_TABPART$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_INDPART$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_TABSUBPART$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_INDSUBPART$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_TABCOMPART$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_INDCOMPART$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_LOBFRAG$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_LOGMNR_BUILDLOG have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_SEED$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_DICTIONARY$ have been marked unusable
Indexes of table SYSTEM.LOGMNR_ATTRCOL$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_ATTRIBUTE$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_CCOL$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_CDEF$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_COL$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_COLTYPE$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_DICTIONARY$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_ENC$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_ICOL$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_IND$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_INDCOMPART$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_INDPART$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_INDSUBPART$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_KOPM$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_LOB$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_LOBFRAG$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_LOGMNR_BUILDLOG have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_NTAB$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_OBJ$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_OPQTYPE$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_PARTOBJ$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_PROPS$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_REFCON$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_SEED$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_SUBCOLTYPE$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_TAB$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_TABCOMPART$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_TABPART$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_TABSUBPART$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_TS$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_TYPE$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_USER$ have been rebuilt and are now usable
Wed May 02 00:02:11 2012
Thread 1 advanced to log sequence 5 (LGWR switch)
Current log# 2 seq# 5 mem# 0: /home/oracle/app/oradata/ora11/redo02.log
Wed May 02 00:02:13 2012
Archived Log entry 26 added for thread 1 sequence 4 ID 0x2b47d37c dest 1:
Wed May 02 00:02:42 2012
LOGMINER: End mining logfiles during dictionary load for session 1
Wed May 02 00:02:45 2012
LSP2 started with pid=38, OS id=2229
Wed May 02 00:02:51 2012
LOGMINER: Begin mining logfile for session 1 thread 1 sequence 91, /home/oracle/archivelog/1_91_781653794.dbf
Wed May 02 00:02:54 2012
LOGSTDBY Analyzer process AS00 started with server id=0 pid=39 OS id=2231
Wed May 02 00:02:55 2012
Wed May 02 00:02:55 2012
LOGSTDBY Apply process AS01 started with server id=1 pid=40 OS id=2233
Wed May 02 00:02:55 2012
LOGSTDBY Apply process AS02 started with server id=2 pid=41 OS id=2235
LOGSTDBY Apply process AS03 started with server id=3 pid=42 OS id=2237
Wed May 02 00:02:55 2012
LOGSTDBY Apply process AS05 started with server id=5 pid=44 OS id=2241
Wed May 02 00:02:55 2012
LOGSTDBY Apply process AS04 started with server id=4 pid=43 OS id=2239
Wed May 02 00:03:13 2012
LOGMINER: End mining logfile for session 1 thread 1 sequence 91, /home/oracle/archivelog/1_91_781653794.dbf
LOGMINER: Begin mining logfile for session 1 thread 1 sequence 92, /home/oracle/archivelog/1_92_781653794.dbf
LOGMINER: End mining logfile for session 1 thread 1 sequence 92, /home/oracle/archivelog/1_92_781653794.dbf
LOGMINER: Begin mining logfile for session 1 thread 1 sequence 93, /home/oracle/archivelog/1_93_781653794.dbf
LOGMINER: End mining logfile for session 1 thread 1 sequence 93, /home/oracle/archivelog/1_93_781653794.dbf
LOGMINER: Begin mining logfile for session 1 thread 1 sequence 94, /home/oracle/archivelog/1_94_781653794.dbf
LOGMINER: End mining logfile for session 1 thread 1 sequence 94, /home/oracle/archivelog/1_94_781653794.dbf
接下来进行升级:
停止日志应用
SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY;
Database altered.
将原监听,密码文件、参数文件、spfile文件拷贝到相应的目录下,修改oracle用户的bash_profile文件
SQL> startup upgrade;
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2227864 bytes
Variable Size 134218088 bytes
Database Buffers 163577856 bytes
Redo Buffers 4784128 bytes
Database mounted.
Database opened.
进行数据字典升级
升级完成之后脚本会自动down数据库
此时重启数据库
[oracle@oracle11g-std ~]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.3.0 Production on Wed May 2 04:13:02 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2227864 bytes
Variable Size 264241512 bytes
Database Buffers 33554432 bytes
Redo Buffers 4784128 bytes
Database mounted.
Database opened.
SQL>
cd /home/oracle/app/product/11.2.0.3/rdbms/admin/
SQL>@utlu112s.sql
SQL>@catuppst.sql
编译各组件----耗时比较长,接近1个小时
SQL> @utlrp.sql
TIMESTAMP
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2012-05-02 04:17:44
DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC> objects in the database. Recompilation time is proportional to the
DOC> number of invalid objects in the database, so this command may take
DOC> a long time to execute on a database with a large number of invalid
DOC> objects.
DOC>
DOC> Use the following queries to track recompilation progress:
DOC>
DOC> 1. Query returning the number of invalid objects remaining. This
DOC> number should decrease with time.
DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC> 2. Query returning the number of objects compiled so far. This number
DOC> should increase with time.
DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC> This script automatically chooses serial or parallel recompilation
DOC> based on the number of CPUs available (parameter cpu_count) multiplied
DOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC> On RAC, this number is added across all RAC nodes.
DOC>
DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC> recompilation. Jobs are created without instance affinity so that they
DOC> can migrate across RAC nodes. Use the following queries to verify
DOC> whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC> 1. Query showing jobs created by UTL_RECOMP
DOC> SELECT job_name FROM dba_scheduler_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
PL/SQL procedure successfully completed.
TIMESTAMP
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2012-05-02 04:53:16
DOC> The following query reports the number of objects that have compiled
DOC> with errors (objects that compile with errors have status set to 3 in
DOC> obj$). If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
OBJECTS WITH ERRORS
-------------------
0
DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#
ERRORS DURING RECOMPILATION
---------------------------
0
Function created.
PL/SQL procedure successfully completed.
Function dropped.
PL/SQL procedure successfully completed.
查看各组件状态
SQL> col comp_name for a30;
SQL> col namespace for a20;
SQL> col version for a15;
SQL> col status for a10;
SQL> SELECT COMP_NAME,namespace,VERSION, STATUS FROM SYS.DBA_REGISTRY;
COMP_NAME NAMESPACE VERSION STATUS
------------------------------ -------------------- --------------- ----------
OWB SERVER 11.2.0.1.0 VALID
Oracle Application Express SERVER 3.2.1.00.10 VALID
Oracle Enterprise Manager SERVER 11.2.0.3.0 VALID
OLAP Catalog SERVER 11.2.0.3.0 INVALID
Spatial SERVER 11.2.0.3.0 VALID
Oracle Multimedia SERVER 11.2.0.3.0 VALID
Oracle XML Database SERVER 11.2.0.3.0 VALID
Oracle Text SERVER 11.2.0.3.0 VALID
Oracle Expression Filter SERVER 11.2.0.3.0 VALID
Oracle Rules Manager SERVER 11.2.0.3.0 VALID
Oracle Workspace Manager SERVER 11.2.0.3.0 VALID
COMP_NAME NAMESPACE VERSION STATUS
------------------------------ -------------------- --------------- ----------
Oracle Database Catalog Views SERVER 11.2.0.3.0 VALID
Oracle Database Packages and T SERVER 11.2.0.3.0 VALID
总计一下升级步骤:
1、安装新的db
2、将物理库切换成逻辑库
3、修改用户的环境变量
4、startup upgrade
5、运行@$ORACLE_HOME/rdbms/admin/utlu112i.sql----显示各组件状态以及升级各组件大约消耗的时间
6、运行真正的升级脚本@$ORACLE_HOME/rdbms/admin/catupgrd.sql
7、运行数据库检查脚本:@$ORACLE_HOME/rdbms/admin/utlu112i.sql:改脚本是检查没有升级之前各组件的状态
8、运行@$ORACLE_HOME/rdbms/admin/utlrp.sql---为了保证数据字典的有效性和完整性,在运行完升级脚本后,建议运行该脚本,编译剩余存储的PL/SQL和JAVA代码
9、运行@$ORACLE_HOME/rdbms/admin/catuppst.sql---定位ORACLE_HOME/rdbms/admin目录用的,不需要进入upgrade模式了。所以直接运行。
/utlu112i.sql----脚本说明:
The Post-Upgrade Status Tool, which is the utlu112s.sql script, displays the status of the database components in the upgraded database and the time required to complete each component upgrade. Any errors that occur during the upgrade are listed with each component
and must be addressed. The utlu112s.sql script can be run any time after you run catupgrd.sql, but not after running utlrp.sql.
以上就是原物理备库转化为逻辑库并且升级结束
后续就是进行贮备切换,以及原主机进行升级
主库:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO LOGICAL STANDBY;
Database altered.
SQL>
备库:
SQL> show user;
USER is "SYS"
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
Database altered.
SQL>
此时的主备库之间已经不能应用日志了,因为低版本的db应用不老高版本的log
接下来就升级原主库:
关闭数据库
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
修改环境变量,加载最新的oracle_home路径
将原主库在新的环境变量的情况下mount起来
[oracle@oracle11 admin]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.3.0 Production on Wed May 2 19:55:11 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2227864 bytes
Variable Size 184549736 bytes
Database Buffers 113246208 bytes
Redo Buffers 4784128 bytes
Database mounted.
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
LOGICAL STANDBY
此时是逻辑库,将逻辑库转化为物理库
SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
Database altered.
SQL> shut immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL>
SQL> Error 45 initializing SQL*Plus
Internal error
[oracle@oracle11 ~]$
启动redo应用
[oracle@oracle11 ~]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.3.0 Production on Wed May 2 21:52:50 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2227864 bytes
Variable Size 184549736 bytes
Database Buffers 113246208 bytes
Redo Buffers 4784128 bytes
Database mounted.
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PHYSICAL STANDBY
然后进行主备库切换,将新备库再切换成原来的主库
1、备库上安装11203的软件,使用silent方式安装
2、将备库上的密码文件,参数文件,监听文件等,cp到新路径下
[oracle@oracle11g-std dbs]$ cp spfileora11.ora snapcf_ora11.f orapwora11 initora11.ora hc_ora11.dat /home/oracle/app/product/11.2.0.3/dbs/
[oracle@oracle11g-std admin]$ cp listener.ora tnsnames.ora /home/oracle/app/product/11.2.0.3/network/admin/
3、主库打开flashback功能
做这一步的主要作用是:因为建立日志字典表的时候需要打开flashback功能
SQL> select DATABASE_ROLE from v$database;
DATABASE_ROLE
----------------
PRIMARY
SQL> select FLASHBACK_ON from v$database;
FLASHBACK_ON
------------------
NO
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2212856 bytes
Variable Size 184552456 bytes
Database Buffers 113246208 bytes
Redo Buffers 4796416 bytes
Database mounted.
SQL> ALTER DATABASE FLASHBACK ON;
/* 同时创建保证还原点以保证升级失败时可以回退 */ SQL> create restore point pre_rolling_upgrd guarantee flashback database;
下面就是讲物理库转化为逻辑库:
取消物理库的日志应用
SQL> alter database recover managed standby database cancel;
Database altered.
备库的日志输出
ORA-16037: user requested cancel of managed recovery operation
MRP0: Background Media Recovery process shutdown (ora11)
Waiting for MRP0 pid 1897 to terminate
Managed Standby Recovery Canceled (ora11)
Completed: alter database recover managed standby database cancel
SQL> shut immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2212856 bytes
Variable Size 134220808 bytes
Database Buffers 163577856 bytes
Redo Buffers 4796416 bytes
Database mounted.
需要在Primary Database中创建Logminer dictionary日志挖掘字典:
SQL> EXECUTE DBMS_LOGSTDBY.BUILD;
PL/SQL procedure successfully completed.
接下来就是讲物理库转化为逻辑库:
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> ALTER DATABASE RECOVER TO LOGICAL STANDBY KEEP IDENTITY;
Database altered.
SQL>
注意在进行转化的时候必须关闭日志应用,否则会报错
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
LOGICAL STANDBY
禁止在逻辑备库端删除外籍日志
SQL> EXECUTE DBMS_LOGSTDBY.APPLY_SET('LOG_AUTO_DELETE', 'FALSE');
BEGIN DBMS_LOGSTDBY.APPLY_SET('LOG_AUTO_DELETE', 'FALSE'); END;
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'DBMS_LOGSTDBY.APPLY_SET' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
SQL> @?/rdbms/admin/dbmslsby.sql
CREATE OR REPLACE PACKAGE sys.dbms_logstdby AUTHID CURRENT_USER IS
*
ERROR at line 1:
ORA-01109: database not open
禁止删除日志的时候报:dbms包没有,创建的时候说数据库没有打开,接下来就打开数据库
SQL> alter database open;
Database altered.
SQL> @?/rdbms/admin/dbmslsby.sql
Package created.
No errors.
Synonym created.
PL/SQL procedure successfully completed.
Grant succeeded.
CREATE ROLE logstdby_administrator
*
ERROR at line 1:
ORA-01921: role name 'LOGSTDBY_ADMINISTRATOR' conflicts with another user or
role name
Grant succeeded.
Grant succeeded.
Grant succeeded.
Library created.
SQL> EXECUTE DBMS_LOGSTDBY.APPLY_SET('LOG_AUTO_DELETE', 'FALSE');
PL/SQL procedure successfully completed.
执行以下语句可以将逻辑备库不支持的而又在主库上运行过的事务记录到DBA_LOGSTDBY_EVENTS中
SQL> EXECUTE DBMS_LOGSTDBY.APPLY_SET('MAX_EVENTS_RECORDED',DBMS_LOGSTDBY.MAX_EVENTS);
PL/SQL procedure successfully completed.
启动在逻辑备库上的SQL APPLY:
以下是输出日志
Thread 1 advanced to log sequence 4 (LGWR switch)
Current log# 1 seq# 4 mem# 0: /home/oracle/app/oradata/ora11/redo01.log
Wed May 02 00:01:29 2012
Archived Log entry 25 added for thread 1 sequence 3 ID 0x2b47d37c dest 1:
Wed May 02 00:01:36 2012
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_TAB$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_TS$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_OBJ$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_IND$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_ICOL$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_COL$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_USER$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_CDEF$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_CCOL$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_LOB$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_PROPS$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_ENC$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_COLTYPE$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_SUBCOLTYPE$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_ATTRCOL$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_TYPE$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_ATTRIBUTE$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_NTAB$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_REFCON$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_OPQTYPE$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_KOPM$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_PARTOBJ$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_TABPART$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_INDPART$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_TABSUBPART$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_INDSUBPART$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_TABCOMPART$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_INDCOMPART$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_LOBFRAG$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_LOGMNR_BUILDLOG have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_SEED$ have been marked unusable
Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_DICTIONARY$ have been marked unusable
Indexes of table SYSTEM.LOGMNR_ATTRCOL$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_ATTRIBUTE$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_CCOL$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_CDEF$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_COL$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_COLTYPE$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_DICTIONARY$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_ENC$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_ICOL$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_IND$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_INDCOMPART$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_INDPART$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_INDSUBPART$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_KOPM$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_LOB$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_LOBFRAG$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_LOGMNR_BUILDLOG have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_NTAB$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_OBJ$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_OPQTYPE$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_PARTOBJ$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_PROPS$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_REFCON$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_SEED$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_SUBCOLTYPE$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_TAB$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_TABCOMPART$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_TABPART$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_TABSUBPART$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_TS$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_TYPE$ have been rebuilt and are now usable
Indexes of table SYSTEM.LOGMNR_USER$ have been rebuilt and are now usable
Wed May 02 00:02:11 2012
Thread 1 advanced to log sequence 5 (LGWR switch)
Current log# 2 seq# 5 mem# 0: /home/oracle/app/oradata/ora11/redo02.log
Wed May 02 00:02:13 2012
Archived Log entry 26 added for thread 1 sequence 4 ID 0x2b47d37c dest 1:
Wed May 02 00:02:42 2012
LOGMINER: End mining logfiles during dictionary load for session 1
Wed May 02 00:02:45 2012
LSP2 started with pid=38, OS id=2229
Wed May 02 00:02:51 2012
LOGMINER: Begin mining logfile for session 1 thread 1 sequence 91, /home/oracle/archivelog/1_91_781653794.dbf
Wed May 02 00:02:54 2012
LOGSTDBY Analyzer process AS00 started with server id=0 pid=39 OS id=2231
Wed May 02 00:02:55 2012
Wed May 02 00:02:55 2012
LOGSTDBY Apply process AS01 started with server id=1 pid=40 OS id=2233
Wed May 02 00:02:55 2012
LOGSTDBY Apply process AS02 started with server id=2 pid=41 OS id=2235
LOGSTDBY Apply process AS03 started with server id=3 pid=42 OS id=2237
Wed May 02 00:02:55 2012
LOGSTDBY Apply process AS05 started with server id=5 pid=44 OS id=2241
Wed May 02 00:02:55 2012
LOGSTDBY Apply process AS04 started with server id=4 pid=43 OS id=2239
Wed May 02 00:03:13 2012
LOGMINER: End mining logfile for session 1 thread 1 sequence 91, /home/oracle/archivelog/1_91_781653794.dbf
LOGMINER: Begin mining logfile for session 1 thread 1 sequence 92, /home/oracle/archivelog/1_92_781653794.dbf
LOGMINER: End mining logfile for session 1 thread 1 sequence 92, /home/oracle/archivelog/1_92_781653794.dbf
LOGMINER: Begin mining logfile for session 1 thread 1 sequence 93, /home/oracle/archivelog/1_93_781653794.dbf
LOGMINER: End mining logfile for session 1 thread 1 sequence 93, /home/oracle/archivelog/1_93_781653794.dbf
LOGMINER: Begin mining logfile for session 1 thread 1 sequence 94, /home/oracle/archivelog/1_94_781653794.dbf
LOGMINER: End mining logfile for session 1 thread 1 sequence 94, /home/oracle/archivelog/1_94_781653794.dbf
接下来进行升级:
停止日志应用
SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY;
Database altered.
将原监听,密码文件、参数文件、spfile文件拷贝到相应的目录下,修改oracle用户的bash_profile文件
SQL> startup upgrade;
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2227864 bytes
Variable Size 134218088 bytes
Database Buffers 163577856 bytes
Redo Buffers 4784128 bytes
Database mounted.
Database opened.
@?/rdbms/admin/catupgrd
进行数据字典升级
升级完成之后脚本会自动down数据库
此时重启数据库
[oracle@oracle11g-std ~]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.3.0 Production on Wed May 2 04:13:02 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2227864 bytes
Variable Size 264241512 bytes
Database Buffers 33554432 bytes
Redo Buffers 4784128 bytes
Database mounted.
Database opened.
SQL>
cd /home/oracle/app/product/11.2.0.3/rdbms/admin/
SQL>@utlu112s.sql
SQL>@catuppst.sql
编译各组件----耗时比较长,接近1个小时
SQL> @utlrp.sql
TIMESTAMP
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2012-05-02 04:17:44
DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC> objects in the database. Recompilation time is proportional to the
DOC> number of invalid objects in the database, so this command may take
DOC> a long time to execute on a database with a large number of invalid
DOC> objects.
DOC>
DOC> Use the following queries to track recompilation progress:
DOC>
DOC> 1. Query returning the number of invalid objects remaining. This
DOC> number should decrease with time.
DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC> 2. Query returning the number of objects compiled so far. This number
DOC> should increase with time.
DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC> This script automatically chooses serial or parallel recompilation
DOC> based on the number of CPUs available (parameter cpu_count) multiplied
DOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC> On RAC, this number is added across all RAC nodes.
DOC>
DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC> recompilation. Jobs are created without instance affinity so that they
DOC> can migrate across RAC nodes. Use the following queries to verify
DOC> whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC> 1. Query showing jobs created by UTL_RECOMP
DOC> SELECT job_name FROM dba_scheduler_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
PL/SQL procedure successfully completed.
TIMESTAMP
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2012-05-02 04:53:16
DOC> The following query reports the number of objects that have compiled
DOC> with errors (objects that compile with errors have status set to 3 in
DOC> obj$). If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
OBJECTS WITH ERRORS
-------------------
0
DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#
ERRORS DURING RECOMPILATION
---------------------------
0
Function created.
PL/SQL procedure successfully completed.
Function dropped.
PL/SQL procedure successfully completed.
查看各组件状态
SQL> col comp_name for a30;
SQL> col namespace for a20;
SQL> col version for a15;
SQL> col status for a10;
SQL> SELECT COMP_NAME,namespace,VERSION, STATUS FROM SYS.DBA_REGISTRY;
COMP_NAME NAMESPACE VERSION STATUS
------------------------------ -------------------- --------------- ----------
OWB SERVER 11.2.0.1.0 VALID
Oracle Application Express SERVER 3.2.1.00.10 VALID
Oracle Enterprise Manager SERVER 11.2.0.3.0 VALID
OLAP Catalog SERVER 11.2.0.3.0 INVALID
Spatial SERVER 11.2.0.3.0 VALID
Oracle Multimedia SERVER 11.2.0.3.0 VALID
Oracle XML Database SERVER 11.2.0.3.0 VALID
Oracle Text SERVER 11.2.0.3.0 VALID
Oracle Expression Filter SERVER 11.2.0.3.0 VALID
Oracle Rules Manager SERVER 11.2.0.3.0 VALID
Oracle Workspace Manager SERVER 11.2.0.3.0 VALID
COMP_NAME NAMESPACE VERSION STATUS
------------------------------ -------------------- --------------- ----------
Oracle Database Catalog Views SERVER 11.2.0.3.0 VALID
Oracle Database Packages and T SERVER 11.2.0.3.0 VALID
总计一下升级步骤:
1、安装新的db
2、将物理库切换成逻辑库
3、修改用户的环境变量
4、startup upgrade
5、运行@$ORACLE_HOME/rdbms/admin/utlu112i.sql----显示各组件状态以及升级各组件大约消耗的时间
6、运行真正的升级脚本@$ORACLE_HOME/rdbms/admin/catupgrd.sql
7、运行数据库检查脚本:@$ORACLE_HOME/rdbms/admin/utlu112i.sql:改脚本是检查没有升级之前各组件的状态
8、运行@$ORACLE_HOME/rdbms/admin/utlrp.sql---为了保证数据字典的有效性和完整性,在运行完升级脚本后,建议运行该脚本,编译剩余存储的PL/SQL和JAVA代码
9、运行@$ORACLE_HOME/rdbms/admin/catuppst.sql---定位ORACLE_HOME/rdbms/admin目录用的,不需要进入upgrade模式了。所以直接运行。
/utlu112i.sql----脚本说明:
The Post-Upgrade Status Tool, which is the utlu112s.sql script, displays the status of the database components in the upgraded database and the time required to complete each component upgrade. Any errors that occur during the upgrade are listed with each component
and must be addressed. The utlu112s.sql script can be run any time after you run catupgrd.sql, but not after running utlrp.sql.
以上就是原物理备库转化为逻辑库并且升级结束
后续就是进行贮备切换,以及原主机进行升级
主库:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO LOGICAL STANDBY;
Database altered.
SQL>
备库:
SQL> show user;
USER is "SYS"
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
Database altered.
SQL>
此时的主备库之间已经不能应用日志了,因为低版本的db应用不老高版本的log
接下来就升级原主库:
关闭数据库
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
修改环境变量,加载最新的oracle_home路径
将原主库在新的环境变量的情况下mount起来
[oracle@oracle11 admin]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.3.0 Production on Wed May 2 19:55:11 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2227864 bytes
Variable Size 184549736 bytes
Database Buffers 113246208 bytes
Redo Buffers 4784128 bytes
Database mounted.
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
LOGICAL STANDBY
此时是逻辑库,将逻辑库转化为物理库
SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
Database altered.
SQL> shut immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL>
SQL> Error 45 initializing SQL*Plus
Internal error
[oracle@oracle11 ~]$
启动redo应用
[oracle@oracle11 ~]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.3.0 Production on Wed May 2 21:52:50 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2227864 bytes
Variable Size 184549736 bytes
Database Buffers 113246208 bytes
Redo Buffers 4784128 bytes
Database mounted.
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PHYSICAL STANDBY
然后进行主备库切换,将新备库再切换成原来的主库
相关文章推荐
- 图解Oracle 11g physical standby Rolling Upgrade物理备库滚动升级特性
- 图解Oracle 11g physical standby Rolling Upgrade物理备库滚动升级特性
- 11g新特性:Rolling Upgrade With Physical Standby
- 11g新特性:Rolling Upgrade With Physical Standby
- Steps to perform for Rolling Forward a Physical Standby Database using RMAN Incremental Backup. (文档
- 11g Release 2 Rolling Upgrade using Transient Logical Standby database
- Oracle 10.2.0.1 rolling upgrade oracle 10.2.0.5 by Logical Standby
- Oracle Data Gurad Physical Standby 相关说明
- Oracle Data Gurad Physical Standby 相关说明
- Oracle:How to create physical standby database with 11g RMAN DUPLICATE FROM ACTIVE DATABASE [ID 747250.1]
- Oracle Data Gurad Physical Standby 相关说明
- How to create physical standby database with 11g RMAN DUPLICATE FROM ACTIVE DATABASE [ID 747250.1]
- Oracle Data Gurad Physical Standby 相关说明
- How To Trace The Remote File Server (RFS) Process In Physical Standby Database (Doc ID 1481125.1)
- Primary Database Changes That Require Manual Intervention at a Physical Standby
- Creating A Physical Standby With RMAN Active Duplicate In 11.2.0.3
- Creating a 10gr2 Data Guard Physical Standby database with Real-Time apply [ID 343424.1]
- Reinstate Failed Primary Database into Physical Standby
- [DataGuard] Creating a Physical Standby Database
- Using Physical Standby for EBS 12 Environments on 11g Databases