Correlar discos de ASM con sistema

Hoy vamos a ver un pequenio y sendillo script para correlar los discos del sistema operativo y el ASM

#!/bin/bash
for i in `ls /dev/oracleasm/disks/ `; do
ASMDEVICE=/dev/oracleasm/disks/$i
#echo "Looking for $ASMDEVICE"
MINOR=`ls -l ${ASMDEVICE} |awk '{ print $5}'`
MAYOR=`ls -l ${ASMDEVICE} |awk '{ print $6}'`
DISKDEV=`ls -l /dev |grep -w $MAYOR | grep -w $MINOR|awk '{ print $10}'`
echo " The ASM device $ASMDEVICE is $DISKDEV"
#echo "The device $ASMDEVICE has a mayor=$MAYOR and minor=$MINOR"
#ls -l /dev/$DISKDEV
#ls -l ${ASMDEVICE}
#echo "====================================="
done

Como crear un asm sin tener discos

Hoy vamos a ver como hacerle trampas a Oracle para levatar una instancia de ASM sin tener discos en el servidor.

Supongamos que el ORACLE_HOME del grid lo tenemos en /u01/app/oracle/product/19c/grid, los pasos a seguir serian


-- == Fake disk 
sudo dd if=/dev/zero of= /u01/app/oracle/product/19c/grid/ASMFAKE.img bs=1M count=5000
sudo losetup /dev/loop1  /u01/app/oracle/product/19c/grid/ASMFAKE.img
 

  
sudo /usr/sbin/asmtool -C -l /dev/oracleasm -n FAKE1  -s /dev/loop1 -a force=yes
sudo /usr/sbin/oracleasm scandisks
sudo /usr/sbin/oracleasm listdisks

Con esto, cuando ejecutemos el asmca vermos que hay un disco llamado FAKE1 que no es otra cosa que el disc ASMFAKE que hemos creado.

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

Comandos basicos del Trace File Analyzer

Hoy vamos a ver los comandos y acciones basicas del tafcl
El tafcl es el comando de ejecucion del Trace File Analyzer (TFA), este pequeño script esta incluido dentro de la suite Autonomous Health Framework (AHF) , y sera o primero que nos solicite Oracle support una vez abramos un SR

Instalacion

