Você está na página 1de 33

12 C Upgrade

document
Step 1: Upgrade Path for Oracle Database to Oracle 12c Release 1 (12.1)
We can directly upgrade to new release 12C as we are on 11.2.0.3

Step 2 : Requirements and recommendations for Source database

Either take a cold or hot backup of the source database.

Ensure that all database components/objects provided by Oracle are VALID in the source
database prior to starting the upgrade.

set pages 1000 lines 200


col COMP_NAME for a40
select COMP_ID,COMP_NAME,VERSION,STATUS from dba_registry;
Ensure that you do not have duplicate objects in the SYS and SYSTEM schema.
select OBJECT_NAME, OBJECT_TYPE from
DBA_OBJECTS where OBJECT_NAME||OBJECT_TYPE
in (select OBJECT_NAME||OBJECT_TYPE from
DBA_OBJECTS where OWNER='SYS') and
OWNER='SYSTEM' and OBJECT_NAME not in
('AQ$_SCHEDULES_PRIMARY', 'AQ$_SCHEDULES',
'DBMS_REPCAT_AUTH');

Step 3 : Check for the integrity of the source database.


Run the dbupgdiag.sql.
(download script from metalink note id: 556610.1)
Sqlplus /as sysdba
alter session set nls_language='American';
@dbupgdiag.sql
Review the logfile.

If the dbupgdiag.sql script reports any invalid objects, run


$ORACLE_HOME/rdbms/admin/utlrp.sql (multiple times) to validate the invalid objects in the
database until there is no change in the number of invalid objects.
$ cd $ORACLE_HOME/rdbms/admin
$ sqlplus "/ as sysdba"
SQL> @utlrp.sql

Step 4 : Pre-Upgrade Steps

Run the Pre-Upgrade Information Tool from the environment of the database that will be
upgraded.
Step 1:
Copy preupgrd.sql and utluppkg.sql from the Oracle Database 12c Release 1 (12.1)
$ORACLE_HOME/rdbms/admin to $ORACLE_HOME/rdbms/admin directory of the
source Oracle Home(11.2.0.3).
Step 2:
* Run the new Pre-Upgrade Information Tool
SQL> @$ORACLE_HOME/rdbms/admin/preupgrd.sql
preupgrade.log, preupgrade_fixups.sql and postupgrade_fixups.sql files are created in
$ORACLE_HOME/cfgtoollogs/$ORACLE_SID/preupgrade/, which is under the source
database ORACLE_HOME (11.2.0.3) to be upgraded.
Review the preupgrade.log and take necessary actions.

4.1 Update Access Control Lists and Network Utility Packages


Starting with Oracle Database 12c, the access control of the UTL packages
(UTL_TCP, UTL_SMTP, UTL_MAIL, UTL_HTTP, and UTL_INADDR) is
implemented using Oracle Database Real Application Security and
does not require Oracle XML DB.
4.2 Dependencies on Network Utility Packages

Execute the following query


