miércoles, 21 de diciembre de 2011

Parchando una base de datos Oracle 9i

Esta es una transcripción de una sesión donde se aplicó un parche a una base de datos Oracle 9i en un sistema AIX; la plicación de parches con OPatch en general es muy similar en todas las plataformas de Oracle 9i en adelante pero es buena idea leer la documentación de cada parche en particular.

Primero revisamos la disponibilidad de perl y java y su versión ya que es un prerequisito de OPatch; la versión necesaria depende de la versión de OPatch a usar.

myserver:mydb> perl -v

This is perl, v5.8.2 built for aix-thread-multi
(with 3 registered patches, see perl -V for more detail)

Copyright 1987-2003, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

myserver:mydb> java -fullversion
java full version "J2RE 1.4.2 IBM AIX build ca142-20080515 (SR11)"
myserver:mydb> oslevel
5.3.0.0

A continuación agregamos el directorio de OPatch a la ruta de ejecución en caso de que no esté, y listamos el inventario de parches para saber acerca de parches existentes:

myserver:mydb> ls -la $ORACLE_HOME/OPatch
total 64
drwxr-x--- 5 oracle dba 256 Mar 03 2008 .
drwxr-xr-x 57 oracle dba 4096 May 10 11:18 ..
drwxr-x--- 2 oracle dba 256 Mar 03 2008 docs
drwxr-x--- 2 oracle dba 256 Mar 03 2008 jlib
-rwxr-xr-x 1 oracle dba 6143 Jun 09 2005 opatch
-rw-r--r-- 1 oracle dba 0 Mar 03 2008 opatch.ini
-rw-r--r-- 1 oracle dba 13703 Jun 09 2005 opatch.pl
drwxr-x--- 2 oracle dba 4096 Mar 03 2008 perl_modules
myserver:mydb> export PATH=$PATH:$ORACLE_HOME/OPatch
myserver:mydb> opatch lsinventory

Oracle Interim Patch Installer version 1.0.0.0.52
Copyright (c) 2005 Oracle Corporation. All Rights Reserved..

We recommend you refer to the OPatch documentation under
OPatch/docs for usage reference. We also recommend using
the latest OPatch version. For the latest OPatch version
and other support related issues, please refer to document
293369.1 which is viewable from metalink.oracle.com

Oracle Home = /oracle_9i/app/oracle/product/9.2.0
Location of Oracle Universal Installer components = /oracle_9i/app/oracle/product/9.2.0/oui
Location of OraInstaller.jar = "/oracle_9i/app/oracle/product/9.2.0/oui/jlib"
Oracle Universal Installer shared library = /oracle_9i/app/oracle/product/9.2.0/oui/lib/aix/liboraInstaller.so
Location of Oracle Inventory Pointer = /etc/oraInst.loc
Location of Oracle Inventory = /oracle_9i/app/oracle/product/9.2.0/inventory
Path to Java = /oracle_9i/app/oracle/product/9.2.0/jre/1.4.2/bin/java
Log file = /oracle_9i/app/oracle/product/9.2.0/.patch_storage//*.log

Creating log file "/oracle_9i/app/oracle/product/9.2.0/.patch_storage/LsInventory__06-29-2010_16-27-35.log"

Result:


There is no Interim Patch




OPatch succeeded.

Casi siempre es obligatorio (o por lo menos buena idea) detener todas las instancias y servicios de bases de datos dependientes del Oracle Home a parchar; si no quieres detener tus bases de datos revisa si el parche que quieres aplicar puede ser aplicado sin dar de baja los servicios.

myserver:mydb> lsnrctl stop LISTENER_mydb

LSNRCTL for IBM/AIX RISC System/6000: Version 9.2.0.7.0 - Production on 29-JUN-2010 18:03:04

Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myserver)(IP=10.0.0.1)(PORT=1521))(CONNECT_DATA=(SID=mydb)))
The command completed successfully
myserver:mydb> sqlplus '/ as sysdba'

