您的位置:首页 > 数据库 > Oracle

Oracle Study之---Oracle升级失败回退(catdwgrd.sql)

2015-08-31 11:56 656 查看


Oracle Study之---Oracle升级失败回退


Downgrading a Database

This chapter guides you through the process of downgrading a database to the previous Oracle Database release. This chapter covers the following topics:

Supported Releases for Downgrading

Check for Incompatibilities

Perform a Full Backup

Downgrade the Database

Perform Post-Downgrade Tasks

See Also:
Some aspects of downgrading are operating system-specific. See your operating system-specific Oracle documentation for additional instructions about downgrading on your operating system.


Supported Releases for Downgrading

You can downgrade both major releases and patchset releases,
based on the original version from which the database was upgraded. Major release downgrades are supported back to release 10.2 and release 10.1. Patchset downgrades are supported back to all prior 11.1 patch releases.

Note:
You cannot downgrade a database that was upgraded from Oracle Database Express Edition.

In all discussions of downgrading, it is important to understand that you can only downgrade to the release from which you upgraded. For example, if you upgraded from Oracle Database 10g Release 1 (10.1)
to Oracle Database 11g Release 1 (11.1), then you could not subsequently downgrade to Oracle Database 10g Release 2 (10.2); you could only downgrade
to Oracle Database 10g Release 1 (10.1).

If the release number of your Oracle Database 10g Release 1 (10.1) database is lower than 10.1.0.5, then you should install the latest patch for Oracle Database 10g Release
1 (10.1) prior to downgrading. Similarly, if the release number of your Oracle Database 10g Release 2 (10.2) database is lower than 10.2.0.3, then you should install the latest patch release for 10.2 prior
to downgrading. Note that you can upgrade from any patch release of 10.1 or 10.2, but you should install the latest patch release in the Oracle home you intend to use after downgrading.

If you have Database Vault installed with your Oracle Database 11g Release 1 (11.1) database, then you can downgrade to release 10.2.0.4 only. Downgrade to 10.2.0.3 is not supported with Database Vault.

If you have Messaging Gateway or Workspace Manager in your database, then be aware that neither of them are part of Oracle Database patchsets prior to release 10.2.0.4. Therefore, you must separately apply all relevant patches to the release 10.2.0.3 or release
10.1.0.5 Oracle home before downgrading.

Downgrade is not supported for Oracle Enterprise Manager. However, if you save your Oracle Enterprise Manager Database Control files and data before upgrading your database, then you can restore the old version of Database Control after downgrading the database.

See Also:

"Save Oracle Enterprise Manager Database Control Data"

"Restoring Oracle Enterprise Manager"

In any event, if you have Enterprise Manager configured in your database, then you must drop the
SYSMAN
schema
before downgrading the database. Run the following statement to drop the
SYSMAN
schema:
DROP USER sysman CASCADE;



Check for Incompatibilities

Check the compatibility level of your database to see if the database might have incompatibilities that prevent you from downgrading. If the compatibility level of your Oracle Database 11g Release 1 (11.1)
database is
11.0.0
or higher, then you are not able to
downgrade.

See Also:
"Compatibility Level"

If you are downgrading to Oracle Database 10g Release 2 (10.2), then the
COMPATIBLE
initialization
parameter must be set to
10.2.0
or lower.

If you are downgrading to Oracle Database 10g Release 1 (10.1), then the
COMPATIBLE
initialization
parameter must be set to
10.1.0
.

See Also:
"Downgrading and Compatibility" and Appendix
A, "Behavior Changes"


Perform a Full Backup

Perform a full backup of your Oracle Database 11g Release 1 (11.1) database before you downgrade.

See Also:
Oracle Database
Backup and Recovery User's Guide for more information


Downgrade the Database

Complete the following steps to downgrade your Oracle Database 11g Release 1 (11.1) database to a major release or a relevant patchset upgrade:

If you have enabled Oracle Database Vault on your database, then you must disable it before downgrading the database.

See Also:
Oracle
Database Vault Administrator's Guide for instructions on disabling Oracle Database Vault

Log in to the system as the owner of the Oracle Database 11g Release 1 (11.1) Oracle home directory.

Note: This step is required only if Enterprise Manager Database Control is already configured for the database.

Stop the Database Control, as follows:

Set the
ORACLE_SID
environment variable to the
databaseSid


Run the following command:
ORACLE_HOME/bin/emctl stop dbconsole


If the database being downgraded is an Oracle Real Application Clusters (Oracle RAC) database, then this step should be performed for all the instances.