SQL> SELECT * FROM DBA_DEPENDENCIES
WHERE referenced_name IN ('UTL_TCP','UTL_SMTP','UTL_MAIL','UTL_HTTP','UTL_
INADDR','DBMS_LDAP')
AND owner NOT IN ('SYS','PUBLIC','ORDPLUGINS'); 2 3 4
no rows selected

Hence No action required

4.3 TIMESTAMP WITH TIME ZONE Data Type

The default time zone file shipped with the Oracle 12c Release 1 is version 18.
Need to do Timezone update after upgrade.
4.4 Optimizer Statistics
$ sqlplus "/as sysdba"
SQL> EXEC DBMS_STATS.GATHER_DICTIONARY_STATS;
4.5 Verify That Materialized View Refreshes Have Completed Before Upgrading
Before upgrading Oracle Database, you must wait until all materialized views have completed
refreshing.
Run the following query to determine if there are any materialized view refreshes still in
progress:
SQL> select s.obj#,o.obj#,s.containerobj#,lastrefreshdate,pflags,xpflags,o.name,o.owner#,
bitand(s.mflags, 8) from obj$ o, sum$ s
where o.obj# = s.obj# and o.type# = 42 AND bitand(s.mflags, 8) = 8;
2
no rows selected
No Action required.
4.6 Ensure That No Files Need Media Recovery Before Upgrading

Make ensure that there are no files requiring media recovery by executing the following query .
SQL> SELECT * FROM v$recover_file;
4.7 Ensure That No Files Are in Backup Mode Before Upgrading

Execute the following query to verify that No Files in backup mode when upgrading Oracle
Database
SQL> SELECT * FROM v$backup WHERE status != 'NOT ACTIVE';

4.8 Resolve Outstanding Distributed Transactions Before Upgrading

To resolve outstanding distributed transactions:


1. Issue the following statement:
SQL> SELECT * FROM dba_2pc_pending;

2. If the query in the previous step returns any rows, then issue the following
statements:
SQL> SELECT local_tran_id FROM dba_2pc_pending;
SQL> EXECUTE dbms_transaction.purge_lost_db_entry('');
SQL> COMMIT;
4.9 Purge the Database Recycle Bin Before Upgrading :

To empty the database recycle bin, issue the following command:


SQL> PURGE DBA_RECYCLEBIN
4.10 Disable all batch and cron jobs
select owner,JOB_NAME,JOB_SUBNAME,STATE from DBA_SCHEDULER_JOBS;
Disable the jobs:
execute
execute
execute
execute
execute
execute
execute
execute
execute
execute

dbms_scheduler.disable('SM$CLEAN_AUTO_SPLIT_MERGE');
dbms_scheduler.disable('RSE$CLEAN_RECOVERABLE_SCRIPT');
dbms_scheduler.disable('BSLN_MAINTAIN_STATS_JOB');
dbms_scheduler.disable('DRA_REEVALUATE_OPEN_FAILURES');
dbms_scheduler.disable('ORA$AUTOTASK_CLEAN');
dbms_scheduler.disable('PURGE_LOG ');
dbms_scheduler.disable('ORACLE_OCM.MGMT_CONFIG_JOB');
dbms_scheduler.disable('ORACLE_OCM.MGMT_STATS_CONFIG_JOB');
dbms_scheduler.disable('EXFSYS.RLM$SCHDNEGACTION');
dbms_scheduler.disable('EXFSYS.RLM$EVTCLEANUP');

4.11 Verify SYS and SYSTEM Default tablespace

Ensure the users SYS and SYSTEM have 'SYSTEM' as their default tablespace.
You must have sufficient space in the 'SYSTEM' tablespace or set extents to unlimited.
SQL> SELECT username, default_tablespace
FROM dba_users
WHERE username in ('SYS','SYSTEM');

If DEFAULT_TABLESPACE is anything other than SYSTEM tablespace, modify the default


tablespace for user SYS and SYSTEM to SYSTEM by using the command below:
SQL> ALTER user SYS default tablespace SYSTEM;
SQL> ALTER user SYSTEM default tablespace SYSTEM;
4.12 Location of datafiles, redo logs and control files

Note the location of datafiles, redo logs and control files. Also take a backup of all configuration
files like listener.ora, tnsnames.ora, etc. from $ORACLE_HOME.
SQL> SELECT name FROM v$controlfile;
SQL> SELECT file_name FROM dba_data_files;
SQL> SELECT group#, member FROM v$logfile;
4.13 Drop Oracle 12c Release 1 supplied users and roles ,if exist in the source
database
Run the preupgrade tool to check for the existence of any users or roles in the
source database that use the same names.
No Users/Roles reported.
4.14 Review and Remove any unnecessary hidden/underscore parameters

Remove init parameters below from init file.


sec_case_sensitive_logon and
_no_recovery_through_resetlogs = TRUE

Step 5 : Requirements and recommendations for target database


Requirements for installing Oracle Database 12.1 release 64-bit on RHEL5
(x86_64)

I Hardware Requirements:
1) Minimum Hardware Requirement
a) Ensure that our system meets the following Physical Memory
requirements:
Minimum: 1 GB of RAM
Recommended: 2 GB of RAM or more. So, kindly provide initially
16GB of RAM.
b) Swap disk space proportional to the system's physical memory as follows:

