Instalacion de Oracle 26ai- Creacion de ASM

Seguimos con la seria de la instalación de un Oracle 26ai , ahora vamos a por el ASM

El appliance en el que estoy usando de laboratorio es bastante raquítico, con un pequeño disco de 100Gb, por lo que habra que apañarse con lo que tenemos,.
Mi configuracion de disco es :

[root@gigabyte u01]# fdisk -l
Disk /dev/sda: 111.79 GiB, 120034123776 bytes, 234441648 sectors
Disk model: KINGSTON SUV400S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x00fde38f

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048 156250111 156248064 74.5G 83 Linux
/dev/sda2       156250112 181415935  25165824   12G 82 Linux swap / Solaris

Asi que vamos a crear dos discos pequeños de 5 Gb que pondremos en /dev/sda3 y /dev/sda4 para poder hacer ver que tenemos un DATA y FRA , el disco quedará:

[root@gigabyte ~]# fdisk -l
Disk /dev/sda: 111.79 GiB, 120034123776 bytes, 234441648 sectors
Disk model: KINGSTON SUV400S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x00fde38f

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048 156250111 156248064 74.5G 83 Linux
/dev/sda2       156250112 181415935  25165824   12G 82 Linux swap / Solaris
/dev/sda3       181415936 191180799   9764864  4.7G 83 Linux
/dev/sda4       191180800 200945663   9764864  4.7G 83 Linux

Descargaremos el asmlib desde
https://www.oracle.com/linux/downloads/linux-asmlib-v9-downloads.html e instalaremos los paquetes.
Una vez instalados,configuraremos el orcleasm

[root@gigabyte ~]# oracleasm configure -i
Configuring the Oracle ASM system service.
This will configure the on-boot properties of the Oracle ASM system
service.  The following questions will determine whether the service
is started on boot and what permissions it will have.  The current
values will be shown in brackets ('[]').  Hitting  without
typing an answer will keep that current value.  Ctrl-C will abort.
Default user to own the ASM disk devices []: grid
Default group to own the ASM disk devices []: asmdba
Start Oracle ASM system service on boot (y/n) [y]: y
Scan for Oracle ASM disks when starting the oracleasm service (y/n) [y]: y
Maximum number of ASM disks that can be used on system [2048]:
Enable iofilter if kernel supports it (y/n) [y]: y
Writing Oracle ASM system service configuration: done

Configuration changes only come into effect after the Oracle ASM
system service is restarted.  Please run 'systemctl restart oracleasm'
after making changes.

WARNING: All of your Oracle and ASM instances must be stopped prior
to restarting the oracleasm service.

[root@gigabyte ~]# systemctl stop oracleasm
[root@gigabyte ~]# systemctl start oracleasm
[root@gigabyte ~]# systemctl status oracleasm
● oracleasm.service - Oracle ASM Service
     Loaded: loaded (/usr/lib/systemd/system/oracleasm.service; enabled; preset: disabled)
     Active: active (exited) since Wed 2026-01-28 17:06:33 CET; 4s ago
    Process: 5027 ExecStartPre=/usr/bin/udevadm settle -t 120 (code=exited, status=0/SUCCESS)
    Process: 5028 ExecStart=/usr/sbin/oracleasm.init start (code=exited, status=0/SUCCESS)
   Main PID: 5028 (code=exited, status=0/SUCCESS)
        CPU: 378ms

Jan 28 17:06:33 gigabyte.pamplona.name systemd[1]: Starting Oracle ASM Service...
Jan 28 17:06:33 gigabyte.pamplona.name oracleasm.init[5042]: Mounting oracleasm driver filesystem: Not applicable with UEK8
Jan 28 17:06:33 gigabyte.pamplona.name oracleasm.init[5053]: Reloading disk partitions: done
Jan 28 17:06:33 gigabyte.pamplona.name oracleasm.init[5053]: Cleaning any stale ASM disks...
Jan 28 17:06:33 gigabyte.pamplona.name oracleasm.init[5053]: Setting up iofilter map for ASM disks: done
Jan 28 17:06:33 gigabyte.pamplona.name oracleasm.init[5065]: Scanning system for ASM disks...
Jan 28 17:06:33 gigabyte.pamplona.name oracleasm.init[5081]: Disk scan successful
Jan 28 17:06:33 gigabyte.pamplona.name systemd[1]: Finished Oracle ASM Service.

