Friday, July 31, 2015

rootcrs.pl -patch Failed

rootcrs.pl -patch Failed after applying the patch 12539000

Using configuration parameter file: ./crsconfig_params
Undefined subroutine &main::read_file called at crspatch.pm line 86.

Workaround.

Its a Bug below is the workaround –
Undefined subroutine &main::read_file called at /u01/oracle/product/11.2.0/grid/crs/install/crspatch.pm line 86.
 Take a backup of the file <GridHome>/crs/install/crsconfig_lib.pm
cd /u01/oracle/product/11.2.0/grid/crs/install
 cp crsconfig_lib.pm crsconfig_lib.pm.bak

Make the following change in that file crsconfig_lib.pm
From
     my @exp_func = qw(check_CRSConfig validate_olrconfig validateOCR
To
     my @exp_func = qw(check_CRSConfig validate_olrconfig validateOCR read_file
Now lock and relink the GI HOME as root user….
root@ # diff crsconfig_lib.pm crsconfig_lib.pm_bkp
700c700
<   my @exp_func = qw(check_CRSConfig validate_olrconfig validateOCR read_file
---
>   my @exp_func = qw(check_CRSConfig validate_olrconfig validateOCR
root@ # perl rootcrs.pl -patch
Using configuration parameter file: ./crsconfig_params
ACFS-9200: Supported
CRS-4123: Oracle High Availability Services has been started.
root@ #

Monday, July 6, 2015

Manual Database upgrade from 11.2.0.2 to 11.2.0.4

1. Install the 11.2.0.4 in a new Home Location using runInstaller

Ex:
Unzip the patch 13***
$/u01/app/oracle/11.2.0.4

2. Copy Pre upgrade Information gathering Script:

    Log in to the system as the owner of the Oracle Database 11.2.0.4 Oracle home directory.
    
Copy the Pre-Upgrade Information Tool (utlu112i.sql) and utltzuv2.sql from the Oracle Database 11.2.0.4 $ORACLE_HOME/rdbms/admin 

directory to a directory outside of the Oracle home, such as the temporary directory on your system.

$ORACLE_HOME/rdbms/admin/utlu112i.sql

3. Execute Pre Upgrade Script:

Should be change to the directory where utlu112i.sql  had been copied in the previous step.    Start SQL*Plus and connect to the database instance as a user with SYSDBA privileges. Then run and spool the utlu112i.sql file. Please note that the database should be started using the Source Oracle Home.

$ sqlplus '/ as sysdba'
SQL> spool upgrade_info.log
SQL> @utlu112i.sql
SQL> spool off
SQL>

Check the spool file and examine the output of the upgrade information tool.

 3. Check for the integrity of the source database:

Check for the integrity of the source database prior to starting the upgrade by downloading and running dbupgdiag.sql script from below My Oracle Support article
Note 556610.1  Script to Collect DB Upgrade/Migrate Diagnostic Information (dbupgdiag.sql) (Avoid this step if don’t have support access)

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 thenumber of invalid objects.
$ cd $ORACLE_HOME/rdbms/admin
$ sqlplus "/ as sysdba"
SQL> @utlrp.sql

After validating the invalid objects, re-run dbupgdiag.sql in the database once again and make sure that everything is fine.

4. Check that National Characterset:
Check that National Characterset (NLS_NCHAR_CHARACTERSET) is UTF8 and AL16UTF16.

select value from NLS_DATABASE_PARAMETERS where parameter = 'NLS_NCHAR_CHARACTERSET';

If this is UTF8 or AL16UTF16 then no action is needed.
If is not UTF8 or AL16UTF16 then refer the following article
Note 276914.1 The National Character Set in Oracle 9i and 10g.

5. Optimizer Statistics:
When upgrading to Oracle Database 11g Release 2 (11.2), optimizer statistics are collected for dictionary tables that lack statistics. This statistics collection can be time consuming for databases with a large number of dictionary tables, but statistics gathering only occurs for those tables that lack statistics or are significantly changed during the upgrade

$ sqlplus "/as sysdba"

SQL> EXEC DBMS_STATS.GATHER_DICTIONARY_STATS;

6. Ensure that no files need media recovery:
Sql> SELECT * FROM v$recover_file;

7. Stop the listener for the database:

Make pfile from spfile;

$ lsnrctl stop

8. Shutdown the Database:

Shutdown the database.

$ sqlplus "/as sysdba"
SQL> shutdown immediate;

9. Back Up the Database:

1- Perform Cold Backup
(or)
2- Take a backup using RMAN

Connect to RMAN:

rman "target / nocatalog"

RUN
{
ALLOCATE CHANNEL chan_name TYPE DISK;
BACKUP DATABASE FORMAT '%U' TAG before_upgrade;
BACKUP CURRENT CONTROLFILE TO '';
}

10. Backup and change pfile:

Make a backup of the init.ora file.
Comment out obsolete parameters

* The DIAGNOSTIC_DEST initialization parameter replaces the USER_DUMP_DEST, BACKGROUND_DUMP_DEST.

Note: Once the Parameter file is modified as per your requirement, copy the file to $ORACLE_HOME/dbs (11g Oracle Home )

11. Set Environment Variables:

If your operating system is UNIX then complete this step, else skip to next Step.

1. Make sure the following environment variables point to the Oracle database software 11g Release directories:

- ORACLE_BASE
- ORACLE_HOME
- PATH
$ export ORACLE_HOME=
$ export PATH=$ORACLE_HOME/bin:$PATH
$ export ORACLE_BASE=
Note : If ORACLE_BASE is not known, after setting Path towards 11g Oracle Home, execute 'orabase', which will point the location of base.
$ orabase
/uo1/app/oracle

2. Update the oratab entry, to set the new ORACLE_HOME pointing towards ORCL and disable automatic startup

Sample /etc/oratab

#orcl:/opt/oracle/product/10.2/db_1:N
orcl:/opt/oracle/product/11.2/db_1:N

Note : After /etc/oratab is updated to have sid and Oracle Home (11.2), you can execute oraenv (/usr/local/bin/oraenv) and set the environment. The input has to be the sid which is entered in /etc/oratab against 11g home.
for Instance,

[oracle@localhost ~]$ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base for ORACLE_HOME=/opt/oracle/product/11.2/db_1 is /u01/app/oracle
[oracle@localhost ~]$

12. Upgrade Database:

At the operating system prompt, change to the $ORACLE_HOME/rdbms/admin directory of 11gR2 Oracle Home.

$ cd $ORACLE_HOME/rdbms/admin
$ sqlplus "/ as sysdba"
SQL> startup UPGRADE

Set the system to spool results to a log file for later verification after the upgrade is completed and start the upgrade script.

SQL> set echo on
SQL> SPOOL upgrade.log
SQL> @catupgrd.sql
SQL> spool off

These measures are an important final step to ensure the integrity and consistency of the newly upgraded Oracle Database software. Also, if you encountered a message listing obsolete initialization parameters when you started the database for upgrade, then remove the obsolete initialization parameters from the parameter file before restarting. If necessary, convert the SPFILE to a PFILE so you can edit the file to delete parameters.

13. Post Upgrade:

Start the database and run the Post-Upgrade Status Tool $ORACLE_HOME/rdbms/admin/utlu112s.sql which provides a summary of the upgrade at the end of the spool log. It 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
$ sqlplus "/as sysdba"
SQL> STARTUP
SQL> @utlu112s.sql

14. Recompile Invalid Objects:
This script can be run concurrently with utlrp.sql. Run utlrp.sql to recompile any remaining stored PL/SQL and Java code in another session.
SQL> @utlrp.sql

15. Check for the integrity of the source database:

Check for the integrity of the upgraded database by running dbupgdiag.sql script from below Metalink article
Note 556610.1  Script to Collect DB Upgrade/Migrate Diagnostic Information (dbupgdiag.sql)
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 thenumber of invalid objects.

After validating the invalid objects, re-run dbupgdiag.sql in the upgraded database once again and make sure that everything is fine.

16. Configure and Start Listener.ora :

Modify the listener.ora file:

For the upgraded instance(s) modify the ORACLE_HOME parameter to point to the new ORACLE_HOME. Start the listener :

lsnrctl start

17. Crosscheck Environment Variables:

Set Environment Variables

1. Make sure the following environment variables point to the Oracle 11g Release directories:

- ORACLE_BASE
- ORACLE_HOME
- PATH

Also check that your oratab file and any client scripts that set the value of ORACLE_HOME point to the Oracle database software11g Release 2 (11.2) home.

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

2. Modify /etc/oratab entry to use automatic startup
SID:ORACLE_HOME:Y

For Instance,
orcl:/opt/oracle/product/11.2/db_1:Y

18. Spfile from Pfile:
 Edit init.ora:

- If you changed the CLUSTER_DATABASE parameter prior the upgrade set it back to TRUE
- Migrate your initialization parameter file to a server parameter file.

Create a server parameter file with a initialization parameter file
SQL> create spfile from pfile;

This will create a spfile as a copy of the init.ora file located in $ORACLE_HOME/dbs (UNIX) & %ORACLE_HOME%\database (Windows).

19. Start the Database with spfile:
Shutdown the database:
Sql> shutdown immediate
Now start the database it will user spfile
Sql> startup
Check the Alert log file for any Error.
Database is ready to use now with Database Software Oracle 11g.

20. Validate the database components as below.
23:07:25 SQL> select name, open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------------------------------------------------------------------
TEST      READ WRITE

Oracle Database 11.2 Post-Upgrade Status Tool           07-02-2015 22:46:05
23:02:08 SQL> /

COMP_NAME                                VERSION                        STATUS
---------------------------------------- ------------------------------ --------------------------------------------
Oracle Enterprise Manager                11.2.0.4.0                     VALID
OLAP Catalog                             11.2.0.4.0                     VALID
Spatial                                  11.2.0.4.0                     VALID
Oracle Multimedia                        11.2.0.4.0                     VALID
Oracle XML Database                      11.2.0.4.0                     VALID
Oracle Text                              11.2.0.4.0                     VALID
Oracle Expression Filter                 11.2.0.4.0                     VALID
Oracle Rules Manager                     11.2.0.4.0                     VALID
Oracle Workspace Manager                 11.2.0.4.0                     VALID
Oracle Database Catalog Views            11.2.0.4.0                     VALID
Oracle Database Packages and Types       11.2.0.4.0                     VALID
JServer JAVA Virtual Machine             11.2.0.4.0                     VALID
Oracle XDK                               11.2.0.4.0                     VALID
Oracle Database Java Packages            11.2.0.4.0                     VALID
OLAP Analytic Workspace                  11.2.0.4.0                     VALID
Oracle OLAP API                          11.2.0.4.0                     VALID
Oracle Real Application Clusters         11.2.0.4.0                     INVALID

Total Upgrade Time: 02:03:31

23:07:12 SQL> SELECT OBJECT_TYPE, COUNT(*) FROM DBA_OBJECTS WHERE STATUS='INVALID' GROUP by object_type;

OBJECT_TYPE                                                                  COUNT(*)
---------------------------------------------------------------------------- --------
VIEW                                                                                2
TRIGGER                                                                             1
SYNONYM                                                                             1
PACKAGE BODY                                                                        6

Recreate and Resize Oracle Redo Logs

1. First see the size of the current logs:             
               
   > sqlplus /nolog
   SQL> connect / as sysdba 

select group#, bytes, status from v$log;

2. Retrieve all the log member names for the groups: 

select group#, member from v$logfile;

3. Retrieve the status of log members of the groups: 

select group#, status from v$log;

4.  In older versions of the database you needed to shutdown and issue the following
   commands in restricted mode. You can still do this, but the database can be online
   to perform these changes.

   Let's create 3 new log groups and name them groups 4, 5, and 6, each 150MB in
   size:                           

alter database add logfile group 4 '/swapphome/oracle/app/oradata/fcproddb/redo04.log' size 150m;

alter database add logfile group 5 '/swapphome/oracle/app/oradata/fcproddb/redo05.log' size 150m;

alter database add logfile group 6 '/swapphome/oracle/app/oradata/fcproddb/redo06.log' size 150m;

5. Now run a query to view the v$log status:  

SQL> select group#, status from v$log;                                       

      GROUP# STATUS
   --------- ----------------
           1 INACTIVE
           2 CURRENT
           3 INACTIVE            
           4 UNUSED
           5 UNUSED
           6 UNUSED   

6. Switch until we are into log group 4, so we can drop log groups 1, 2, and 3:

alter system switch logfile;
** repeat as necessary until group 4 is CURRENT **

7. Run the query again to verify the current log group is group 4:                                                            
                                                                
   SQL> select group#, status from v$log;                                       
                                                                  
      GROUP# STATUS
   --------- ----------------
           1 ACTIVE
           2 INACTIVE
           3 INACTIVE            
           4 CURRENT
           5 UNUSED
           6 UNUSED    

Note: redo log Group 1 or 2 or 3 can be active after "alter system switch log file" which means could not be dropped, in this case, 
you need to do "alter system checkpoint" to make redo log groups 1,2 and 3 inactive. 

8. Run the below command to make redo log groups 1,2 and 3 inactive.

SQL> alter system checkpoint;

Run the query again to verify the current log group is group 4:                                                            
                                                                
   SQL> select group#, status from v$log;                                       
                                                                  
      GROUP# STATUS
   --------- ----------------
           1 INACTIVE
           2 INACTIVE
           3 INACTIVE            
           4 CURRENT
           5 UNUSED
           6 UNUSED    

7. Now drop redo log groups 1, 2, and 3

alter database drop logfile group 1;

alter database drop logfile group 2;

alter database drop logfile group 3;

8. Verify the groups were dropped, and the new groups' sizes are correct.
   SVRMGR> select group#, bytes, status from v$log;

      GROUP#     BYTES STATUS
   --------- --------- ----------------
           4  10485760 CURRENT
           5  10485760 UNUSED
           6  10485760 UNUSED       
 
8.  At this point, you consider taking a backup of the database.

9.  You can now go out to the operating system and delete the filesASSOCIATED
    with redo log groups 1, 2, and 3 in step 2 above as they are no longer
    needed:
    
    % rm /usr/oracle/dbs/log1PROD.dbf
    % rm /usr/oracle/dbs/log2PROD.dbf  
    % rm /usr/oracle/dbs/log3PROD.dbf                                                 
                                                  
   Monitor the alert.log for the times of redo log switches. Due to increased
   redo log size, the groups should not switch as frequently under the same 
   load conditions. 

Thursday, July 2, 2015

ORA-04045: errors during recompilation/revalidation of ODSSTG.ODSPREBXE_STREAMS_LOGON

Verify if the object exists

select object_name, object_type, status, owner from dba_objects where object_name='ODSPREBXE_STREAMS_LOGON';

If the object status shows as invalid.

Compile as below.

OBJECT_NAME
--------------------------------------------------------------------------------
OBJECT_TYPE
----------------------------------------------------------------------------
STATUS                       OWNER
---------------------------- ------------------------------
ODSPREBXE_STREAMS_LOGON
TRIGGER
INVALID                      ODSSTG


22:54:24 SQL> alter trigger ODSSTG.ODSPREBXE_STREAMS_LOGON COMPILE;

Trigger altered.

Elapsed: 00:00:00.09

After the compilations the error is stopped in the alert log.


Remove dmsys befor upgrading to 11.2.0.X

20:14:11 SQL> 20:14:11 SQL> SELECT COUNT(*) FROM DBA_SYNONYMS WHERE TABLE_OWNER = 'DMSYS';
       4
Elapsed: 00:00:00.08
20:14:41 SQL> DROP USER DMSYS CASCADE;

Elapsed: 00:00:42.99
20:15:40 SQL> 20:15:40 SQL> SELECT COUNT(*) FROM DBA_SYNONYMS WHERE TABLE_OWNER = 'DMSYS';
       4
Elapsed: 00:00:00.01
20:15:48 SQL> DELETE FROM SYS.EXPPKGACT$ WHERE SCHEMA = 'DMSYS';
Elapsed: 00:00:00.04

20:16:03 SQL> SELECT COUNT(*) FROM DBA_SYNONYMS WHERE TABLE_OWNER = 'DMSYS';
       4
Elapsed: 00:00:00.00
20:16:18 SQL> SET HEAD OFF;
20:16:59 SQL> SELECT 'Drop public synonym ' ||'"'||SYNONYM_NAME||'";' FROM DBA_SYNONYMS
WHERE TABLE_OWNER = 'DMSYS';20:17:07   2

Drop public synonym "CLUSTER_RULE_TYPE";
Drop public synonym "CLUSTER_TYPE";
Drop public synonym "ODM_ATTRIBUTE_IMPORTANCE_MODEL";
Drop public synonym "ODM_NAIVE_BAYES_MODEL";
Elapsed: 00:00:00.05

20:17:08 SQL> Drop public synonym "CLUSTER_RULE_TYPE";
Elapsed: 00:00:00.06
20:17:22 SQL> Drop public synonym "CLUSTER_TYPE";
Elapsed: 00:00:00.04
20:17:28 SQL> Drop public synonym "ODM_ATTRIBUTE_IMPORTANCE_MODEL";
Elapsed: 00:00:00.04
20:17:33 SQL> Drop public synonym "ODM_NAIVE_BAYES_MODEL";
Elapsed: 00:00:00.03
20:17:39 SQL> SELECT COUNT(*) FROM DBA_SYNONYMS WHERE TABLE_OWNER = 'DMSYS';
       0
Elapsed: 00:00:00.00
20:17:46 SQL>