RAM

Swap Space
Between 1 GB and 2
GB

1.5 times the size of RAM

Between 2 GB and 16 GB

Equal to the size of RAM

More than 16 GB

16 GB

So, kindly keep the swap space as 16GB as we are initially requesting 16GB
of RAM
NOTE: Further RAM and swap space may be required to tune/improve
RDBMS performance.
c) We need 10GB of space for /tmp and /var mount points.
d) Need 50GB of local disk space for database software files.This
mount point will be the shelter for oracle home

II Software:
1. Certified Linux Operating Systems
i) Oracle Linux 5 Update 6 or higher
ii) Red Hat Enterprise Linux 5 Update 6 or higher
NOTE: At present all CGF server are Red Hat Enterprise Linux
servers.So,better to go with RHEL 5.6 above.
Current production OS version is as below.
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Kernel \r on an \m
2) Oracle recommends that you install the Linux operating system with the
default software packages (RPMs) and do not customize the RPMs during
installation.
3) Linux Kernel Requirements
Red Hat Enterprise Linux 5 Update 6 2.6.18-238.0.0.0.1.el5 or later
4) Required OS Components (per Release Notes, and Install Guide)
We need to make sure the below RPMs are installed on RHEL 5 server.Those
RPMs which are missing Linux team need to install them.
1.
2.
3.
4.

binutils-2.17.50.0.6 (x86_64)
compat-libstdc++-33-3.2.3 (x86_64)
glibc-2.5-58 (x86_64)
ksh <== any version of ksh is acceptable

5. libaio-0.3.106 (x86_64)
6. libgcc-4.1.2 (x86_64)
7. libstdc++-4.1.2 (x86_64)
8. libXext-1.0.1 (x86_64)
9. libXtst-1.0.1 (x86_64)
10. libX11-1.0.3 (x86_64)
11. libXau-1.0.1 (x86_64)
12. libXi-1.0.1 (x86_64)
13. make-3.81 (x86_64)
14. gcc-4.1.2 (x86_64)
15. gcc-c++-4.1.2 (x86_64)
16. glibc-devel-2.5-58 (x86_64)
17. libaio-devel-0.3.106 (x86_64)
18. libstdc++-devel-4.1.2 (x86_64)
19. sysstat-7.0.2 (x86_64)
20. vnc-server
Customers wishing to install the Oracle Database 12.1 32-bit Client
software should also install these packages:
1. compat-libstdc++-33-3.2.3 (i386)
2. glibc-2.5-58 (i386)
3. glibc-devel-2.5-58 (i386)
4. libaio-0.3.106 (i386)
5. libaio-devel-0.3.106 (i386)
6. libgcc-4.1.2 (i386)
7. libstdc++-4.1.2 (i386)
8. libXext-1.0.1 (i386)
9. libXtst-1.0.1 (i386)
10. libX11-1.0.3 (i386)
11. libXau-1.0.1 (i386)
12. libXi-1.0.1 (i386)
NOTE: Several RPMs will be required as prerequisites to those listed
in section 4 as per this document:
glibc-headers (x86-64)
kernel-headers (x86-64)

III Environment:
1) Below are the Minimum Recommended Kernel Parameter settings required
for Database Software Installation. Modify your kernel settings in
/etc/sysctl.conf as follows.
kernel.shmall = 1/2 of physical memory in pages, this will be the value
2097152.
kernel.shmmax = 1/2 of physical memory in bytes. This would be the value
2147483648 for a system with 4GB of physical RAM.

For 64-bit Linux Systems :