Como formatear los discos

crearemos los discos, en mi caso, al ser un pequeño sistema de prueba,estos han de ser particiones en un disco, en el caso de produccion,creariamos una particion única para cada disco.

[root@gigabyte ~]# oracleasm  createdisk DATA01 /dev/sda3
Writing disk header: done
Instantiating disk: done
[root@gigabyte ~]# oracleasm  createdisk FRA01 /dev/sda4
Writing disk header: done
Instantiating disk: done

[root@gigabyte ~]# oracleasm  scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Setting up iofilter map for ASM disks: done
Scanning system for ASM disks...

[root@gigabyte ~]# oracleasm  listdisks
DATA01
FRA01

Evitar problemas con SElinux

Para evitar problemas en los siguientes pasos con con SeLinux, ejecutaremos :

semanage fcontext -a -e /bin /u01/app/grid/bin
semanage fcontext -a -e /lib /u01/app/grid/lib
semanage fcontext -a -e /etc /etc/oracle/scls_scr

Configurar el CRS/HAS

Una vez tenemos los discos creados, procederemos a configurar el CRS,para eso, como root
ejecutaremos:

[root@gigabyte ~]# export GI_HOME=/u01/app/grid
[root@gigabyte ~]#  $GI_HOME/perl/bin/perl -I $GI_HOME/perl/lib -I $GI_HOME/crs/install $GI_HOME/crs/install/roothas.pl
Using configuration parameter file: /u01/app/grid/crs/install/crsconfig_params
The log of current session can be found at:
  /u01/app/oracle/crsdata/gigabyte/crsconfig/roothas_2026-01-28_05-21-47PM.log
2026/01/28 17:21:52 CLSRSC-363: User ignored prerequisites during installation
LOCAL ADD MODE
Creating OCR keys for user 'grid', privgrp 'oinstall'..
Operation successful.
2026/01/28 17:23:12 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'

gigabyte     2026/01/28 17:25:07     /u01/app/oracle/crsdata/gigabyte/olr/backup_20260128_172507.olr     2107015493
2026/01/28 17:25:09 CLSRSC-327: Successfully configured Oracle Restart for a standalone server

configuracion de oracle net

Como usuario grid iremos a $ORACLE_HOME/network/admin y crearemos los ficheros
sqlnet.ora

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
DIAG_ADR_ENABLED=ON
SQLNET.EXPIRE_TIME= 10
SQLNET.INBOUND_CONNECT_TIMEOUT=60

listener.ora

LISTENER =
   (DESCRIPTION_LIST =
    (DESCRIPTION =
       (ADDRESS = (PROTOCOL = TCP)(HOST = gigabyte.pamplona.name)(PORT = 1521))
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      )
   )
USE_SID_AS_SERVICE_LISTENER=ON
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON
VALID_NODE_CHECKING_REGISTRATION_LISTENER=ON
LOG_FILE_SIZE_LISTENER=50
LOG_FILE_NUM_LISTENER=365

Y despues, crearemos el servicio del listner

grid@gigabyte admin]$ $GI_HOME/bin/srvctl add listener -listener LISTENER -oraclehome  $GI_HOME

grid@gigabyte admin]$ $GI_HOME/bin/srvctl start listener

[grid@gigabyte admin]$ $GI_HOME/bin/crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
               ONLINE  ONLINE       gigabyte                 STABLE
ora.ons
               OFFLINE OFFLINE      gigabyte                 STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        OFFLINE OFFLINE                               STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.evmd
      1        ONLINE  ONLINE       gigabyte                 STABLE
--------------------------------------------------------------------------------

creacion del ASM

Ahora crearemos el ASM con:

[grid@gigabyte admin]$ $GI_HOME/bin/asmca -silent \
      -configureASM \
      -sysAsmPassword CHANGE.me.26ai \
      -asmsnmpPassword CHANGE.me.26ai \
      -diskString "ORCL:*"  \
      -diskGroupName DATA \
      -disk "ORCL:DATA*" \
      -param ASM_POWER_LIMIT=1 \
      -param DIAGNOSTIC_DEST=$ORACLE_BASE \
      -param AUDIT_SYS_OPERATIONS=TRUE \
      -redundancy EXTERNAL



