Oracle數據庫異機升級

環境:
A機:RHEL5.5 + Oracle 10.2.0.4
B機:RHEL5.5
需求:
A機10.2.0.4數據庫,在B機升級到11.2.0.4,應用最新PSU補丁程序。
目錄:
1、 確認是否能夠直接升級
2、 B機安裝11g軟件,打好PSU補丁
3、 B機環境變量檢查
4、 B機建立須要的目錄
5、 A機原庫升級前檢查html

6、 A機備份原庫
7、 B機恢復數據庫
8、 B機升級數據庫sql

9、 B機升級後操做數據庫

1、 確認是否能夠直接升級

本次需求:Oracle 10.2.0.4 -> 11.2.0.4.7
從下圖中看到,能夠直接升級。

網絡

2、 B機安裝11g軟件,打好PSU補丁


安裝11g軟件(不須要建庫)可參考: http://www.cnblogs.com/jyzhao/p/3891769.html
打PSU補丁(補丁隨帶的readme必須看)可參考: http://www.cnblogs.com/jyzhao/p/4145273.html

3、 B機環境變量檢查

echo $ORACLE_BASE
echo $ORACLE_HOME
echo $ORACLE_SID
echo $PATH

4、 B機建立須要的目錄

B機建議先建立如下目錄,其中scripts不是必須的,對於bdump,udump在11g再也不須要了,這點從後面的升級前檢查腳本的輸出結果也可看到。oracle

mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/dpdump 
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/cdump 
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/pfile 
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/scripts

5、 A機原庫升級前檢查

將B機11.2.0.4的utlu112i.sql,scp到A機上,進行升級檢查。
app

5.1 從B機上傳utlu112i.sql腳本到A機

$ scp $ORACLE_HOME/rdbms/admin/utlu112i.sql 192.168.xx.xx:/home/oracle

5.2 A機執行utlu112i.sql進行升級前檢查

[oracle@oracle10g oracle]$ sqlplus / as sysdba
 
SQL*Plus: Release 10.2.0.4.0 - Production on Fri Dec 26 06:46:46 2014
 
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
 
 
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
SQL> spool upgrade.info
SQL> @/home/oracle/utlu112i.sql
Oracle Database 11.2 Pre-Upgrade Information Tool 08-28-2015 10:02:57
Script Version: 11.2.0.4.0 Build: 007
.
**********************************************************************
Database:
**********************************************************************
--> name:          VAS
--> version:       10.2.0.4.0
--> compatible:    10.2.0.3.0
--> blocksize:     8192
--> platform:      Linux x86 64-bit
--> timezone file: V4
.
**********************************************************************
Tablespaces: [make adjustments in the current environment]
**********************************************************************
--> SYSTEM tablespace is adequate for the upgrade.
.... minimum required size: 991 MB
--> UNDOTBS1 tablespace is adequate for the upgrade.
.... minimum required size: 400 MB
--> SYSAUX tablespace is adequate for the upgrade.
.... minimum required size: 790 MB
--> TEMP tablespace is adequate for the upgrade.
.... minimum required size: 60 MB
.
**********************************************************************
Flashback: OFF
**********************************************************************
**********************************************************************
Update Parameters: [Update Oracle Database 11.2 init.ora or spfile]
Note: Pre-upgrade tool was run on a lower version 64-bit database.
**********************************************************************
--> If Target Oracle is 32-Bit, refer here for Update Parameters:
-- No update parameter changes are required.
.

--> If Target Oracle is 64-Bit, refer here for Update Parameters:
-- No update parameter changes are required.
.
**********************************************************************
Renamed Parameters: [Update Oracle Database 11.2 init.ora or spfile]
**********************************************************************
-- No renamed parameters found. No changes are required.
.
**********************************************************************
Obsolete/Deprecated Parameters: [Update Oracle Database 11.2 init.ora or spfile]
**********************************************************************
--> background_dump_dest         11.1       DEPRECATED   replaced by  "diagnostic_dest"
--> user_dump_dest               11.1       DEPRECATED   replaced by  "diagnostic_dest"
.