Minimum: 536870912 (512 MB)
Maximum: A value that is 1 byte less than the physical memory
Recommended: More than half the physical memory
See My Oracle Support Note 567506.1 for additional information about
configuring shmmax.
Please place the below values at the end of the file /etc/sysctl.conf
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
To activate these new settings into the running kernel space, run the "sysctl
-p" command as root.
NOTE: If the current value for any parameter is higher than the value
listed, do not change the value of that parameter.
2) Set Shell Limits for the oracle database OS User. Assuming that the
"oracle" as Unix database user will perform the installation, do the
following:
a.) Add the following settings to /etc/security/limits.conf configuration file
for the installation owner.
oracle
oracle
oracle
oracle
oracle
oracle

soft
hard
soft
hard
soft
hard

nproc 2047
nproc 16384
nofile 1024
nofile 65536
stack 10240
stack at least 10240, at most 32768

NOTE: When the limits.conf file is changed, these changes take effect
immediately. However, if the oracle users are logged in, then these
changes do not take effect until you log these users out and log them
back in. You must do this before you use these accounts for installation.
3) Verify the latest version of PAM is loaded, then add or edit the following
line in the /etc/pam.d/login file, if it does not already exist:
session required pam_limits.so

4) Verify the current ulimits, and raise if needed. This can be done many
ways...adding the following lines to /etc/profile is the recommended
method:
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -u 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
5) The hostname command should return the fully qualified hostname as
shown below:
hostname.domainname
Once all the above requirements are done then we are fine with
running runInstaller to install the 12C database software.

Installing 12c Oracle Database 12.1 Software alone on


release 64-bit on RHEL5 (x86_64)
Kindly follow the below steps to install the oracle database 12.1 software
alone on the server.
NOTE: Before running the runInstaller kindly unset the below
environment variables on the server
i)
ORACLE_HOME
ii)
ORACLE_SID
iii)
TNS_ADMIN
iv)
Any Library paths
v)
Any other variables related to the oracle binaries.
Just comment out the entries in bash.profile in your home
directory.

Step1:
Once you are ready with the installation then take a vnc session and then run the
runInstaller.

Step2:
Once you ran the runInstaller then you will get a GUI which will lead you to install
the 12c software.

Kindly uncheck the check box as we no need to receive any security updates via My
Oracle Support.

Click on Yes button and then proceed with installation by clicking on Next

Step3:

Kindly select second option Install database software only


because later we need to upgrade our databases to 12c from 11gr2.

Step4:

Based upon your requriement kindly select the option.For AGUK we need to select
first option as we are not having RAC instances.

Step5:

Now kindly select the required languages as shown above.

Step6:

Kindly select Enterprise Edition option for installation of s/w

Step7:

Kindly provide appropriate values for Oracle base and Oracle home.The above
values are just examples for CRPUK.

Step8:

Now make sure the appropriate group values are present ot not.

Step9:

Even though after setting appropriate values in /etc/sysctl.conf file we are getting
the above Warnings.So,kindly click on Fix & Check Again button.This will lead you to
the below screen shot.

Kindly go to the above location on the server and run the runfixup.sh script as root
user.

Step10:
Once done kindly click on OK.Then it will lead you to the below screen shot.

Then again come to Verification Result tab and check the Ignore All as shown in
the below screen shot.

Kindly click on YES and proceed with the installation.

Step11:

Now click on Install

Step12:

Now please run the script root.sh in the above mentioned location as a root user as
shown below.

Once done kindly click on OK on the vnc session window.

Step13:

Thats the end of the successful installation of 12c DB oracle home software alone.
NOTE: Now we need to perform Upgrade tasks to upgrade our databases from
11gR2 to 12.1

Upgrading Oracle Database


1.1 Upgrade Strategies for Oracle Database

1.1.1 Upgrading a Non-CDB Oracle Database


Manually Upgrading a Non-CDB Oracle Database
After installing the software for Oracle Database 12c

To manually upgrade a non-CDB database:


1. Prepare the new Oracle home
To prepare the new Oracle home for upgrading:

Copy configuration files from the Oracle home(11.2.0.3) of the database


being upgraded to the new Oracle home for Oracle Database 12c.
- Parameter file (spfile or pfile)
- Password file (orapwsid)

2. Shut down the database.