If you are downgrading an Oracle RAC database to 10g Release 1 (10.1), then you must remove extra voting disks before shutting down the Oracle Clusterware stack.

To see the number of voting disks used and to list voting disk paths, run the following command:
Oracle_Clusterware_Home/bin/crsctl query css votedisk


Remove each additional voting disk you find in the previous step by running the following command, where
path
is
a voting disk path discovered in the previous step:
Oracle_Clusterware_Home/bin/crsctl delete css votedisk path


At a system prompt, change to the ORACLE_HOME/rdbms/admin directory.

Note:
If you are downgrading a cluster database, then shut down the instance completely and change the
CLUSTER_DATABASE
initialization
parameter to
false
. After the downgrade, you must set
this parameter back to
true
.

Start SQL*Plus.

Connect to the database instance as a user with
SYSDBA
privileges.

Start up the instance in
DOWNGRADE
mode:
SQL> STARTUP DOWNGRADE


You might be required to use the
PFILE
option to specify
the location of your initialization parameter file.

Drop the
SYSMAN
schema:
DROP USER sysman CASCADE;


Set the system to spool results to a log file for later verification of success:
SQL> SPOOL downgrade.log


Run
catdwgrd.sql
:
SQL> @catdwgrd.sql


The following are notes about running the script:

You must use the version of the script included with Oracle Database 11g Release 1 (11.1).

You must run the script in the Oracle Database 11g Release 1 (11.1) environment.

The script downgrades all Oracle Database components in the database to the major release or Oracle Database 11g patch release from which you originally upgraded.

If you encounter any problems when you run the script,
or any of the scripts in the remaining steps, then correct the causes of the problems and rerun the script. You can rerun any of the scripts described in this chapter as many times as necessary.

If the downgrade for a component fails, then an
ORA-39709
error
is displayed and the SQL*Plus session terminates without downgrading the Oracle Database data dictionary. All components must be successfully downgraded before the Oracle Database data dictionary is downgraded. You must identify and fix the problem before
rerunning the
catdwgrd.sql
script.

Turn off the spooling of script results to the log file:
SQL> SPOOL OFF


Then, check the spool file and verify that there were no errors generated during the downgrade. You named the spool file in Step 9;
the suggested name was
downgrade.log
. Correct any problems
you find in this file and rerun the downgrade script if necessary.

Shut down the instance:
SQL> SHUTDOWN IMMEDIATE


Exit SQL*Plus.

If your operating system is Linux or UNIX, then change the following environment variables to point to the directories of the release to which you are downgrading:

ORACLE_HOME


PATH


You should also check that your
oratab
file and any client
scripts that set the value of
ORACLE_HOME
point to the
downgraded Oracle home.

See Also:
Your operating system-specific Oracle Database 11g Release 1 (11.1) installation documents for information about setting other important environment variables on your operating system

If your operating system is Windows, then complete the following steps:

Stop all Oracle services, including the
OracleService
SID
Oracle
service of the Oracle Database 11g Release 1 (11.1) database, where
SID
is
the instance name.

For example, if your SID is ORCL, then enter the following at a command prompt:
C:\> NET STOP OracleServiceORCL


See Also:
The Oracle Database Platform Guide for Microsoft Windows that is specific to your Microsoft Windows environment for information about stopping services

Delete the Oracle service at a command prompt by issuing the ORADIM command. For example, if your SID is ORCL, then enter the following command:
C:\> ORADIM -DELETE -SID ORCL


Create the Oracle service of the database that you
are downgrading at a command prompt using the ORADIM command.
C:\> ORADIM -NEW -SID SID -INTPWD PASSWORD -MAXUSERS USERS
-STARTMODE AUTO -PFILE ORACLE_HOME\DATABASE\INITSID.ORA


This syntax includes the following variables:

VariableDescription
SID
Same SID name as the SID of the database being downgraded.
PASSWORD
Password for the database instance. This is the password for the user connected with
SYSDBA
privileges.
The -
INTPWD
option is not required. If you do not specify
it, then operating system authentication is used, and no password is required.
USERS
Maximum number of users who can be granted
SYSDBA
and
SYSOPER
privileges.
ORACLE_HOME
Oracle home directory of the database to which you are downgrading. Ensure that you specify the full path name with the
-PFILE
option,
including drive letter of the Oracle home directory.
For example, if you are downgrading to Oracle Database 10g Release 2 (10.2), if your SID is
ORCL
,
your PASSWORD is
TWxy5791
,
the maximum number of USERS is 10, and the ORACLE_HOME directory is C:\ORANT, then enter the following command:
C:\> ORADIM -NEW -SID ORCL -INTPWD TWxy5791 -MAXUSERS 10
-STARTMODE AUTO -PFILE C:\ORANT\DATABASE\INITORCL.ORA


