Remplacement de WM_CONCAT par LISTAGG

SELECT mess_val_col1,
       WM_CONCAT(mepj_fichier_nom)     fichiers,
       mess_pers_initiale               resp_envoi,
       mess_dt_envoi                    envoi
  FROM MESSAGE, message_pieces_jointes
 WHERE mess_id = mepj_mess_id(+)
GROUP BY mess_val_col1,
       mess_syta_code,
       mess_pers_initiale,
       mess_dt_envoi
SELECT mess_val_col1,
       fichier,
       mess_pers_initiale               resp_envoi,
       mess_dt_envoi                    envoi
FROM MESSAGE, 
    (SELECT mepj_mess_id, 
            LISTAGG(mepj_fichier_nom, ', ') WITHIN GROUP (ORDER BY mepj_mess_id) AS fichiers
    FROM MESSAGE_PIECES_JOINTES
    GROUP BY mepj_mess_id)
WHERE mess_id = mepj_mess_id(+)
GROUP BY mess_val_col1
        ,mess_syta_code
        ,mess_pers_initiale
        ,mess_dt_envoi
        ,fichiers

STATSPACK

Problème : (sur pdtb11 base TCEDU)

ORA-01654: unable to extend index PERFSTAT.STATS$LIBRARYCACHE_PK by 128 in
tablespace STATSPACK
ORA-06512: at "PERFSTAT.STATSPACK", line 5081
ORA-06512: at "PERFSTAT.STATSPACK", line 105
ORA-06512: at line 1

il faut purger les stats.

Dans une fenêtre sqlplus lancer la purge via sppurge.sql :

pdtb11.ft.grp
ora112/o…

export ORACLE_SID=TCEDU
sqlplus
system/z…..

SQL> @$ORACLE_HOME/rdbms/admin/sppurge.sql

le script liste les snap_id et leur date


22517 24 Jul 2019 09:44:32 5 pdtb11.ft.grp
22518 24 Jul 2019 10:04:32 5 pdtb11.ft.grp
22519 24 Jul 2019 10:24:32 5 pdtb11.ft.grp
22520 24 Jul 2019 10:44:32 5 pdtb11.ft.grp
22540 02 Aug 2019 13:09:59 5 pdtb11.ft.grp
Warning
~~~~~~~
sppurge.sql deletes all snapshots ranging between the lower and
upper bound Snapshot Id’s specified, for the database instance
you are connected to. Snapshots identified as Baseline snapshots
which lie within the snapshot range will not be purged.

It is NOT possible to rollback changes once the purge begins.
You may wish to export this data before continuing.

Specify the Lo Snap Id and Hi Snap Id range to purge
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for losnapid: 4001  entrer le premier SNAP_ID à supprimer
Using 4001 for lower bound.

Enter value for hisnapid: 5802 entrer le dernier SNAP_ID à supprimer
Using 5802 for upper bound.

Deleting snapshots 4001 – 5802.

Number of Snapshots purged: 1802
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Purge of specified Snapshot range complete.

SQL> QUIT

 

 

shared memory realm does not exist

nolog> nolog> ORA-27125: unable to create shared memory segment
Linux-x86_64 Error: 1: Operation not permitted

(voir WCTSRV0060 ou WCTSRVDBTCINT1)

Pour ajouter oracle au group wheel

root@wctsrv0056:# id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)

vim /etc/group
ajouter ,oracle à la fin du groupe wheel si pas dans la liste id

 Grant autorisation sur hugepages

pour vérifier avant :
sysctl -a |grep hugetlb
sysctl: reading key « net.ipv6.conf.all.stable_secret »
sysctl: reading key « net.ipv6.conf.default.stable_secret »
sysctl: reading key « net.ipv6.conf.eth0.stable_secret »
sysctl: reading key « net.ipv6.conf.lo.stable_secret »
vm.hugetlb_shm_group = 0

pour écrire dans sysctl => sysctl -w vm.hugetlb_shm_group=${ORACLE_INSTALL_GROUPE} (voir en haut id oracle)
sysctl -w vm.hugetlb_shm_group=54321