**********************************************************************
Components: [The following database components will be upgraded or installed]
**********************************************************************
--> Oracle Catalog Views         [upgrade]  VALID
--> Oracle Packages and Types    [upgrade]  VALID
--> JServer JAVA Virtual Machine [upgrade]  VALID
--> Oracle XDK for Java          [upgrade]  VALID
--> Oracle Workspace Manager     [upgrade]  VALID
--> OLAP Analytic Workspace      [upgrade]  VALID
--> OLAP Catalog                 [upgrade]  VALID
--> EM Repository                [upgrade]  VALID
--> Oracle Text                  [upgrade]  VALID
--> Oracle XML Database          [upgrade]  VALID
--> Oracle Java Packages         [upgrade]  VALID
--> Oracle interMedia            [upgrade]  VALID
--> Spatial                      [upgrade]  VALID
--> Data Mining                  [upgrade]  VALID
--> Expression Filter            [upgrade]  VALID
--> Rule Manager                 [upgrade]  VALID
--> Oracle OLAP API              [upgrade]  VALID
.
**********************************************************************
Miscellaneous Warnings
**********************************************************************
WARNING: --> Database is using a timezone file older than version 14.
.... After the release migration, it is recommended that DBMS_DST package
.... be used to upgrade the 10.2.0.4.0 database timezone version
.... to the latest version which comes with the new release.
WARNING: --> Database contains INVALID objects prior to upgrade.
.... The list of invalid SYS/SYSTEM objects was written to
.... registry$sys_inv_objs.
.... The list of non-SYS/SYSTEM objects was written to
.... registry$nonsys_inv_objs.
.... Use utluiobj.sql after the upgrade to identify any new invalid
.... objects due to the upgrade.
.... USER CRNOPHQOA has 2 INVALID objects.
WARNING: --> EM Database Control Repository exists in the database.
.... Direct downgrade of EM Database Control is not supported. Refer to the
.... Upgrade Guide for instructions to save the EM data prior to upgrade.
WARNING: --> Your recycle bin is turned on and currently contains no objects.
.... Because it is REQUIRED that the recycle bin be empty prior to upgrading
.... and your recycle bin is turned on, you may need to execute the command:
        PURGE DBA_RECYCLEBIN
.... prior to executing your upgrade to confirm the recycle bin is empty.
WARNING: --> JOB_QUEUE_PROCESS value must be updated
.... Your current setting of "10" is too low.

.... Starting with Oracle Database 11g Release 2 (11.2), setting
.... JOB_QUEUE_PROCESSES to 0 causes both DBMS_SCHEDULER and
.... DBMS_JOB jobs to not run. Previously, setting JOB_QUEUE_PROCESSES
.... to 0 caused DBMS_JOB jobs to not run, but DBMS_SCHEDULER jobs were
.... unaffected and would still run. This parameter must be updated to
.... a value greater than 32  (default value is 1000) prior to upgrade.
.... Not doing so will affect the running of utlrp.sql after the upgrade
.
**********************************************************************
Recommendations
**********************************************************************
Oracle recommends gathering dictionary statistics prior to
upgrading the database.
To gather dictionary statistics execute the following command
while connected as SYSDBA:

    EXECUTE dbms_stats.gather_dictionary_stats;

**********************************************************************
SQL> spool off

5.3 根據檢查結果調整A機數據庫

5.3.1 表空間對比知足條件

select file_name,tablespace_name,maxbytes/1024/1024 from dba_data_files
where tablespace_name in('SYSTEM','UNDOTBS1','SYSAUX')
union all
select file_name,tablespace_name,maxbytes/1024/1024 from dba_temp_files;

5.3.2 A機建立pfile文件

SQL> create pfile='/home/oracle/orcl10.pfile' from spfile;

5.3.3 A機scp pfile文件到B機

$ scp /home/oracle/orcl10.pfile 192.168.xx.xx:/home/oracle

5.3.4 B機上編輯pfile文件

注意下sga和pga的設定是否符合目的機器的配置
*.sga_target=629145600
*.pga_aggregate_target=25165824
將*.background_dump_dest和*.user_dump_dest刪除
加上 *.diagnostic_dest='$ORACLE_BASE'
注:參數文件的修改不用多說,但須要注意其餘各參數的值是否符合需求。

修改後複製一份到$ORACLE_HOME/dbs/init$ORACLE_SID.oraide

$ cp /home/oracle/orcl10.pfile $ORACLE_HOME/dbs/init$ORACLE_SID.ora

5.3.5 A機運行utlrp.sql 腳本,從新編譯無效對象

從新編譯SYS 和SYSTEM 中的無效對象工具

記錄無效對象:
col OWNER for a10;
col OBJECT_NAME for a30;
col OBJECT_TYPE for a10;
select * from registry$nonsys_inv_objs; //非sys/system的失效對象

select * from registry$sys_inv_objs;   //sys/system的失效對象
 
SQL> @?/rdbms/admin/utlrp.sql;
從新執行 @/home/oracle/utlu112i.sql,查看是否從新編譯,

5.3.6 A機執行PURGE DBA_RECYCLEBIN