SQL> SHUTDOWN IMMEDIATE
3. Stop the listener for the database.
$ lsnrctl stop
4. Create a new listener for Oracle Database 12c Release 1 (12.1)
database

Copy listener.ora/tnsnames.ora from 11.2.0.3 Oracle_home to


12C(12.1.0) ORACLE_HOME
And change the ORACLE_HOME location on listener.ora.
And start the listener from new home

Your ORACLE_SID is set correctly


Make sure the following environment variables point to the Oracle 12c
Release 1 (12.1) directories

- ORACLE_BASE
- ORACLE_HOME
- PATH, LD_LIBRARY_PATH and SHLIB_PATH
$ export ORACLE_HOME=<location of Oracle 12.1>
$ export PATH=$ORACLE_HOME/bin:$PATH
$ export ORACLE_BASE=<Oracle_Base set during installation>

The oratab file points to the Oracle home for Oracle Database 12c

The following environment variables point to the Oracle Database 12c


directories:

ORACLE_SID
ORACLE_HOME
PATH
TNS_ADMIN
5. Log in to the system as the owner of the Oracle home under the new Oracle Database
12c.
6. From the ORACLE_HOME/rdbms/admin directory, start SQL*Plus.
7. Connect to the database to be upgraded using an account with DBA privileges:
SQL> CONNECT / AS SYSDBA

8. Start the instance by issuing the following command in SQL*Plus:


SQL> startup upgrade pfile=pfile_name
9. Exit SQL*Plus before proceeding to the next step.
10. Run the catctl.pl script from the new Oracle home as described in this
step. The Parallel Upgrade Utility, catctl.pl, provides parallel upgrade
options that reduce downtime.
cd $ORACLE_HOME/rdbms/admin
$ORACLE_HOME/perl/bin/perl catctl.pl -n
catupgrd.sql

6 -l $ORACLE_HOME/diagnostics

11. The upgraded database is shut down after running catctl.pl. Restart the instance to
reinitialize the system parameters for normal operation.
SQL> STARTUP

12. Important: The catuppst.sql script is run as part of the upgrade unless the upgrade
returns errors during the process. Check the log file for "Rem BEGIN catuppst.sql" to
verify that catuppst.sql ran during the upgrade process.

If catuppst.sql has not run, then proceed to run catuppst.sql as


shown in this step.
Run catuppst.sql as follows:
$ORACLE_HOME/perl/bin/perl catcon.pl -n 1 -e -b catuppst -d
'''.''' catuppst.sql

The log file catuppst0.log will be generated with the results of the post
upgrade.

13. Run catcon.pl to invoke utlrp.sql to recompile any remaining stored PL/SQL and
Java code. Use the following syntax:
$ORACLE_HOME/perl/bin/perl catcon.pl -n 1 -e -b utlrp -d '''.'''
utlrp.sql

The log file utlrp0.log is generated with the results of the recompilations.
14. Run postupgrade_fixups.sql.
spool to the admin directory
SQL> SPOOL postupgrade.log
Run the postupgrade_fixups.sql
SQL> SPOOL OFF
15. Run utlu121s.sql to verify that all issues have been fixed.
SQL> @rdbms/admin/utlu121s.sql

16. Verify that all expected packages and classes are valid. (This step assumes that you
previously ran preupgrd.sql before starting the upgrade.)

17.

$ORACLE_HOME/perl/bin/perl catcon.pl -n 1 -e -b utluiobj -d '''.'''


utluiobj.sql

Exit SQL*Plus if you are still in it.

Post-Upgrade Tasks for Oracle Database


1. How to Show the Current State of the Oracle Data
Dictionary
Run the dbupgdiag.sql script and verify the log.

Run the dbupgdiag.sql.


(download script from metalink note id: 556610.1)

Sqlplus /as sysdba


alter session set nls_language='American';
@dbupgdiag.sql
To show the current state of the dictionary, execute a SQL query similar to the
following example:

2. About OPatch Commands After Upgrading Oracle