pour vérifier après
sysctl -a |grep hugetlb
sysctl: reading key « net.ipv6.conf.all.stable_secret »
sysctl: reading key « net.ipv6.conf.default.stable_secret »
sysctl: reading key « net.ipv6.conf.eth0.stable_secret »
sysctl: reading key « net.ipv6.conf.lo.stable_secret »
vm.hugetlb_shm_group = 54321

root@wctsrv0056:# id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),10(wheel),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)

 

ORA-39087: nom de répertoire EXPDP_DIR non valide

su – oracle

. oraenv
=> SID
sqlplus / as sysdba

SQL> create directory EXPDP_DIR as '&PATH';

*/ il va te prompt le chemin a mettre. il doit correspondre au chemin du fichier /exploit/..dump..sh (la commande rm) /*

Entrez une valeur pour path : /u02/oradata/dump/ERPFDM/
ancien 1 : create directory EXPDP_DIR as ‘&PATH’
nouveau 1 : create directory EXPDP_DIR as ‘/u02/oradata/dump/ERPFDM/’

Repertoire cree.

SQL> quit

RMAN : y-a-t-il eu un Hot backup ?

se connecter ora102
se positionner sur la database

[ora102@pdtb2 KTP ~]$ export ORACLE_SID=HYPPROD
[ora102@pdtb2 HYPPROD ~]$ rman target /

pour voir les backups effectués (mais là on ne sait pas si ils sont complets !)

RMAN> list backup summary;

using target database control file instead of recovery catalog

List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
29975   B  0  A DISK        27-OCT-15       1       1       YES        DATABASE LEVEL 0
29976   B  A  A DISK        27-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29977   B  F  A DISK        27-OCT-15       1       1       NO         TAG20151027T072645
29978   B  A  A DISK        28-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29979   B  A  A DISK        28-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29980   B  A  A DISK        28-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29981   B  A  A DISK        28-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29982   B  A  A DISK        28-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29983   B  A  A DISK        28-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29984   B  A  A DISK        28-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29985   B  A  A DISK        28-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29991   B  A  A DISK        28-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29992   B  A  A DISK        28-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29995   B  0  A DISK        28-OCT-15       1       1       YES        DATABASE LEVEL 0
29996   B  A  A DISK        28-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29997   B  F  A DISK        28-OCT-15       1       1       NO         TAG20151028T035123
29998   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
29999   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
30000   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
30001   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
30002   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
30003   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
30004   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
30005   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
30006   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
30007   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
30008   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
30009   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
30010   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0
30011   B  A  A DISK        29-OCT-15       1       1       YES        ARCHIVES LEVEL 0

list des derniers FULL backup complet (là tu as toutes les infos, size, date, durée, détails des fichiers…)

RMAN> LIST BACKUP OF DATABASE;

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
29975   Incr 0  17.57G     DISK        03:14:27     27-OCT-15
        BP Key: 29975   Status: AVAILABLE  Compressed: YES  Tag: DATABASE LEVEL 0
        Piece Name: /data/backups/20151027_HYPPROD_90qknrkl_1_1
  List of Datafiles in backup set 29975
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1    0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/system01.dbf
  2    0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/undotbs01.dbf
  3    0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/sysaux01.dbf
  4    0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/data_hfm01.dbf
  5    0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/data_hss01.dbf
  6    0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/data_hbi01.dbf
  7    0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/idx_hss01.dbf
  8    0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/idx_hbi01.dbf
  9    0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/idx_hfm01.dbf
  10   0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/data_hfm02.dbf
  11   0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/data_hfm03.dbf
  12   0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/data_hfm04.dbf
  13   0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/data_hfm05.dbf
  14   0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/data_hfm06.dbf
  15   0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/idx_hfm02.dbf
  16   0  Incr 644379976  27-OCT-15 /data/oracle/HYPPROD/idx_hfm03.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
29995   Incr 0  17.58G     DISK        03:26:55     28-OCT-15
        BP Key: 29995   Status: AVAILABLE  Compressed: YES  Tag: DATABASE LEVEL 0
        Piece Name: /data/backups/20151028_HYPPROD_9kqkq2ll_1_1
  List of Datafiles in backup set 29995
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1    0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/system01.dbf
  2    0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/undotbs01.dbf
  3    0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/sysaux01.dbf
  4    0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/data_hfm01.dbf
  5    0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/data_hss01.dbf
  6    0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/data_hbi01.dbf
  7    0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/idx_hss01.dbf
  8    0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/idx_hbi01.dbf
  9    0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/idx_hfm01.dbf
  10   0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/data_hfm02.dbf
  11   0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/data_hfm03.dbf
  12   0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/data_hfm04.dbf
  13   0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/data_hfm05.dbf
  14   0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/data_hfm06.dbf
  15   0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/idx_hfm02.dbf
  16   0  Incr 644705605  28-OCT-15 /data/oracle/HYPPROD/idx_hfm03.dbf

conclusion factuelle

Pas de backup complet en date du 29/10

RMAN archivlog / noarchivlog

Rman

archive log mode

[oracle@wctsrv0058 ~]$ . oraenv
ORACLE_SID = [TSH1] ? BRIDGE
[oracle@wctsrv0058 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Tue Jul 2 13:12:04 2019

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Release 10.2.0.4.0 - 64bit Production

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/product/10.2.0/db_1/dbs/arch
Oldest online log sequence     68
Current log sequence           70
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  2083368 bytes
Variable Size             188745176 bytes
Database Buffers           88080384 bytes
Redo Buffers                6303744 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/product/10.2.0/db_1/dbs/arch
Oldest online log sequence     68
Next log sequence to archive   70
Current log sequence           70
SQL>
alter database noarchivelog;
alter database open; 
archive log list;
alter system switch logfile;

Configuration ControlFile

$ rman

connect target / ;
show all;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/data/backups/hot/%T_%d_%F';
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/data/backups/hot/%T_%d_%U';

ou

connect target / ;
show all;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backups/%d/hot/%T_%d_%F';
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/backups/%d/hot/%T_%d_%U';

rman backup

manual
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt expired archivelog all;
delete noprompt obsolete;

backup incremental level 0 tag 'database level 0' database plus archivelog tag 'archives level 0';
delete noprompt obsolete;

report need backup;
list backup summary;
script

Cold

 ./stop_database.sh BIPRD
 ./backup_cold_BIPRD.sh
 ./start_database.sh BIPRD

Hot

 sauve_hot.sh BIPRD

Add tablespace

Add tablespace oracle

add_tablespace

La limite physique gérée par Oracle est de 32Go.
Quand on arrive à cette limite il faut en créer nouveau.

 

----------------------------------------------
 Recherche des erreurs dans les log
----------------------------------------------

File : /soft/oracle/diag/diag/rdbms/zabprd/ZABPRD/trace/alert_ZABPRD.log
month : Sep
year : 2015
day : 13
error : ORA-
nom de lignes dans le fichier log :  14775247
Erreur trouvée en ligne :  14774733
Sun Sep 13 00:01:30 2015
Starting background process VKRM
Sun Sep 13 00:01:30 2015
VKRM started with pid=28, OS id=20244 
Sun Sep 13 00:01:44 2015
ORA-1652: unable to extend temp segment by 128 in tablespace                 IDX 
ORA-1652: unable to extend temp segment by 128 in tablespace                 IDX 
Sun Sep 13 00:01:45 2015
Starting ORACLE instance (restrict)
Sun Sep 13 00:01:45 2015
Thread 1 advanced to log sequence 24884 (LGWR switch)
  Current log# 2 seq# 24884 mem# 0: /data3/oracle/ZABPRD/redo02a.rdo

ora_switch_logfile.sh

#!/bin/bash
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0 database_name"
}
# --------------------------
# Verification de la syntaxe
# --------------------------
if [ $# -ne 1 ]
then
 echo "=================================================="
 echo "ERREUR : Nombre d'arguments incorrects !"
 syntaxe
 echo "=================================================="
 exit 1
fi
# --------------------------
# Verification des arguments
# --------------------------
w_instance=$1
v_res=`grep "${w_instance}:" /etc/oratab | wc -l`
v_res=`expr ${v_res}`
if [ ${v_res} -eq 0 ]
then
 echo "=================================================="
 echo "ERREUR : Base de donnees ${w_instance} inexistante !"
 syntaxe
 echo "=================================================="
 exit 1
fi
export ORACLE_SID=${w_instance}
echo $ORACLE_SID
# export NLS_DATE_FORMAT=YYYY.MM.DD.HH24.MI.SS
w_prog=`basename $0 .sh`
w_date=$(date '+%Y_%m_%d_%H_%M_%S')
w_log_dest=/exploit/logs
w_log_file=$w_log_dest/${w_date}_${w_prog}_${w_instance}.log;
sqlplus /nolog <<EOSQL >>$w_log_file 2>&1
WHENEVER SQLERROR EXIT SQL.SQLCODE
connect / as sysdba
ALTER SYSTEM ARCHIVE LOG CURRENT;
exit

ora_compilation.sh

#!/bin/bash
# --------------------------
# Verification de la syntaxe
# --------------------------
if [ $# -ne 1 ]
then
 echo "=================================================="
 echo "ERREUR : Nombre d'arguments incorrects !"
 syntaxe
 echo "=================================================="
 exit 1
fi
# --------------------------
# Verification des arguments
# --------------------------
w_instance=$1
v_res=`grep "${w_instance}" /etc/oratab | wc -l`
v_res=`expr ${v_res}`
if [ ${v_res} -eq 0 ]
then
 echo "=================================================="
 echo "ERREUR : Base de donnees [${w_instance}] inexistante !"
 syntaxe
 echo "=================================================="
 exit 1
fi
echo "SID=${w_instance}"
export ORACLE_SID=${w_instance}
ls /soft/oracle/db102/rdbms/admin/utlrp.sql
err_fic=$?
if [ "${err_fic}" != "0" ]
then
 echo Fichier absent.
 exit ${err_fic}
fi
export ORACLE_SID=$1
echo "recompile tous les objets invalides" ${ORACLE_SID}
sqlplus /nolog <<EOF
 connect / as sysdba
 WHENEVER SQLERROR EXIT SQL.SQLCODE
 SELECT owner#,name,status,ctime,mtime,stime FROM obj$ WHERE status IN (4, 5, 6);
start /soft/oracle/db102/rdbms/admin/utlrp.sql
SELECT job_name FROM dba_scheduler_running_jobs WHERE job_name like 'UTL_RECOMP_SLAVE_%';
exit
 EOF
exit ${err_sql}

stop_database.sh

#!/bin/bash
# ==================================================
# Nom : start_database.sh
# Objet : arret d'une base de donnees
# Cree le : 28/01/2010
# Syntaxe : start_database.sh database_name
# ==================================================
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0 database_name"
}
# --------------------------
# Verification de la syntaxe
# --------------------------
if [ $# -ne 1 ]
then
 echo "=================================================="
 echo "ERREUR : Nombre d'arguments incorrects !"
 syntaxe
 echo "=================================================="
 exit 1
fi
# --------------------------
# Verification des arguments
# --------------------------
w_instance=$1
v_res=`grep "${w_instance}:" /etc/oratab | wc -l`
v_res=`expr ${v_res}`
if [ ${v_res} -eq 0 ]
then
 echo "=================================================="
 echo "ERREUR : Base de donnees ${w_instance} inexistante !"
 syntaxe
 echo "=================================================="
 exit 1
fi
export ORACLE_SID=${w_instance}
# export NLS_DATE_FORMAT=YYYY.MM.DD.HH24.MI.SS
w_prog=`basename $0 .sh`
w_date=$(date '+%Y_%m_%d_%H_%M_%S')
w_log_dest=/exploit/logs
w_log_file=$w_log_dest/${w_date}_${w_prog}_${w_instance}.log;
sqlplus /nolog <<EOSQL >>$w_log_file 2>&1
connect / as sysdba
shutdown immediate;
exit
EOSQL

start_database.sh

#!/bin/bash
# ==================================================
# Nom : start_database.sh
# Objet : demarrage d'une base de donnees
# Cree le : 28/01/2010
# Syntaxe : start_database.sh database_name
# ==================================================
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0 database_name"
}
# --------------------------
# Verification de la syntaxe
# --------------------------
if [ $# -ne 1 ]
then
 echo "=================================================="
 echo "ERREUR : Nombre d'arguments incorrects !"
 syntaxe
 echo "=================================================="
 exit 1
fi
# --------------------------
# Verification des arguments
# --------------------------
w_instance=$1
v_res=`grep "${w_instance}:" /etc/oratab | wc -l`
v_res=`expr ${v_res}`
if [ ${v_res} -eq 0 ]
then
 echo "=================================================="
 echo "ERREUR : Base de donnees ${w_instance} inexistante !"
 syntaxe
 echo "=================================================="
 exit 1
fi
export ORACLE_SID=${w_instance}
echo $ORACLE_SID
# export NLS_DATE_FORMAT=YYYY.MM.DD.HH24.MI.SS
w_prog=`basename $0 .sh`
w_date=$(date '+%Y_%m_%d_%H_%M_%S')
w_log_dest=/exploit/logs
w_log_file=$w_log_dest/${w_date}_${w_prog}_${w_instance}.log;
sqlplus /nolog <<EOSQL >>$w_log_file 2>&1
connect / as sysdba
startup;
select NAME, CREATED,LOG_MODE,OPEN_MODE from v\$database;
exit
EOSQL

 

ora_arch_logfile.sh

#!/bin/bash
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0 database_name"
}
# --------------------------
# Verification de la syntaxe
# --------------------------
if [ $# -ne 1 ]
then
 echo "=================================================="
 echo "ERREUR : Nombre d'arguments incorrects !"
 syntaxe
 echo "=================================================="
 exit 1
fi
# --------------------------
# Verification des arguments
# --------------------------
w_instance=$1
v_res=`grep "${w_instance}:" /etc/oratab | wc -l`
v_res=`expr ${v_res}`
if [ ${v_res} -eq 0 ]
then
 echo "=================================================="
 echo "ERREUR : Base de donnees ${w_instance} inexistante !"
 syntaxe
 echo "=================================================="
 exit 1
fi
export ORACLE_SID=${w_instance}
echo $ORACLE_SID
# export NLS_DATE_FORMAT=YYYY.MM.DD.HH24.MI.SS
w_prog=`basename $0 .sh`
w_date=$(date '+%Y_%m_%d_%H_%M_%S')
w_log_dest=/exploit/logs
w_log_file=$w_log_dest/${w_date}_${w_prog}_${w_instance}.log;
sqlplus /nolog <<EOSQL >>$w_log_file 2>&1
WHENEVER SQLERROR EXIT SQL.SQLCODE
connect / as sysdba
ALTER SYSTEM ARCHIVE LOG CURRENT;
exit

sauve_cold.sh

#!/bin/bash
# ==================================================
# Nom : sauve_cold.sh
# Objet : sauvegarde RMAN a froid d'une base complete
# Auteur : S. GOURGAND - DIGORA
# Cree le : 27/01/2010
# Syntaxe : sauve_cold.sh database_name
# ==================================================
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0 database_name"
}
# --------------------------
# Verification de la syntaxe
# --------------------------
if [ $# -ne 1 ]
then
 echo "=================================================="
 echo "ERREUR : Nombre d'arguments incorrects !"
 syntaxe
 echo "=================================================="
 exit 1
fi
# --------------------------
# Verification des arguments
# --------------------------
w_instance=$1
echo "w_instance : "$1
[ "${HOSTNAME}" = "king" -o "${HOSTNAME}" = "king.faiveley.com" ] && w_num=1
[ "${HOSTNAME}" = "kong" -o "${HOSTNAME}" = "kong.faiveley.com" ] && w_num=2
[ "${HOSTNAME}" = "ping" -o "${HOSTNAME}" = "ping.faiveleytransport.local" ] && w_num=3
[ "${HOSTNAME}" = "pong" -o "${HOSTNAME}" = "pong.faiveleytransport.local" ] && w_num=4
v_res=`grep "${w_instance}${w_num}:" /etc/oratab | wc -l`
v_res=`expr ${v_res}`
if [ ${v_res} -eq 0 ]
then
 echo "=================================================="
 echo "ERREUR : Base de donnees ${w_instance} inexistante !"
 syntaxe
 echo "=================================================="
 exit 1
fi
export ORACLE_SID=${w_instance}${w_num}
# export NLS_DATE_FORMAT=YYYY.MM.DD.HH24.MI.SS
export NLS_DATE_FORMAT="DD/MM/YYYY HH24:MI:SS"
w_prog=`basename $0 .sh`
w_date=$(date '+%Y_%m_%d_%H_%M_%S')
w_log_dest=/exploit/logs
w_log_file=$w_log_dest/${w_date}_${w_prog}_${w_instance}.log;
rman <<EORMAN >${w_log_file} 2>&1
connect target / ;
connect catalog rman/rman@ref_rman;
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt expired archivelog all;
delete noprompt obsolete;
startup force dba;
shutdown immediate;
startup mount;
backup tag 'database cold' database plus archivelog tag 'archives cold';
alter database open;
delete noprompt obsolete;
report need backup;
list backup summary;
exit
EORMAN
# Ajout 08/04/2010 : Envoi du fichier de traces par mail
# ------------------------------------------------------
w_host=`basename $HOSTNAME .faiveley.com`
w_host=`basename ${w_host} .faiveleytransport.local | tr [a-z] [A-Z]`
mail -s "${w_host} : Sauvegarde a froid de la base ${w_instance}" u1_info_exploit@faiveleytransport.com <${w_log_file}
# Ajout 31/03/2011 : Traitement des anomalies pour VTOM
# -----------------------------------------------------
v_res=`grep "^RMAN-" ${w_log_file} | wc -l`
v_res=`expr ${v_res}`
if [ ${v_res} -gt 0 ]
then
 echo +----------------------------+
 echo ! DEBUT DU FICHIER DE TRACES !
 echo +----------------------------+
 cat ${w_log_file}
 echo +--------------------------+
 echo ! FIN DU FICHIER DE TRACES !
 echo +--------------------------+
 exit 1
else
 exit 0
fi

sauve_hot.sh

#!/bin/bash
# ==================================================
# Nom : sauve_backup.sh
# Objet : sauvegarde RMAN d'une base complete
# Auteur : S. GOURGAND - DIGORA
# Cree le : 28/01/2010
# Syntaxe : sauve_backup.sh database_name
# ==================================================
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0 database_name"
}
# --------------------------
# Verification de la syntaxe
# --------------------------
if [ $# -ne 1 ]
then
 echo "=================================================="
 echo "ERREUR : Nombre d'arguments incorrects !"
 syntaxe
 echo "=================================================="
 exit 1
fi
# --------------------------
# Verification des arguments
# --------------------------
w_instance=$1
[ "${HOSTNAME}" = "king" -o "${HOSTNAME}" = "king.faiveley.com" ] && w_num=1
[ "${HOSTNAME}" = "kong" -o "${HOSTNAME}" = "kong.faiveley.com" ] && w_num=2
[ "${HOSTNAME}" = "ping" -o "${HOSTNAME}" = "ping.faiveleytransport.local" ] && w_num=3
[ "${HOSTNAME}" = "pong" -o "${HOSTNAME}" = "pong.faiveleytransport.local" ] && w_num=4
v_res=`grep "${w_instance}${w_num}:" /etc/oratab | wc -l`
v_res=`expr ${v_res}`
if [ ${v_res} -eq 0 ]
then
 echo "=================================================="
 echo "ERREUR : Base de donnees [${w_instance}] inexistante !"
 syntaxe
 echo "=================================================="
 exit 1
fi
export ORACLE_SID=${w_instance}${w_num}
echo instance : ${ORACLE_SID}
# export NLS_DATE_FORMAT=YYYY.MM.DD.HH24.MI.SS
export NLS_DATE_FORMAT="DD/MM/YYYY HH24:MI:SS"
w_prog=`basename $0 .sh`
w_date=$(date '+%Y_%m_%d_%H_%M_%S')
w_log_dest=/exploit/logs
w_log_file=$w_log_dest/${w_date}_${w_prog}_${w_instance}.log;
rman <<EORMAN >${w_log_file} 2>&1
connect target / ;
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt expired archivelog all;
delete noprompt obsolete;
backup incremental level 0 tag 'database level 0' database plus archivelog tag 'archives level 0';
delete noprompt obsolete;
report need backup;
list backup summary;
exit
EORMAN
# Ajout 08/04/2010 : Envoi du fichier de traces par mail
# ------------------------------------------------------
w_host=`basename $HOSTNAME .faiveley.com`
w_host=`basename ${w_host} .faiveleytransport.local | tr [a-z] [A-Z]`
mail -s "${w_host} : Hot Backup Database ${w_instance}" nicolas.lamotte@faiveleytransport.com <${w_log_file}
# Ajout 31/03/2011 : Traitement des anomalies pour VTOM
# -----------------------------------------------------
v_res=`grep "^RMAN-" ${w_log_file} | wc -l`
v_res=`expr ${v_res}`
if [ ${v_res} -gt 0 ]
then
 echo +----------------------------+
 echo ! DEBUT DU FICHIER DE TRACES !
 echo +----------------------------+
 cat ${w_log_file}
 echo +--------------------------+
 echo ! FIN DU FICHIER DE TRACES !
 echo +--------------------------+
 exit 1
else
 exit 0
fi

ora_alertlog.sh

#!/bin/sh
echo "----------------------------------------------"
echo " Recherche des erreurs dans les log"
echo "----------------------------------------------"
echo " "
fic=$1 # nom du fichier
month=$2 # mois recherché
year=$3 # année recherchée
day=$4 # jour recherché
error="$5" # chaine erreur
#fic=/soft/oracle/admin/BIPROD/bdump/alert_BIPROD.log
#month=DEC
#year=2013
#day=30
#error="ORA-"
# On transforme le mois de MAJUSCULE en minuscule puis on passe la première lettre en Majuscule
month=`echo $month|tr "A-Z" "a-z"|sed 's/^./\u&/'`
day=`echo $day | tr "0" " " | sed 's/^./\u&/'`
echo "File : $fic"
echo "month : $month"
echo "year : $year"
echo "day : $day"
echo "error : $error"
nbligne=`wc $fic | awk '{print $1}'`
echo "nom de lignes dans le fichier log : " $nbligne
echo "grep -n '... $month $day ........ $year' $fic |head -1 | awk -F ':' '{print $1}'"
numligne=`grep -n "... $month $day ........ $year" $fic |head -1 | awk -F ':' '{print $1}'`
echo "Numero de la ligne de la date demandée : " $numligne
# on compte le nombre d'erreurs trouvées et on affiche les 5 lignes suivantes du log
echo "tail -n +$numligne $fic| grep $error |wc -l"
cpt=`tail -n +$numligne $fic| grep -v WARNING |grep $error |wc -l`
if [ $cpt == 0 ]; then
 # si pas d'erreur on sort
 exit 0
else
 # On affiche les erreur pour le log Vtom
 echo "tail -n +$numligne $fic | grep -C 5 $error"
 tail -n +$numligne $fic |grep -v WARNING| grep -C 5 $error
 exit $cpt
fi