Note:
You are not required to change any Windows Registry settings when downgrading a database. The oradim utility makes all necessary changes automatically.

Restore the configuration files (for example, parameter files, password files, and so on) of the release to which you are downgrading.

If this is an Oracle RAC database, execute the following command to return the database to single instance mode:
SET CLUSTER_DATABASE=FALSE


Note:
If you are downgrading a cluster database, then perform this step on all nodes in which this cluster database has instances configured.

Set the
CLUSTER_DATABASE
initialization parameter to
false
.
After the downgrade, you must set this initialization parameter back to
TRUE
.

At a system prompt, change to the ORACLE_HOME/rdbms/admin directory of the previous release.

Start SQL*Plus.

Connect to the database instance as a user with
SYSDBA
privileges.

Start up the instance:
SQL> STARTUP UPGRADE


Set the system to spool results to a log file for later verification of success:
SQL> SPOOL reload.log


Run
catrelod.sql
:
SQL> @catrelod.sql


The
catrelod.sql
script reloads the appropriate version
of all of the database components in the downgraded database.

If you are downgrading to release 10.1.0.5 and you have XDB in your database, then run the following script after running
catrelod.sql
:
@dbmsxdbt.sql


Turn off the spooling of script results to the log file:
SQL> SPOOL OFF


Then, check the spool file and verify that the packages and procedures compiled successfully. You named the spool file in Step 21;
the suggested name was
reload.log
. Correct any problems
you find in this file and rerun the appropriate script if necessary.

Shut down and restart the instance for normal operation:
SQL> SHUTDOWN IMMEDIATESQL> STARTUP


You might be required to use the
PFILE
option to specify
the location of your initialization parameter file.