Nos descargaremos el paquete de la AHF de la nota de soporte Autonomous Health Framework (AHF) – Including TFA and ORAchk/EXAchk (Doc ID 2550798.1 Y lo ejecutaremos como superusuario el comando ahf_setup.
Este comando tiene varias opciones

   Usage for ./ahf_setup

   ./ahf_setup [[-ahf_loc ][-data_dir ][-nodes ][-extract[orachk|exachk|-notfasetup] [-local][-silent][-tmp_loc ][-force][-debug [-level <1-6>]]]

        -ahf_loc          -    Install into the directory supplied. (Default /opt/oracle.ahf)
        -data_dir         -    AHF Data Directory where all the collections, metadata, etc. will be stored
        -nodes            -    Comma separated Remote Node List
        -extract          -    Extract only files from Installer. (Default for non-root users)
        -nosymlink        -    Do not create symlinks on Exadata DOM0. (Default for non-root users)
        -notfasetup       -    Do not Configure TFA when used with -extract
        -local            -    Only install on the local node
        -silent           -    Do not ask any install questions
        -tmp_loc          -    Temporary location directory for AHF to extract the install archive to (must exist) (Default /tmp)
        -perlhome         -    Custom location of perl binaries
        -force            -    Force AHF Install
        -debug            -    Debug AHF Install Script
        -level            -    AHF Instal Debug Level 1-6 (Default 4 with option -debug)
                               [FATAL - 1, ERROR - 2, WARNING - 3, INFO - 4, DEBUG - 5, TRACE - 6]

Si la instalacionn se hizo de manera estandard, el mismo TFA detectara la instalacion anterior y se actualizara.
Veamos un ejemplo de actualizacion.

[oracle@rac1 tmp]$ sudo ./ahf_setup 

AHF Installer for Platform Linux Architecture x86_64

AHF Installation Log : /tmp/ahf_install_211000_21804_2021_04_01-09_22_26.log

Starting Autonomous Health Framework (AHF) Installation

AHF Version: 21.1.0 Build Date: 202104131158

AHF is already installed at /opt/oracle.ahf

Installed AHF Version: 20.2.3 Build Date: 202010132201

Do you want to upgrade AHF [Y]|N : Y

Upgrading /opt/oracle.ahf

Shutting down AHF Services
Shutting down TFA
Removed symlink /etc/systemd/system/multi-user.target.wants/oracle-tfa.service.
Removed symlink /etc/systemd/system/graphical.target.wants/oracle-tfa.service.
. . . . .
. . .
Successfully shutdown TFA..


Starting AHF Services
Starting TFA..
Created symlink from /etc/systemd/system/multi-user.target.wants/oracle-tfa.service to /etc/systemd/system/oracle-tfa.service.
Created symlink from /etc/systemd/system/graphical.target.wants/oracle-tfa.service to /etc/systemd/system/oracle-tfa.service.
Waiting up to 100 seconds for TFA to be started..
. . . . .
. . . . .
. . . . .
Successfully started TFA Process..
. . . . .
TFA Started and listening for commands
No new directories were added to TFA


INFO: Starting orachk scheduler in background. Details for the process can be found at /opt/app/oracle/oracle.ahf/data/rac1/diag/orachk/compliance_start_230421_093124.log


AHF is successfully upgraded to latest version

.------------------------------------------------------------------.
| Host       | TFA Version | TFA Build ID         | Upgrade Status |
+------------+-------------+----------------------+----------------+
| rac1 |  21.1.0.0.0 | 21100020210413115827 | UPGRADED       |
| rac2 |  20.2.3.0.0 | 20230020201013220107 | NOT UPGRADED   |
'------------+-------------+----------------------+----------------'

Moving /tmp/ahf_install_211000_21804_2021_04_01-09_22_26.log to /opt/app/oracle/oracle.ahf/data/rac1/diag/ahf/

Usos comunes

Obtener informacion de las trazas en un determninado tiempo

Si quremos recabar informacion del sistema entre unas determinadas fechas usaremos los fags -from  -to
./tfactl diagcollect -from "2021-04-07 08:00:00" -to "2021-04-07 10:00:00"

Obtener informacion ded un determinado error

Si quremos obtener informacion del sistema sobre un determinado error, usaremos el flag srdc

./tfactl diagcollect -srdc ORA-07445

Gestion del repositorio

Ver la configuration

 
tfactl> print config
.---------------------------------------------------------------------------------------------------------------------.
|                                                      wiracdev02                                                     |
+--------------------------------------------------------------------------------------------------------+------------+
| Configuration Parameter                                                                                | Value      |
+--------------------------------------------------------------------------------------------------------+------------+
| TFA Version ( tfaversion )                                                                             | 21.1.0.0.0 |
| Java Version ( javaVersion )                                                                           | 1.8        |
| Public IP Network ( publicIp )                                                                         | true       |
| Repository current size (MB) ( currentsizemegabytes )                                                  | 293        |
| Repository maximum size (MB) ( maxsizemegabytes )                                                      | 10240      |
| Cluster Event Monitor ( clustereventmonitor )                                                          | ON         |
| scandiskmon                                                                                            | OFF        |
| scanacfslog                                                                                            | OFF        |
| File Data Collection ( inventory )                                                                     | ON         |
| Automatic Purging ( autoPurge )                                                                        | ON         |
| Internal Search String ( internalSearchString )                                                        | ON         |
| ISA Data Gathering ( collection.isa )                                                                  | ON         |
| Trim Files ( trimfiles )                                                                               | ON         |
| collectTrm                                                                                             | OFF        |
| chmdataapi                                                                                             | ON         |
| chanotification ( chanotification )                                                                    | ON         |
| Managelogs Auto Purge ( manageLogsAutoPurge )                                                          | OFF        |
| scanacfseventlog                                                                                       | OFF        |
| Alert Log Scan ( rtscan )                                                                              | ON         |
| debugips                                                                                               | OFF        |
| generateZipMetadataJson                                                                                | ON         |
| collectAllDirsByFile                                                                                   | ON         |
| scanvarlog                                                                                             | OFF        |
| Auto Diagcollection ( autodiagcollect )                                                                | ON         |
| Public IP Network ( publicIp )                                                                         | ON         |
| Flood Control ( floodcontrol )                                                                         | ON         |
| Generation of Mini Collections ( minicollection )                                                      | ON         |
| odscan                                                                                                 | ON         |
| Disk Usage Monitor ( diskUsageMon )                                                                    | ON         |
| Discovery ( discovery )                                                                                | ON         |
| analyze                                                                                                | OFF        |
| indexInventory                                                                                         | ON         |
| Generation of Telemetry Data ( telemetry )                                                             | OFF        |
| chaautocollect                                                                                         | ON         |
| Granular Tracing ( granulartracing )                                                                   | OFF        |
| minPossibleSpaceForPurge                                                                               | 1024       |
| disk.threshold                                                                                         | 90         |
| mem.swapfree                                                                                           | 5120       |
| mem.util.samples                                                                                       | 4          |
| inventoryThreadPoolSize                                                                                | 1          |
| mem.swaptotal.samples                                                                                  | 2          |
| maxFileAgeToPurge                                                                                      | 1440       |
| mem.free                                                                                               | 20480      |
| actionrestartlimit                                                                                     | 30         |
| Minimum Free Space to enable Alert Log Scan (MB) ( minSpaceForRTScan )                                 | 500        |
| cpu.io.samples                                                                                         | 30         |
| mem.util                                                                                               | 80         |
| Maximum single Zip File Size (MB) ( maxZipSize )                                                       | 2048       |
| Time interval between consecutive Disk Usage Snapshot(minutes) ( diskUsageMonInterval )                | 60         |
| TFA ISA Purge Thread Delay (minutes) ( tfaDbUtlPurgeThreadDelay )                                      | 60         |
| firstDiscovery                                                                                         | 0          |
| TFA IPS Pool Size ( tfaIpsPoolSize )                                                                   | 5          |
| Maximum File Collection Size (MB) ( maxFileCollectionSize )                                            | 5120       |
| Time interval between consecutive Managelogs Auto Purge(minutes) ( manageLogsAutoPurgeInterval )       | 60         |
| arc.backupmissing.samples                                                                              | 2          |
| cpu.util.samples                                                                                       | 2          |
| cpu.usr.samples                                                                                        | 2          |
| cpu.sys                                                                                                | 50         |
| Flood Control Limit Count ( fc.limit )                                                                 | 3          |
| Flood Control Pause Time (minutes) ( fc.pauseTime )                                                    | 120        |
| Maximum Number of TFA Logs ( maxLogCount )                                                             | 10         |
| DB Backup Delay Hours ( dbbackupdelayhours )                                                           | 27         |
| cdb.backup.samples                                                                                     | 1          |
| arc.backupstatus                                                                                       | 1          |
| purgeFrequency                                                                                         | 4          |
| TFA ISA Purge Age (seconds) ( tfaDbUtlPurgeAge )                                                       | 2592000    |
| Maximum Collection Size of Core Files (MB) ( maxCoreCollectionSize )                                   | 200        |
| cpu.util                                                                                               | 80         |
| mem.swapfree.samples                                                                                   | 2          |
| cdb.backupstatus                                                                                       | 1          |
| mem.swaputl.samples                                                                                    | 2          |
| arc.backup.samples                                                                                     | 3          |
| unreachablenodeTimeOut                                                                                 | 3600       |
| Flood Control Limit Time (minutes) ( fc.limitTime )                                                    | 60         |
| mem.swaputl                                                                                            | 10         |
| mem.free.samples                                                                                       | 2          |
| Maximum Size of Core File (MB) ( maxCoreFileSize )                                                     | 20         |
| disk.samples                                                                                           | 2          |
| cpu.sys.samples                                                                                        | 30         |
| cpu.usr                                                                                                | 98         |
| arc.backupmissing                                                                                      | 1          |
| cpu.io                                                                                                 | 20         |
| Archive Backup Delay Minutes ( archbackupdelaymins )                                                   | 40         |
| inventoryPurgeThreadInterval                                                                           | 720        |
| Age of Purging Collections (Hours) ( minFileAgeToPurge )                                               | 12         |
| cpu.idle.samples                                                                                       | 2          |
| unreachablenodeSleepTime                                                                               | 300        |
| cpu.idle                                                                                               | 20         |
| mem.swaptotal                                                                                          | 24         |
| TFA ISA CRS Profile Delay (minutes) ( tfaDbUtlCrsProfileDelay )                                        | 720        |
| cdb.backupmissing                                                                                      | 1          |
| cdb.backupmissing.samples                                                                              | 2          |
| Trim Size ( trimsize )                                                                                 | 500000     |
| Maximum Size of TFA Log (MB) ( maxLogSize )                                                            | 52428800   |
| minTimeForAutoDiagCollection                                                                           | 300        |
| skipScanThreshold                                                                                      | 100        |
| fileCountInventorySwitch                                                                               | 5000       |
| TFA ISA Purge Mode ( tfaDbUtlPurgeMode )                                                               | profile    |
| country                                                                                                | US         |
| Debug Mask (Hex) ( debugmask )                                                                         | 0x000000   |
| Setting for ACR redaction (none|SANITIZE|MASK) ( redact )                                              | none       |
| language                                                                                               | en         |
| AlertLogLevel                                                                                          | ALL        |
| BaseLogPath                                                                                            | ERROR      |
| encoding                                                                                               | UTF-8      |
| UserLogLevel                                                                                           | ALL        |
| Logs older than the time period will be auto purged(days[d]|hours[h]) ( manageLogsAutoPurgePolicyAge ) | 30d        |
| isaMode                                                                                                | enabled    |
'--------------------------------------------------------------------------------------------------------+------------'


cambio de ubicacion

Supongamos que queremos mover la ubicacion a un directorio compartido.
La ultima rama del repositorio debe de llamarse repository

tfactl set repositorydir=/mnt/tfa/repository 

Desinstalacion

Para su desinstalacion simplemente tenemos que ejecutarlo con el flag uninstall

[root@rac1 ~]$ which tfactl
/opt/app/12.1/grid/bin/tfactl
[root@rac1 ~]$  /opt/app/12.1/grid/bin/tfactl uninstall

Como siempre, mas infrmacion en oracle support:

Error PRKO-2207 : Warning:–spfile option has been deprecated and will be ignored

Hoy me he encontrado con un eroor curioso.
Cuando he intentado modificar la ubicacionn del spfile con el comando

srvctl modify asm -spfile +DATA/ASM/ASMPARAMETERFILE/initasm.ora

El sistema me ha devuelto el error
PRKO-2207 : Warning:-spfile option has been deprecated and will be ignored

Cual ha sido mi sorpresa al ver que la modificacion del spfile o el listener en el asm con el comando srvctl esta deprecated.
Segun lanota de soporte «PRKO-2207 : Warning:-spfile option has been deprecated and will be ignored» for ASM instance (Doc ID 2227045.1) la manera de llevarlo a cabo ahora es mediante os comandos de oracle, estoson: