Ads 468x60px

martes, 21 de mayo de 2013

Como Actualizar Oracle Database

Como Actualizar Oracle Database

Seguramente en alguna instancia o momento te han solicitado o te haz visto en la necesidad de actualizar tu version de base de datos Oracle. En esta ocasion se explica como actualizar una base de datos Oracle 10.2.0.1 a 10.2.0.4 en un RedHat Enterprise Linux 5.9 .

Lo primero que haz de saber, Oracle a pesar de ofrecer y permitir descargas y uso limitado en capacidad de sus productos de forma "gratuita" el soporte y las actualizaciones de sus softwares NO SON GRATUITOS por lo que sino tienes un usuario de PAGO con Oracle no podras descargar ningun parche de actualizacion o correcion de alguna vulnerabilidad. Para obtener un usuario de PAGO en Oracle, tienes que tener una licencia valida de algun producto adquirido con Oracle.

Bien, continuando con la explicacion del tema, se realiza actualizacion de una base de datos Oracle Standard Edition 10.2.0.1 a la 10.2.0.4 en RedHat Enterprise, en arquitectura de 32 bits.

PREPARANDONOS PARA LA ACTUALIZACION.

- Lo mas primordial siempre, es realizar un respaldo previo a todo, asi si algo sale mal podras reponer el daño con tu respaldo. Por lo que tomando esto en cuenta se procede a detener el motor de BD:


/* Detener el motor si se esta ejecutando */
$ isqlplusctl stop
iSQL*Plus 10.2.0.1.0
Copyright (c) 2003, 2005, Oracle.  All rights reserved.
Stopping iSQL*Plus ...
iSQL*Plus stopped.

/* Detener la consola EM  */

$ emctl stop dbconsole
TZ set to US/Eastern
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0  
Copyright (c) 1996, 2005 Oracle Corporation.  All rights reserved.
http://ora10.home.com:1158/em/console/aboutApplication
Stopping Oracle Enterprise Manager 10g Database Control ... 
 ...  Stopped. 

/* Detener el Listener */

$ lsnrctl stop

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
The command completed successfully

/* Apagar el motor */

$ sqlplus / as sysdba

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> 

Una vez detenido el motor de BD, haz un respaldo en frio de la misma y respalda tambien el directorio completo de tu ORACLE_HOME.

$cd /u01/apps/oracle/oradata/

/*
 Todos mis data files , archivos de control y archivos logs estan en un directorio llamado  ora10g
 y ubicado en /u01/apps/oracle/oradata/.
 Asi que los comprimire en un archivo TAR
*/

$ tar czf /home/oracle/ora10g.tar.gz ora10g

$ echo $ORACLE_HOME
/u01/apps/oracle/product/10.2.0/db_1

/*Este es mi archivo ORACLE_HOME el cual respaldo igual.
*/

$ cd /u01/apps/oracle/product/10.2.0/
$ tar czf /home/oracle/oraHomeBackup.tar.gz db_1

Vamos que tenemos que asegurarnos que todo debe quedar perfectamente respaldado. 
Lo siguiente solo funciona sino tienes ningun JOB creado dentro del motor que trabaje con la zona horaria de TZData.

Lo siguiente es descargarse el parche de actualizacion (En este caso paso del motor 10.2.0.1 a 10.2.0.4).

Descarga Parche 10.2.0.4 Linux 32 bits.

Una vez descargado, ingresa como root en otra terminal y:

# xhost +SI:localuser:oracle

Bien, hora de instalar el parche, asi que regresa a la terminal de oracle donde estabas inicialmente
y descomprime el parche que descargaste:

$ cd /home/oracle
$ unzip p6810189_10204_Linux-x86.zip
$ cd Disk1/
$ ./runInstaller

Te aparecera una pantalla similar a la siguiente:

Como Actualizar Oracle Database

Indicale la ruta donde esta el ORACLE_HOME

Como Actualizar Oracle Database

Despues de verificar los requisitos y si todo sale bien y cumples con todo lo requerido
te mostrara una pantalla donde podras inicializar la instalacion:

Como Actualizar Oracle Database
El procedimiento que continua es bastante similar al de instalacion, por lo cual debes
responder y hacer click a continuar en las demas solicitudes que se te vayan presentando.
Si todo termina de forma correcta, el ultimo paso a realizar una vez finalizado es actualizar
el motor mediante el cliente, ya que sino lo haces te ocurrira algo similar a lo siguiente:

$ sqlplus / as sysdba

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  608174080 bytes
Fixed Size                  1268896 bytes
Variable Size             171967328 bytes
Database Buffers          427819008 bytes
Redo Buffers                7118848 bytes
Database mounted.
ORA-01092: ORACLE instance terminated. Disconnection forced

SQL> exit
 
Asi que para actualizar el motor mediante el cliente SQLPLUS debes de:
 
 
$ cd $ORACLE_HOME/rdbms/admin
$ sqlplus / as sysdba

SQL> startup upgrade

SQL> spool pre_upgrade.log