Perform this step if the database is configured for Oracle Label Security and you are downgrading from Oracle Database 10g Release 1 (10.1) or Oracle Database 10g Release
2 (10.2). Copy the
olstrig.sql
script from the Oracle
Database 11g Release 1 (11.1) Oracle home to the Oracle home of the version to which the database is to be downgraded. Run
olstrig.sql
to
re-create DML triggers on tables with Oracle Label Security policies. (See Oracle
Database Enterprise User Security Administrator's Guide for more information.)
SQL> @olstrig.sql


Run the
utlrp.sql
script:
SQL> @utlrp.sql


The
utlrp.sql
script recompiles all existing PL/SQL modules
that were previously in an
INVALID
state, such as packages,
procedures, types, and so on.

Exit SQL*Plus.

Your database is now downgraded.


Perform Post-Downgrade Tasks

This section discusses tasks that might be required after downgrading a database.

This section contains the following topics:

Downgrading Oracle Clusterware Configuration

Restoring Oracle Enterprise Manager

Single-Instance Oracle Database Without ASM

Oracle RAC Database Without ASM

Single-Instance Oracle ASM Instance

Oracle RAC ASM Instance

Single-Instance Oracle Database With ASM

Oracle RAC Database and ASM Instance

Enabling Oracle Database Vault


Downgrading Oracle Clusterware Configuration

Use one of the following options to downgrade the Oracle Clusterware 11g configuration:

Use
srvconfig
from the Oracle Database 11g Release
1 (11.1) Oracle home. For example:
% srvconfig -downgrade -dbname db_name -orahome 11g_Oracle_home


Run
srvctl
. For example:
11g_Oracle_home/bin/srvctl remove database -d db_name
pre-11g_Oracle_home/bin/srvctl add database -d db_name -o pre-11g_Oracle_home
pre-11g_Oracle_home/bin/srvctl add instance -d db_name -i instance -n node


Note:
Downgrading the database back to 10g needs to be done before running
emca
-restore
.


Restoring Oracle Enterprise Manager

This task is required only if you are downgrading in some form and Oracle Enterprise Manager is configured on the host. To restore Oracle Enterprise Manager, you must have saved your Oracle Enterprise Manager files and data before upgrading.

See Also:
"Save Oracle Enterprise Manager Database Control Data"

If this is an Oracle RAC database using Oracle Clusterware, the database must be registered with the
srvctl
before
running the
emca -restore
command. This needs to be executed
from the
ORACLE_HOME
/bin
of the version to which the database is being downgraded.

Run the
emca
-restore
command
with the appropriate options to restore Oracle Enterprise Manager Database Control or Grid Control to the old Oracle home. The options that you specify depend on whether the database being downgraded is an Oracle Real Application Clusters (Oracle RAC) database
or an Automatic Storage Management (ASM) database, as follows:

Note:
Use the Oracle Database 11g Release 1 (11.1) version of
emca
for
this procedure.

Single-Instance Oracle Database Without ASM
111Home/bin/emca -restore db


You are prompted to enter the following information:

Oracle home for the database to be restored

Database SID

Listener port number

Oracle RAC Database Without ASM
111Home/bin/emca -restore db -cluster


You are prompted to enter the following information:

Oracle home for the database to be restored

Database unique name

Listener port number

Single-Instance Oracle ASM Instance
111Home/bin/emca -restore asm


You are prompted to enter the following information:

Oracle home for the database to be restored

ASM port

ASM SID

Oracle RAC ASM Instance
111Home/bin/emca -restore asm -cluster


You are prompted to enter the following information:

Oracle home for the database to be restored

ASM port

Single-Instance Oracle Database With ASM
111Home/bin/emca -restore db_asm


You are prompted to enter the following information:

Oracle home for the database to be restored

Database SID

Listener port number

ASM port

ASM Oracle home

ASM SID [+ASM]

Oracle RAC Database and ASM Instance
111Home/bin/emca -restore db_asm -cluster


You are prompted to enter the following information:

Oracle home for the database to be restored

Database unique name

Listener port number

ASM port

ASM Oracle home

ASM SID [+ASM]

The output of
emca
will vary with the options you specify
and the values you enter at the prompts; but it will look something like this:
> emca -restore db

STARTED EMCA at Mar 23, 2007 2:44:17 PM
EM Configuration Assistant, Version 11.1.0.3.0 Production
Copyright (c) 2003, 2005, Oracle.  All rights reserved.
Enter the following information:
Mar 23, 2007 2:44:17 PM oracle.sysman.emcp.util.GeneralUtil initSQLEngine
SEVERE: No SID specified
ORACLE_HOME for the database to be restored: /scratch/oracle/10.2.0/product/db_1
Database SID: DB102
Listener port number: 1521
Password for SYS user:  oracle
Do you wish to continue? [yes(Y)/no(N)]: Y
Mar 23, 2007 2:47:29 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /scratch/oracle/cfgtoollogs/emca/DB102/emca_2007_03_23_14_44_17.log.
Mar 23, 2007 2:47:30 PM oracle.sysman.emcp.util.DBControlUtil stopOMS
INFO: Stopping Database Control (this may take a while) ...
Mar 23, 2007 2:47:41 PM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Mar 23, 2007 2:48:06 PM oracle.sysman.emcp.EMDBPostConfig performRestore
INFO: Database Control started successfully
Mar 23, 2007 2:48:06 PM oracle.sysman.emcp.EMDBPostConfig performRestore
INFO: >>>> The Database Control URL is http://stadd17.us.oracle.com:1158/em <<<<<<
Enterprise Manager configuration completed successfully
FINISHED EMCA at Mar 23, 2007 2:48:06 PM


For an inplace patchset upgrade, the original home backup you saved before applying the patchset must be restored. This step must be repeated on all the nodes in RAC environments. Running the
emca
-restore
command
is not required for an inplace patchset upgrade.

After completing the
emca
-restore
procedure
you are ready to restore the Oracle Enterprise Manager Database files and data with the
emdwgrd
utility.
You must run the emdwgrd utility from the Oracle Database 11g Release 1 (11.1) home. But
ORACLE_HOME
and
other environment variables must be set to point to the Oracle home from which the upgrade originally took place.

The following procedure is for Linux and UNIX. To run it on Windows, simply substitute
emdwgrd.bat
for
emdwgrd
.

Follow these steps to restore your Database Control files and data:

Set
ORACLE_HOME
to the Oracle home from which the database
upgrade originally took place.

For an inplace patchset upgrade, restore the backup of the original home (with one-off patch of Bug 7198496 if upgrading from 11.1.0.6), and set
ORACLE_HOME
to
the current Oracle home.

Set
ORACLE_SID
to the SID of the database that was upgraded
and then downgraded.

Set
PATH
,
LD_LIBRARY_PATH
and
SHLIB_PATH
to
point to the Oracle home from which the database upgrade originally took place.

Go to the Oracle Database 11g Release 1 (11.1) home:
cd ORACLE_HOME/bin


Execute one of the following:

For a single-instance database, run the following command, where
SID
is
the SID of the database that was upgraded and then downgraded and
save_directory
is
the path to the storage location you chose when saving your Database Control files and data:
emdwgrd -restore -sid SID -path save_sirectory -tempTablespace TEMP


For an Oracle RAC database, remote copy is required across the cluster nodes. Define an environment variable to indicate which remote copy is configured. For example:
setenv EM_REMCP /usr/bin/scp


Then, execute the following
restore
command:
emdwgrd -restore -tempTablespace TEMP -cluster -sid SID10g -path save_directory


If 10g Oracle home is on a shared device, add
-shared
to
the previous command line.

Enter the SYS and SYSMAN passwords when prompted by
emdwgrd
.

On a single-instance database, the
emdwgrd
utility produces
output similar to the following:
Sat Apr 28 09:27:09 2007 - Verify EM DB Control files ... pass
Sat Apr 28 09:27:09 2007 - Validating DB Connection to DB102 ... pass
Sat Apr 28 09:27:19 2007 - Validating TEMP tablespace in DB102 ... pass
Sat Apr 28 09:27:20 2007 - creating directory ... created
Sat Apr 28 09:27:20 2007 - Stopping DB Control ... stopped
Sat Apr 28 09:27:21 2007 - dropping sysman schema ... dropped
Sat Apr 28 09:27:22 2007 - recreating sysman user ... recreated
Sat Apr 28 09:27:23 2007 - Restoring DB Control files ... restored
Sat Apr 28 09:27:23 2007 - Importing sysman schema ... imported
Sat Apr 28 09:30:42 2007 - recompiling invalid objects ... recompiled
Sat Apr 28 09:30:54 2007 - Starting DB Control ... started
Sat Apr 28 09:32:37 2007 - DB Control was restored successfully.


When
emdwgrd
finishes, Oracle Enterprise Manager Database
Control has been downgraded to the old Oracle home.

On an Oracle RAC database, the
emdwgrd
utility produces
output similar to the following:
$ /scratch/oracle/product/11.1.0/db_1/bin/emdwgrd -srcOracleHome $ORACLE_HOME -sid DB102 -path /scratch/rpattabh/ravi/tmp/dbcdir5 -restore –cluster -tempTablespace TEMP

Enter sys password for database DB102?
*****

Enter sysman password for database DB102?
*****

Sat Apr 28 09:27:09 2007 - Verify EM DB Control files ... pass
Sat Apr 28 09:27:09 2007 - Validating DB Connection to DB102 ... pass
Sat Apr 28 09:27:19 2007 - Validating TEMP tablespace in DB102 ... pass
Sat Apr 28 09:27:20 2007 - creating directory ... created
Sat Apr 28 09:27:20 2007 - Stopping DB Control on all Nodes
stbdq04, r101b1, /oradbnas/sangeeta/10.1.0/db, stop, 0
stbdq05, r101b2, /oradbnas/sangeeta/10.1.0/db, stop, 1

Please Execute '/tmp/racdwgrd_dbctl.sh' on Node1, Node2.

Press yes to continue when the operations are successful.
Continue (yes/no) ?
y

... stopped
Sat Apr 28 09:27:21 2007 - dropping sysman schema ... dropped
Sat Apr 28 09:27:22 2007 - recreating sysman user ... recreated
Sat Apr 28 09:27:23 2007 - Restoring DB Control files
Executing Restore directories to node Node1
Executing Restore directories to node Node2

... restored
Sat Apr 28 09:27:23 2007 - Importing sysman schema ... imported
Sat Apr 28 09:30:42 2007 - recompiling invalid objects ... recompiled
Sat Apr 28 09:32:37 2007 - DB Control was restored successfully.
Sat Apr 28 09:33:54 2007 - Starting DB Control On All nodes

Please Execute '/tmp/racdwgrd_dbctl.sh' on Node1, Node2.

Press yes to continue when the operations are successful.
Continue (yes/no) ?
y

... started
Sat Apr 28 09:38:57 2007 - Dump directory was dropped successfully.



Enabling Oracle Database Vault

If you use Oracle Database Vault, then you were instructed to disable it before downgrading your database. You must now enable Database Vault again.

See Also:
Oracle
Database Vault Administrator's Guide for instructions on enabling Oracle Database Vault
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: