dbua升級oracle 10.2.0.1 0 到11.2.0.4 失敗後還原過程

羽化殘虹發表於2014-08-23

一 升級時候勾選bakcup database





二 假設升級中出現問題

   這裡可以是意外升級中斷,機器down機器等

三 找到當初備份目錄

我這裡的環境是這樣

[/darin/admin/ora10g/backup]ls

control01.ctl  control03.ctl  ora10g_restore.sh  redo02.log  shutdown_ora10g.sql  sysaux01.dbf  temp01.dbf     users01.dbf

control02.ctl  example01.dbf  redo01.log         redo03.log  startup_ora10g.sql   system01.dbf  undotbs01.dbf

可以發現 有一個 ora10g_restore.sh 檔案,我們開啟看看

 

 

#!/bin/sh

 

# -- Run this Script to Restore Oracle Database Instance ora10g

echo -- Bringing down the database from the new oracle home

ORACLE_HOME=/darin/product/11.2.0.4; export ORACLE_HOME

ORACLE_SID=ora10g; export ORACLE_SID

ORACLE_UNQNAME=ora10g; export ORACLE_UNQNAME

/darin/product/11.2.0.4/bin/emctl stop dbconsole

/darin/product/11.2.0.4/bin/sqlplus /nolog @/darin/admin/ora10g/backup/shutdown_ora10g.sql

echo You should Remove this entry from the /etc/oratab: ora10g:/darin/product/11.2.0.4:Y

echo -- Copying Datafiles....

/bin/cp /darin/admin/ora10g/backup/example01.dbf /darin/oradata/ora10g/example01.dbf

/bin/cp /darin/admin/ora10g/backup/redo01.log /darin/oradata/ora10g/redo01.log

/bin/cp /darin/admin/ora10g/backup/redo02.log /darin/oradata/ora10g/redo02.log

/bin/cp /darin/admin/ora10g/backup/redo03.log /darin/oradata/ora10g/redo03.log

/bin/cp /darin/admin/ora10g/backup/sysaux01.dbf /darin/oradata/ora10g/sysaux01.dbf

/bin/cp /darin/admin/ora10g/backup/system01.dbf /darin/oradata/ora10g/system01.dbf

/bin/cp /darin/admin/ora10g/backup/temp01.dbf /darin/oradata/ora10g/temp01.dbf

/bin/cp /darin/admin/ora10g/backup/undotbs01.dbf /darin/oradata/ora10g/undotbs01.dbf

/bin/cp /darin/admin/ora10g/backup/users01.dbf /darin/oradata/ora10g/users01.dbf

/bin/cp /darin/admin/ora10g/backup/control01.ctl /darin/oradata/ora10g/control01.ctl

/bin/cp /darin/admin/ora10g/backup/control02.ctl /darin/oradata/ora10g/control02.ctl

/bin/cp /darin/admin/ora10g/backup/control03.ctl /darin/oradata/ora10g/control03.ctl

echo -- Bringing up the database from the source oracle home

ORACLE_HOME=/darin/product/10.2.0; export ORACLE_HOME

ORACLE_SID=ora10g; export ORACLE_SID

unset LD_LIBRARY_PATH; unset LD_LIBRARY_PATH_64; unset SHLIB_PATH; unset LIB_PATH

echo You should Add this entry in the /etc/oratab: ora10g:/darin/product/10.2.0:Y

cd /darin/product/10.2.0

/darin/product/10.2.0/bin/sqlplus /nolog @/darin/admin/ora10g/backup/startup_ora10g.sql

/darin/product/11.2.0.4/bin/emca -restore db -silent -DB_UNIQUE_NAME ora10g -PORT 1521 -LISTENER LISTENER  -SID ora10g -ORACLE_HOME /darin/product/11.2.0.4 -

HOST darin -LISTENER_OH /darin/product/11.2.0.4 -LOG_FILE /darin/cfgtoollogs/dbua/ora10g/upgrade3/restoreEmConfig.log -SRC_OH /darin/product/10.2.0

#Performed EM Restore Config Changes.