ASM has been created and started successfully.

[DBT-30001] Disk groups created successfully. Check /u01/app/oracle/cfgtoollogs/asmca/asmca-260128PM053656.log for details.

Luego, craremos los otros diskgroups al estilo de

$GI_HOME/bin/asmca -silent \
      -createDiskGroup \
      -sysAsmPassword CHANGE.me.26ai \
      -asmsnmpPassword CHANGE.me.26ai \
      -diskString "ORCL:*"  \
      -diskGroupName FRA \
      -disk "ORCL:FRA*" \
      -param ASM_POWER_LIMIT=1 \
      -param DIAGNOSTIC_DEST=$ORACLE_BASE \
      -param AUDIT_SYS_OPERATIONS=TRUE \
      -redundancy EXTERNAL
[DBT-30001] Disk groups created successfully. Check /u01/app/oracle/cfgtoollogs/asmca/asmca-260128PM053938.log for details.

Con esto, ya tendremos el asm creado e instalado en nuestra versio

[grid@gigabyte admin]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       gigabyte                 STABLE
ora.FRA.dg
               ONLINE  ONLINE       gigabyte                 STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       gigabyte                 STABLE
ora.asm
               ONLINE  ONLINE       gigabyte                 Started,STABLE
ora.ons
               OFFLINE OFFLINE      gigabyte                 STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       gigabyte                 STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.evmd
      1        ONLINE  ONLINE       gigabyte                 STABLE
--------------------------------------------------------------------------------
[grid@gigabyte admin]$ asmcmd lsdg
State    Type    Rebal  Sector  Logical_Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512             512   4096  1048576      4768     4701                0            4701              0             N  DATA/
MOUNTED  EXTERN  N         512             512   4096  1048576      4768     4704                0            4704              0             N  FRA/

Siguiente paso.. creación de una base de datos 26ai

Evitar mensajes SWITCHOVER de dataguard en el alert log

Hoy vamos a ver un caso sencillo que puede dar algun susto si no sabemos de donde viene.

Ultimamente habreis visto que en el alert log de vuestras bases de datos donde tenemos Dataguards activados, tenemos unos sospechosos mensajes relativos al SWIRCHOVER del estilo

 Mem# 0: +REDO1/WINTRA_STBY/ONLINELOG/group_12.430.1176371311
  Mem# 1: +REDO2/ORCL_SITE2/ONLINELOG/group_12.448.1176371317
2024-12-09T12:04:01.654207+01:00
ARC4 (PID:22664): Archived Log entry 1874 added for T-6.S-29707 ID 0xf4a75427 LAD:1
2024-12-09T12:04:02.545651+01:00
 rfs (PID:3350): Selected LNO:10 for T-5.S-22376 dbid 4104620583 branch 722623079
2024-12-09T12:04:02.595323+01:00
PR00 (PID:22983): Media Recovery Waiting for T-5.S-22376 (in transit)
2024-12-09T12:04:02.609412+01:00
Recovery of Online Redo Log: Thread 5 Group 10 Seq 22376 Reading mem 0
  Mem# 0: +REDO1/ORCL_SITE2/ONLINELOG/group_10.419.1176369743
  Mem# 1: +REDO2/ORCL_SITE2/ONLINELOG/group_10.437.1176369749
2024-12-09T12:04:02.973552+01:00
ARC1 (PID:22656): Archived Log entry 1875 added for T-5.S-22375 ID 0xf4a75427 LAD:1
2024-12-09T12:47:21.593967+01:00
 rfs (PID:5113): krsr_rfs_atc: Identified database type as 'PHYSICAL STANDBY': Client is Foreground (PID:26765)
2024-12-09T12:47:23.731609+01:00
SWITCHOVER VERIFY BEGIN
SWITCHOVER VERIFY COMPLETE
2024-12-09T13:32:28.283411+01:00
 rfs (PID:5336): krsr_rfs_atc: Identified database type as 'PHYSICAL STANDBY': Client is Foreground (PID:29093)
2024-12-09T13:32:30.524186+01:00
SWITCHOVER VERIFY BEGIN
SWITCHOVER VERIFY COMPLETE
2024-12-09T14:17:29.627321+01:00
 rfs (PID:3408): krsr_rfs_atc: Identified database type as 'PHYSICAL STANDBY': Client is Foreground (PID:540)