SQL> PURGE DBA_RECYCLEBIN;
DBA Recyclebin purged.

5.3.7 A機收集系統信息EXECUTE dbms_stats.gather_dictionary_stats;

在升級前收集字典統計信息,不然預升級工具( utlu102i.sql)會花費更長時間測試

SQL> EXECUTE dbms_stats.gather_dictionary_stats;
 
PL/SQL procedure successfully completed.

注意:升級以後執行utluiobj.sqlui

6、 A機備份原庫

爲了避免影響業務的網絡帶寬,可採用DCN網絡進行NFS的搭建,同時沒必要再傳送備份文件。
NFS配置參考:http://www.cnblogs.com/jyzhao/p/3809078.html
A機備份原庫可參考:http://www.cnblogs.com/jyzhao/p/4806434.html#1

7、 B機恢復數據庫


B機恢復數據庫可參考: http://www.cnblogs.com/jyzhao/p/4806434.html#2

注意:這裏恢復完成不要直接嘗試打開數據庫。由於咱們是要升級!須要open resetlogs upgrade(在下一個步驟說明)。

8、 B機升級數據庫


8.1 修改恢復後的數據庫爲非歸檔模式


爲預防升級測試過程當中默認的歸檔空間不夠,這裏升級先把庫開啓爲非歸檔模式。

SQL> select status from v$instance;

STATUS
------------
MOUNTED

SQL> alter database noarchivelog;

Database altered.

SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     27
Current log sequence           29

8.2 alter database open resetlogs upgrade;

SQL> alter database open resetlogs upgrade;

8.3 執行升級腳本

SQL> spool upgrade.log
SQL> @?/rdbms/admin/catupgrd.sql

本次升級經驗值:
測試庫此步驟升級運行時間:37分鐘。
生產庫此步驟升級運行時間:61分鐘。

9、 B機升級後操做

9.1 建立spfile文件

SQL> startup pfile='$ORACLE_HOME/dbs/init$ORACLE_SID.ora'
SQL> create spfile from pfile='$ORACLE_HOME/dbs/init$ORACLE_SID.ora';

9.2 執行EXECUTE dbms_stats.gather_dictionary_stats;

SQL> exec dbms_stats.gather_dictionary_stats;
PL/SQL procedure successfully completed.

9.3 從新編譯

SQL> @?/rdbms/admin/utlrp.sql

9.4 查看失效對象

SQL> SELECT count(*) FROM dba_invalid_objects;

若是失效對象爲升級以前的失效對象,升級過程當中沒有使對象失效。

9.5 運行升級後檢查腳本

SQL> @?/rdbms/admin/utlu112s.sql
.
Oracle Database 11.2 Post-Upgrade Status Tool           08-31-2015 16:13:55
.
Component                               Current      Version     Elapsed Time
Name                                    Status       Number      HH:MM:SS
.
Oracle Server
.                                         VALID      11.2.0.4.0  00:07:44
JServer JAVA Virtual Machine
.                                         VALID      11.2.0.4.0  00:05:02
Oracle Workspace Manager
.                                         VALID      11.2.0.4.0  00:00:21
OLAP Analytic Workspace
.                                         VALID      11.2.0.4.0  00:00:20
OLAP Catalog
.                                         VALID      11.2.0.4.0  00:00:30
Oracle OLAP API
.                                         VALID      11.2.0.4.0  00:00:15
Oracle Enterprise Manager
.                                         VALID      11.2.0.4.0  00:05:23
Oracle XDK
.                                         VALID      11.2.0.4.0  00:01:48
Oracle Text
.                                         VALID      11.2.0.4.0  00:00:30
Oracle XML Database
.                                         VALID      11.2.0.4.0  00:02:42
Oracle Database Java Packages
.                                         VALID      11.2.0.4.0  00:00:08
Oracle Multimedia
.                                         VALID      11.2.0.4.0  00:02:21
Spatial
.                                         VALID      11.2.0.4.0  00:03:32
Oracle Expression Filter
.                                         VALID      11.2.0.4.0  00:00:06
Oracle Rules Manager
.                                         VALID      11.2.0.4.0  00:00:05
Final Actions
.                                                                00:00:25
Total Upgrade Time: 00:31:21

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.09

9.6 數據庫層面應用PSU

cd $ORACLE_HOME/rdbms/admin/
SQL> @catbundle.sql psu apply

檢查opatch補丁相關信息:

./opatch lspatches
./opatch lsinventory

查詢dba_registry_history:

SQL> select * from dba_registry_history;

到此,已完成數據庫異機升級操做。

相關文章
相關標籤/搜索