SQL*Plus: Release 9.2.0.7.0 - Production on Tue Jun 29 18:03:28 2010

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.7.0 - Production

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.7.0 - Production

Ahora aplicamos el parche cambiándonos al directorio del parche y ejecutando opatch; OPatch tiene muchas opciones pero aplicar un parche sólo en un Oracle Home es el mas fácil de los escenarios:

myserver:mydb> cd /oracle_resp9/p5496862_92070_AIX64-5L/5496862
myserver:mydb> ls -la
total 16
drwx------ 4 oracle dba 256 Jun 09 11:03 .
drwx------ 3 oracle dba 256 Jun 09 11:03 ..
-rw------- 1 oracle dba 4710 Jun 09 10:52 README.txt
drwx------ 4 oracle dba 256 Jun 09 11:03 etc
drwx------ 4 oracle dba 256 Jun 09 11:03 files
myserver:mxod0012> opatch apply

Oracle Interim Patch Installer version 1.0.0.0.52
Copyright (c) 2005 Oracle Corporation. All Rights Reserved..

We recommend you refer to the OPatch documentation under
OPatch/docs for usage reference. We also recommend using
the latest OPatch version. For the latest OPatch version
and other support related issues, please refer to document
293369.1 which is viewable from metalink.oracle.com

Oracle Home = /oracle_9i/app/oracle/product/9.2.0
Location of Oracle Universal Installer components = /oracle_9i/app/oracle/product/9.2.0/oui
Location of OraInstaller.jar = "/oracle_9i/app/oracle/product/9.2.0/oui/jlib"
Oracle Universal Installer shared library = /oracle_9i/app/oracle/product/9.2.0/oui/lib/aix/liboraInstaller.so
Location of Oracle Inventory Pointer = /etc/oraInst.loc
Location of Oracle Inventory = /oracle_9i/app/oracle/product/9.2.0/inventory
Path to Java = /oracle_9i/app/oracle/product/9.2.0/jre/1.4.2/bin/java
Log file = /oracle_9i/app/oracle/product/9.2.0/.patch_storage//*.log

Creating log file "/oracle_9i/app/oracle/product/9.2.0/.patch_storage/5496862/Apply_5496862_06-29-2010_18-11-21.log"

Invoking fuser to check for active processes.

Backing up comps.xml ...

OPatch detected non-cluster Oracle Home from the inventory and will patch the local system only.


Please shut down Oracle instances running out of this ORACLE_HOME
(Oracle Home = /oracle_9i/app/oracle/product/9.2.0)
Is this system ready for updating?
Please respond Y|N >
Y
Patching...
Printing stderr to output (from /oracle_9i/app/oracle/product/9.2.0/.patch_storage/5496862/make_local.stderr)
ar: Creating an archive file /oracle_9i/app/oracle/product/9.2.0/lib/libclntst9.a.

ar: Creating an archive file /oracle_9i/app/oracle/product/9.2.0/lib32/libclntst9.a.


...


Updating inventory...
Backing up comps.xml ...


OPatch succeeded.

Después de aplicar el parche levantamos las instancias y servicios de bases de datos y revisamos la nueva versión de Oracle (si aplica); algunos parches requieren que ejecutes scripts para cambiar las bases de datos y otros no por lo cual no olvides leer la documentación del parche.

myserver:mydb> sqlplus '/ as sysdba'

SQL*Plus: Release 9.2.0.7.0 - Production on Tue Jun 29 18:20:06 2010

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 253723320 bytes
Fixed Size 742072 bytes
Variable Size 184549376 bytes
Database Buffers 67108864 bytes
Redo Buffers 1323008 bytes
Database mounted.
Database opened.
SQL> select * from v$instance;

INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
HOST_NAME
----------------------------------------------------------------
VERSION STARTUP_T STATUS PAR THREAD# ARCHIVE LOG_SWITCH_
----------------- --------- ------------ --- ---------- ------- -----------
LOGINS SHU DATABASE_STATUS INSTANCE_ROLE ACTIVE_ST
---------- --- ----------------- ------------------ ---------
1 mydb
myserver
9.2.0.7.0 29-JUN-10 OPEN NO 1 STOPPED
ALLOWED NO ACTIVE PRIMARY_INSTANCE NORMAL


SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.7.0 - Production

myserver:mydb> lsnrctl start LISTENER_mydb

LSNRCTL for IBM/AIX RISC System/6000: Version 9.2.0.7.0 - Production on 29-JUN-2010 18:22:35

Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.

Starting /oracle_9i/app/oracle/product/9.2.0/bin/tnslsnr: please wait...

TNSLSNR for IBM/AIX RISC System/6000: Version 9.2.0.7.0 - Production
System parameter file is /oracle_9i/app/oracle/product/9.2.0/network/admin/listener.ora
Log messages written to /oracle_9i/app/oracle/product/9.2.0/network/log/listener_mydb.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=hsodbc)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=mydb)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=myserver)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=IPC)(KEY=hsodbc))
STATUS of the LISTENER
------------------------
Alias LISTENER_mydb
Version TNSLSNR for IBM/AIX RISC System/6000: Version 9.2.0.7.0 - Production
Start Date 29-JUN-2010 18:22:35
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security OFF
SNMP OFF
Listener Parameter File /oracle_9i/app/oracle/product/9.2.0/network/admin/listener.ora
Listener Log File /oracle_9i/app/oracle/product/9.2.0/network/log/listener_mydb.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=hsodbc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=mydb)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=myserver)(PORT=1521)))
Services Summary...
Service "mydb" has 1 instance(s).
Instance "mydb", status UNKNOWN, has 1 handler(s) for this service...
Service "hsodbc" has 1 instance(s).
Instance "hsodbc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

myserver:mydb> tnsping mydb

TNS Ping Utility for IBM/AIX RISC System/6000: Version 9.2.0.7.0 - Production on 29-JUN-2010 18:27:02

Copyright (c) 1997 Oracle Corporation. All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL=TCP) (HOST=myserver) (IP=10.0.0.1) (PORT=1521))) (CONNECT_DATA = (SID=mydb)))
OK (90 msec)

Finalmente, listamos de nuevo el inventario de parches y debemos ver el parche recién aplicado:

myserver:mydb> opatch lsinventory

Oracle Interim Patch Installer version 1.0.0.0.52
Copyright (c) 2005 Oracle Corporation. All Rights Reserved..

We recommend you refer to the OPatch documentation under
OPatch/docs for usage reference. We also recommend using
the latest OPatch version. For the latest OPatch version
and other support related issues, please refer to document
293369.1 which is viewable from metalink.oracle.com

Oracle Home = /oracle_9i/app/oracle/product/9.2.0
Location of Oracle Universal Installer components = /oracle_9i/app/oracle/product/9.2.0/oui
Location of OraInstaller.jar = "/oracle_9i/app/oracle/product/9.2.0/oui/jlib"
Oracle Universal Installer shared library = /oracle_9i/app/oracle/product/9.2.0/oui/lib/aix/liboraInstaller.so
Location of Oracle Inventory Pointer = /etc/oraInst.loc
Location of Oracle Inventory = /oracle_9i/app/oracle/product/9.2.0/inventory
Path to Java = /oracle_9i/app/oracle/product/9.2.0/jre/1.4.2/bin/java
Log file = /oracle_9i/app/oracle/product/9.2.0/.patch_storage//*.log

Creating log file "/oracle_9i/app/oracle/product/9.2.0/.patch_storage/LsInventory__06-29-2010_18-26-05.log"

Result:


Installed Patch List:
=====================
1) Patch 5496862 applied on Tue Jun 29 17:15:41 GMT-06:00 2010
[ Base Bug(s): 5496862 ]




OPatch succeeded.

No hay comentarios.:

Publicar un comentario