SQL> @utlu102i.sql
Oracle Database 10.2 Upgrade Information Utility    07-02-2010 17:39:25
.
**********************************************************************
Database:
**********************************************************************
--> name:       ORA10G
--> version:    10.2.0.1.0
--> compatible: 10.2.0.1.0
--> blocksize:  8192
.
**********************************************************************
Tablespaces: [make adjustments in the current environment]
**********************************************************************
--> SYSTEM tablespace is adequate for the upgrade.
.... minimum required size: 488 MB
.... AUTOEXTEND additional space required: 8 MB
--> UNDOTBS1 tablespace is adequate for the upgrade.
.... minimum required size: 400 MB
.... AUTOEXTEND additional space required: 370 MB
--> SYSAUX tablespace is adequate for the upgrade.
.... minimum required size: 245 MB
.... AUTOEXTEND additional space required: 15 MB
--> TEMP tablespace is adequate for the upgrade.
.... minimum required size: 58 MB
.... AUTOEXTEND additional space required: 38 MB
--> EXAMPLE tablespace is adequate for the upgrade.
.... minimum required size: 69 MB
.
**********************************************************************
Update Parameters: [Update Oracle Database 10.2 init.ora or spfile]
**********************************************************************
-- No update parameter changes are required.
.
**********************************************************************
Renamed Parameters: [Update Oracle Database 10.2 init.ora or spfile]
**********************************************************************
-- No renamed parameters found. No changes are required.
.
**********************************************************************
Obsolete/Deprecated Parameters: [Update Oracle Database 10.2 init.ora or spfile]
**********************************************************************
-- No obsolete parameters found. No changes are required
.
**********************************************************************
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 Java Packages         [upgrade]  VALID
--> Oracle Text                  [upgrade]  VALID
--> Oracle XML Database          [upgrade]  VALID
--> Oracle Workspace Manager     [upgrade]  VALID
--> Oracle Data Mining           [upgrade]  VALID
--> OLAP Analytic Workspace      [upgrade]  VALID
--> OLAP Catalog                 [upgrade]  VALID
--> Oracle OLAP API              [upgrade]  VALID
--> Oracle interMedia            [upgrade]  VALID
--> Spatial                      [upgrade]  VALID
--> Expression Filter            [upgrade]  VALID
--> EM Repository                [upgrade]  VALID
--> Rule Manager                 [upgrade]  VALID
.

PL/SQL procedure successfully completed.

SQL> spool off
 
INICIAMOS EL UPGRADE
 
SQL> spool upgrade.log
SQL> @catupgrd.sql
.
.
.
[output trimmed]
.
.
.
Oracle Database 10.2 Upgrade Status Utility           07-02-2010 18:13:40
.
Component                                Status         Version  HH:MM:SS
Oracle Database Server                    VALID      10.2.0.4.0  00:09:32
JServer JAVA Virtual Machine              VALID      10.2.0.4.0  00:03:34
Oracle XDK                                VALID      10.2.0.4.0  00:00:29
Oracle Database Java Packages             VALID      10.2.0.4.0  00:00:39
Oracle Text                               VALID      10.2.0.4.0  00:00:20
Oracle XML Database                       VALID      10.2.0.4.0  00:01:29
Oracle Workspace Manager                  VALID      10.2.0.4.3  00:00:39
Oracle Data Mining                        VALID      10.2.0.4.0  00:00:18
OLAP Analytic Workspace                   VALID      10.2.0.4.0  00:00:19
OLAP Catalog                              VALID      10.2.0.4.0  00:00:50
Oracle OLAP API                           VALID      10.2.0.4.0  00:00:45
Oracle interMedia                         VALID      10.2.0.4.0  00:03:48
Spatial                                   VALID      10.2.0.4.0  00:01:29
Oracle Expression Filter                  VALID      10.2.0.4.0  00:00:09
Oracle Enterprise Manager                 VALID      10.2.0.4.0  00:01:16
Oracle Rule Manager                       VALID      10.2.0.4.0  00:00:07
.
Total Upgrade Time: 00:25:52
DOC>#######################################################################
DOC>#######################################################################
DOC>
DOC>   The above PL/SQL lists the SERVER components in the upgraded
DOC>   database, along with their current version and status.
DOC>
DOC>   Please review the status and version columns and look for
DOC>   any errors in the spool log file.  If there are errors in the spool
DOC>   file, or any components are not VALID or not the current version,
DOC>   consult the Oracle Database Upgrade Guide for troubleshooting
DOC>   recommendations.
DOC>
DOC>   Next shutdown immediate, restart for normal operation, and then
DOC>   run utlrp.sql to recompile any invalid application objects.
DOC>
DOC>#######################################################################
DOC>#######################################################################
DOC>#
SQL> spool off
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down
 
 
$ sqlplus / as sysdba

Connected to an idle instance.

SQL> startup

SQL> spool recompile.log

SQL> @utlrp.sql

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN  2010-07-02 18:23:16