Database
Check opatch lsinventory from new ORACLE_HOME.

3. Required Tasks to Complete After Upgrading Oracle


Database

3.1 Set Environment Variables on Linux and UNIX Systems After Manual
Upgrades

Set the below variables at UNIX level


ORACLE_HOME
ORACLE_SID
TNS_ADMIN
PATH.LD_LIBRARY_PATH

3.2Set oratab and Scripts to Point to the New Oracle Location After
Upgrading Oracle Database
Add this entry in oratab.
FOCRPUK:/focrpukdb/product_12c/oracle/12.1.0:N

3.3 Adjust Minimum and Maximum for Parallel Execution Servers


Set below init parameters as
PARALLEL_MIN_SERVERS=0 and
PARALLEL_MAX_SERVERS=12

3.6 Upgrade the Time Zone File Version After Upgrading Oracle Database

If the Pre-Upgrade Information Tool instructed you to upgrade the time zone files after
completing the database upgrade, then use the DBMS_DST PL/SQL package to upgrade the
time zone file.

Scripts to automatically update the RDBMS DST


(timezone) version in an 11gR2 or 12cR1 database .
(Doc ID 1585343.1)
As per above document download the DBMS_DST_scriptsV1.9.zip.

1)run upg_tzv_check.sql using SQL*PLUS from the database home


Conn / as sysdba
spool upg_tzv_check.log
@upg_tzv_check.sql
spool off

2)if upg_tzv_check.sql has run sucessfully , run upg_tzv_apply.sql using


SQL*PLUS from the database home
Conn / as sysdba
spool upg_tzv_apply.log
@upg_tzv_apply.sql
spool off
3.7 Tasks to Complete Only After Manually Upgrading Oracle
Database

Change Passwords for Oracle Supplied Accounts


Depending on the release from which you upgraded, there might be new Oracle supplied
accounts. Oracle recommends that you lock all Oracle supplied accounts except for SYS
and SYSTEM, and expire their passwords, thus requiring new passwords to be specified
when the accounts are unlocked.
You can view the status of all accounts by issuing the following SQL statement:
SQL> SELECT username, account_status
FROM dba_users
ORDER BY username;

To lock and expire passwords, issue the following SQL statement:

SQL> ALTER USER username PASSWORD EXPIRE ACCOUNT LOCK;

select USERNAME,ACCOUNT_STATUS,CREATED from dba_users order by


CREATED;

Migrate Your Initialization Parameter File to a Server Parameter File


Create spfile from pfile and start db with spfile.
Setting the COMPATIBLE Initialization Parameter

If you are using an initialization parameter file, then complete the following steps:
1. Shut down the instance if it is running:
2. SQL> SHUTDOWN IMMEDIATE
3. Edit the initialization parameter file to set or change the value of the COMPATIBLE
initialization parameter.
COMPATIBLE = 12.1.0

4. Start the instance using STARTUP.

3.10

Enable the New Extended Data Type Capability

SHUTDOWN IMMEDIATE;
STARTUP UPGRADE;
alter system set MAX_STRING_SIZE=EXTENDED;
@?/rdbms/admin/utl32k.sql
SHUTDOWN IMMEDIATE;
STARTUP;
3.11 Shedule the DBMS_SCHEDULER_JOBS After upgrad.
execute dbms_scheduler.enable('SM$CLEAN_AUTO_SPLIT_MERGE');
execute dbms_scheduler.enable('RSE$CLEAN_RECOVERABLE_SCRIPT');
execute dbms_scheduler.enable('BSLN_MAINTAIN_STATS_JOB');
execute dbms_scheduler.enable('DRA_REEVALUATE_OPEN_FAILURES');
execute dbms_scheduler.enable('ORA$AUTOTASK_CLEAN');
execute dbms_scheduler.enable('PURGE_LOG ');
execute dbms_scheduler.enable('ORACLE_OCM.MGMT_CONFIG_JOB');
execute dbms_scheduler.enable('ORACLE_OCM.MGMT_STATS_CONFIG_JOB');

Você também pode gostar