這個指令碼是資料庫還原指令碼

1 首先是切換環境變數到11g

2 然後停止em

3 關閉db

4 移除/etc/oratab: ora10g:/darin/product/11.2.0.4:Y 條目

5 Copy 檔案到你的原來的資料庫檔案目錄

6 切換到10g的環境變數

7 啟動資料庫

8 還原監聽

下面我們來執行一下這個指令碼(我現在是升級成功的環境)

 

 

 

 

darin[/darin/admin/ora10g/backup]./ora10g_restore.sh

-- Bringing down the database from the new oracle home

Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0

Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.

https://darin:1158/em/console/aboutApplication

Stopping Oracle Enterprise Manager 11g Database Control ...

 ...  Stopped.

 

SQL*Plus: Release 11.2.0.4.0 Production on Sat Aug 23 20:57:44 2014

 

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

 

Connected.

ORACLE instance shut down.

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

You should Remove this entry from the /etc/oratab: ora10g:/darin/product/11.2.0.4:Y

-- Copying Datafiles....

-- Bringing up the database from the source oracle home

You should Add this entry in the /etc/oratab: ora10g:/darin/product/10.2.0:Y

 

SQL*Plus: Release 10.2.0.2.0 - Production on Sat Aug 23 21:00:28 2014

 

Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.

 

Connected to an idle instance.

ORACLE instance started.

 

Total System Global Area  281018368 bytes

Fixed Size                  2070552 bytes

Variable Size             100665320 bytes

Database Buffers          171966464 bytes

Redo Buffers                6316032 bytes

Database mounted.

Database opened.

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production

With the Partitioning, OLAP and Data Mining options

 

STARTED EMCA at Aug 23, 2014 9:01:07 PM

EM Configuration Assistant, Version 11.2.0.3.0 Production

Copyright (c) 2003, 2011, Oracle.  All rights reserved.

 

 

Aug 23, 2014 9:01:12 PM oracle.sysman.emcp.EMConfig perform

INFO: This operation is being logged at /darin/cfgtoollogs/dbua/ora10g/upgrade3/restoreEmConfig.log.

Aug 23, 2014 9:01:14 PM oracle.sysman.emcp.util.DBControlUtil stopOMS

INFO: Stopping Database Control (this may take a while) ...

Aug 23, 2014 9:01:26 PM oracle.sysman.emcp.util.DBControlUtil startOMS

INFO: Starting Database Control (this may take a while) ...

Aug 23, 2014 9:03:12 PM oracle.sysman.emcp.EMDBPostConfig performRestore

INFO: Database Control started successfully

Aug 23, 2014 9:03:12 PM oracle.sysman.emcp.EMDBPostConfig performRestore

INFO: >>>>>>>>>>> The Database Control URL is http://darin:1158/em <<<<<<<<<<<

Enterprise Manager configuration completed successfully

FINISHED EMCA at Aug 23, 2014 9:03:12 PM

 

還原完成

這裡我們還要在 /etc/oratab 增加條目

ora10g:/darin/product/10.2.0:Y

 

 

檢視監聽正常

darin[/home/oracle]lsnrctl status

 

LSNRCTL for Linux: Version 10.2.0.2.0 - Production on 23-AUG-2014 21:07:13

 

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=darin)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 10.2.0.2.0 - Production

Start Date                23-AUG-2014 21:06:33

Uptime                    0 days 0 hr. 0 min. 40 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /darin/product/10.2.0/network/admin/listener.ora

Listener Log File         /darin/product/10.2.0/network/log/listener.log

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=darin)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

Service "ora10g" has 1 instance(s).

  Instance "ora10g", status READY, has 1 handler(s) for this service...

Service "ora10gXDB" has 1 instance(s).

  Instance "ora10g", status READY, has 1 handler(s) for this service...

Service "ora10g_XPT" has 1 instance(s).

  Instance "ora10g", status READY, has 1 handler(s) for this service

至此,還原結束。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26175573/viewspace-1256585/,如需轉載,請註明出處,否則將追究法律責任。

相關文章