DOC>   The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC>   objects in the database. Recompilation time is proportional to the
DOC>   number of invalid objects in the database, so this command may take
DOC>   a long time to execute on a database with a large number of invalid
DOC>   objects.
DOC>
DOC>   Use the following queries to track recompilation progress:
DOC>
DOC>   1. Query returning the number of invalid objects remaining. This
DOC>      number should decrease with time.
DOC>         SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC>   2. Query returning the number of objects compiled so far. This number
DOC>      should increase with time.
DOC>         SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC>   This script automatically chooses serial or parallel recompilation
DOC>   based on the number of CPUs available (parameter cpu_count) multiplied
DOC>   by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC>   On RAC, this number is added across all RAC nodes.
DOC>
DOC>   UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC>   recompilation. Jobs are created without instance affinity so that they
DOC>   can migrate across RAC nodes. Use the following queries to verify
DOC>   whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC>   1. Query showing jobs created by UTL_RECOMP
DOC>         SELECT job_name FROM dba_scheduler_jobs
DOC>            WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC>   2. Query showing UTL_RECOMP jobs that are running
DOC>         SELECT job_name FROM dba_scheduler_running_jobs
DOC>            WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#

PL/SQL procedure successfully completed.


TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END  2010-07-02 18:23:50


PL/SQL procedure successfully completed.

DOC> The following query reports the number of objects that have compiled
DOC> with errors (objects that compile with errors have status set to 3 in
DOC> obj$). If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#

OBJECTS WITH ERRORS
-------------------
                  0

DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#

ERRORS DURING RECOMPILATION
---------------------------
                          0


PL/SQL procedure successfully completed.

SQL> spool off

/*
  When the script utlrp.sql completes go ahead and verify if all the components are 
  upgraded to 10.2.0.4
*/
set lines 10000
set pages 1000
column comp_name format a40
column version format a12
column status format a6
select comp_name, version, status from sys.dba_registry;

COMP_NAME                                VERSION      STATUS
---------------------------------------- ------------ ------
Oracle Database Catalog Views            10.2.0.4.0   VALID
Oracle Database Packages and Types       10.2.0.4.0   VALID
Oracle Workspace Manager                 10.2.0.4.3   VALID
JServer JAVA Virtual Machine             10.2.0.4.0   VALID
Oracle XDK                               10.2.0.4.0   VALID
Oracle Database Java Packages            10.2.0.4.0   VALID
Oracle Expression Filter                 10.2.0.4.0   VALID
Oracle Data Mining                       10.2.0.4.0   VALID
Oracle Text                              10.2.0.4.0   VALID
Oracle XML Database                      10.2.0.4.0   VALID
Oracle Rule Manager                      10.2.0.4.0   VALID
Oracle interMedia                        10.2.0.4.0   VALID
OLAP Analytic Workspace                  10.2.0.4.0   VALID
Oracle OLAP API                          10.2.0.4.0   VALID
OLAP Catalog                             10.2.0.4.0   VALID
Spatial                                  10.2.0.4.0   VALID
Oracle Enterprise Manager                10.2.0.4.0   VALID

17 rows selected.
 
Si todo fue satisfactorio, al ingresar al motor veras que ya la version es 10.2.0.4.0

SI EL PROCESO DE ACTUALIZACION FALLA

* Deberas restaurar todos los respaldos previamente guardados, de la siguiente manera:

$ echo $ORACLE_HOME
/u01/apps/oracle/product/10.2.0/db_1

$ cd /u01/apps/oracle/product/10.2.0/
$ rm -fr db_1
$ tar xzf /home/oracle/oraHomeBackup.tar.gz *

/* Esto restaura la vieja ruta de ORACLE_HOME */

$ cd /u01/apps/oracle/oradata/
$ rm -fr ora10g
$ tar xzf /home/oracle/ora10g.tar.gz *

/* Esto restaura los control files, redo files, etc */
 
Luego ingresa e inicia el motor y veras que la version es la antiguamente existente:
 
$ sqlplus / as sysdba

Connected to an idle instance.

SQL> startup

set lines 10000
set pages 1000
column comp_name format a40
column version format a12
column status format a6
select comp_name, version, status from sys.dba_registry;

COMP_NAME                                VERSION      STATUS
---------------------------------------- ------------ ------
Oracle Database Catalog Views            10.2.0.1.0   VALID
Oracle Database Packages and Types       10.2.0.1.0   VALID
Oracle Workspace Manager                 10.2.0.1.0   VALID
JServer JAVA Virtual Machine             10.2.0.1.0   VALID
Oracle XDK                               10.2.0.1.0   VALID
Oracle Database Java Packages            10.2.0.1.0   VALID
Oracle Expression Filter                 10.2.0.1.0   VALID
Oracle Data Mining                       10.2.0.1.0   VALID
Oracle Text                              10.2.0.1.0   VALID
Oracle XML Database                      10.2.0.1.0   VALID
Oracle Rules Manager                     10.2.0.1.0   VALID
Oracle interMedia                        10.2.0.1.0   VALID
OLAP Analytic Workspace                  10.2.0.1.0   VALID
Oracle OLAP API                          10.2.0.1.0   VALID
OLAP Catalog                             10.2.0.1.0   VALID
Spatial                                  10.2.0.1.0   VALID
Oracle Enterprise Manager                10.2.0.1.0   VALID

17 rows selected. 
 
 

No hay comentarios:

Publicar un comentario