2024-12-09T14:17:31.443773+01:00
SWITCHOVER VERIFY BEGIN
SWITCHOVER VERIFY COMPLETE

La primera pregunta que nos hacemos es

Quien demonios esta haciendo el SWITHVER VERIFY en nuestro dataguard?

La respuesta es, que lo hace el propio Oracle.
Parece ser que, a Oracle se les ha escapado sin avisar un cambio que hace que el TFA ejecute periodicamente DGMGRL VALIDATE DATABASE, lo que nos genera estos mensajes en el alert.log.

Esta previsto que esto se solucione en AHF 24.8 , donde el comando validate no estara en el schedule del TFA.

Tenemos que esperarnos a que se libere esa version?

Afortunadamente no, ya que podemos eliminar esa ejecucion de nuestro profile de ejecucion con con el comando

# tfactl modifyprofile db_dataguard disable 

Corrupcion de bloques no detectados por validate

Hoy vamos a ver una entada que nos puede traer un poco de cabeza.

Supongamos tenemos la tipica consulta que nos devuelve un error de corrupcion de bloque ORA-01578: ORACLE data block corrupted

SQL> select something from sometable  where file_name='whatever';
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 377, block # 2818432)
ORA-01110: data file 377:
'+DATA/TESTDB/DATAFILE/TESTDB.20221119.110001.377.dbf' 

Ante este error, nuestros pasos suelen ser claros.

  • Buscamos los bloques corruptos con rman validate o en su defecto dbverify dbv
  • Comprobamos la vista V$DATABASE_BLOCK_CORRUPTION;
  • Recuperamos de backup datafile & block recover datafile 377block 2818432;

Pero , que ocurre si tras ejecutar el validate o el dbv ?

Si miramos el alert.log durane la validacion, veremos lineas con el contenido

TESTDB(3):Completely zero block found during validation

Esto nos indica que es un error en un bloque que contiene solo ceros.
Oracle por diseño no escribe bloques con todo ceros, por lo que este error es heredado del sistema operativo o el sistema de almacenamiento.

Para solucionar este problema deberemos de recuperar ese datafile desde un backup con cualquiera de los metodos soportados

Mas informacion como siempre en Oracle Support

  • Physical Corrupted Blocks consisting of all Zeroes indicate a problem with OS, HW or Storage (Doc ID 1545366.1)

Bucle sleep en codigo PL-SQL

Vamos a ver una entrada rapidisima y sencillisima para dummies.

Como introducimos una espera en codigo PL-SQL

La respuesta es sencillisima, con la funcion DBMS_LOCK.SLEEP
Veamos por ejemplo como forzar dos esperas de 1 minuto para obtener un hang analyzer

$ORACLE_HOME/bin/sqlplus -s "/as sysdba" << EOF
oradebug setmypid;
oradebug unlimit;
oradebug hanganalyze 3;
exec dbms_lock.sleep(60);
-- Wait upto 1 minute before getting the second hanganalyze
oradebug hanganalyze 3;
-- Wait upto 1 minute before getting the second hanganalyze
exec dbms_lock.sleep(60);
oradebug hanganalyze 3;
oradebug tracefile_name;
EOF

Uso de variables de entorno en script sde rman

Hoy vamos a ver una entrada muy rapida para dummies.

Muchas veces queremos hacer que el log de rman tenga una variable de entorno ( usualmente a fecha),haciendo algo similar a

#!/bin/bash
HORA=`date +%Y%m%d_%H:%M:%S`
rman  cmdfile restore_${ORACLE_SID}.cmd  log logs/${HORA}_restore_${ORACLE_SID}.log

Pero cuando vamos al subdirecorio de logs nos encontramos con que nos ha creado un fichero llamado ${HORA}_restore_${ORACLE_SID}.log

Como solucionamos esto?

La solucion no pasa por jugar con las comillas sino con el uso del parametro MSGLOG
Simplemente tendremos que cambiar nuestro script por

#!/bin/bash
HORA=`date +%Y%m%d_%H:%M:%S`
rman  cmdfile restore_${ORACLE_SID}.cmd  MSGLOG logs/${HORA}_restore_${ORACLE_SID}.log

Y funcionara tal y como queremos