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

Maintenance base domotique

Se connecter root, sur MariaDB 10, puis sur la base domo

SELECT * FROM graph_tbl WHERE ftimestamp < ‘2023-11-01 00:00:00’

create table graph_tbl_2022_1101_2023_1030 as SELECT * FROM graph_tbl WHERE ftimestamp < ‘2023-11-01 00:00:00’

delete FROM graph_tbl WHERE ftimestamp < ‘2023-11-01 00:00:00’

CREATE UNIQUE INDEX idx_mesure ON graph_tbl2022_1101_2023_1030 (ffeed(15),ftimestamp)

drop INDEX idx_mesure ON graph_tbl

CREATE UNIQUE INDEX idx_mesure ON graph_tbl (ffeed(15),ftimestamp)

———————————————————-

create table graph_conso_2022_1001 as SELECT * FROM graph_conso WHERE ftimestamp < ‘2022-10-01 00:00:00’

delete FROM graph_conso WHERE ftimestamp < ‘2022-10-01 00:00:00’

CREATE UNIQUE INDEX idx_mesure ON graph_conso_2022_1001 (ffeed(15),ftimestamp)

drop INDEX idx_mesure ON graph_conso

CREATE UNIQUE INDEX idx_mesure ON graph_conso (ffeed(15),ftimestamp)

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

Modifier le fichier wp-config.php

Lorsque vous télécharger WordPress pour la première fois, le fichier wp-config.php n’est pas présent. C’est le processus d’installation de WordPress qui créera le fichier wp-config.php en fonction des informations que vous fournirez.

Les utilisateurs expérimentés peuvent créer manuellement le fichier wp-config.php en utilisant le fichier wp-config-sample.php (qui se trouve dans le répertoire de base), en l’éditant comme nécessaire, puis en l’enregistrant sous wp-config.php.

On peut être amener à modifier le fichier wp-config.php si on change le pwd du compte root de la base mariaDB par exemple.

1- Copier le fichier wp-config.php dans un autre dossier
2- le renommer en wp-config-sample.php
3- Renommer le fichier wp-config.php en wp-config.php.old
4- Editer le fichier wp-config-sample.php
5- Replacer et renommer le fichier wp-config-sample.php en wp-config.php

 

SQLSERVER stat_desc online offline

SQLSERVER_database_state_desc.bat

echo DbName : %1
echo schema : %2

sqlcmd -v DbName="%1" schema="%2" -i \\pfile.ft.grp\Batch_win\SQLSERVER_database_state_desc.sql -b

SQLSERVER_database_state_desc.sql

SELECT state_desc FROM sys.databases where name = '$(schema)';
 GO

SQLSERVER_database_online.bat

echo DbName : %1
echo schema : %2

sqlcmd -v DbName="%1" schema="%2" -i \\pfile.ft.grp\Batch_win\SQLSERVER_database_online.sql -b

SQLSERVER_database_online.sql

USE $(DbName);
GO
-- Shrink the truncated log file to 1 MB.
ALTER DATABASE $(schema) SET ONLINE ;
GO

SQLSERVER_database_offline.bat

echo DbName : %1
echo schema : %2

sqlcmd -v DbName="%1" schema="%2" -i \\pfile.ft.grp\Batch_win\SQLSERVER_database_offline.sql -b

SQLSERVER_database_offline.sql

USE $(DbName);
GO
-- Shrink the truncated log file to 1 MB.
ALTER DATABASE $(schema) SET OFFLINE ;
GO

Remplacement d’une valeur par une autre dans un champ

But :
Remplacer fougere.myds.me:8080 par les-fougs.com dans les champs post_content et guid de la table wp_posts

create table wp_posts_old as select * from wp_posts

SELECT post_content FROM wp_posts WHERE post_content like ‘%http://fougere.myds.me:8080/recettes%’

SELECT REPLACE (post_content, ‘http://fougere.myds.me:8080/recettes’ , ‘http://les-fougs.com/recettes’) FROM wp_posts WHERE post_content like ‘%http://fougere.myds.me:8080/recettes%’

update wp_posts set post_content = REPLACE (post_content, ‘fougere.myds.me:8080’ , ‘les-fougs.com’) WHERE post_content like ‘%fougere.myds.me:8080%’

SELECT guid FROM wp_posts WHERE guid like ‘%http://fougere.myds.me:8080/recettes%’

SELECT REPLACE (guid, ‘http://fougere.myds.me:8080/recettes’ , ‘http://les-fougs.com/recettes’) FROM wp_posts WHERE guid like ‘%http://fougere.myds.me:8080/recettes%’

update wp_posts set guid = REPLACE (guid, ‘fougere.myds.me:8080’ , ‘les-fougs.com’) WHERE guid like ‘%fougere.myds.me:8080%’

Source :
REPLACE(str,from_str,to_str)

Returns the string str with all occurrences of the string from_str replaced by the string to_str. REPLACE() performs a case-sensitive match when searching for from_str.

mysql> SELECT REPLACE(‘www.mysql.com’, ‘w’, ‘Ww’);
-> ‘WwWwWw.mysql.com’
This function is multibyte safe.

Query Mysql en ligne de commande

/soft/mysql55/bin/mysql -u user -ppassword -e « show databases »;

/soft/mysql55/bin/ = chemin pour accéder au bin mysql

Pour trouver le chemin :
find / -name mysql -type f 

 

[root@pdtb7 ~]# /soft/mysql55/bin/mysql -u root -pxxxxxx -e "show databases";
+--------------------+
| Database |
+--------------------+
| information_schema |
| FT_DATAMART_TST |
| FT_DATASTAGE_TST |
| mysql |
| performance_schema |
| redsbx |
+--------------------+

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

my_coldbackup_database.sh

w_date=$(date '+%Y_%m_%d_%H_%M_%S')
# avec generation log
# su mysql --command="mysqlbackup --user=root --password=motdepasse --ibbackup=/opt/mysql/meb-3.5/bin/ibbackup /etc/mysql/my.cnf /data/backups/mysql" > /exploit/logs/my-backup-${w_date}.log
# sans log pour remonter dans VTOM
su mysql --command="mysqlbackup --user=root --password=motdepasse --ibbackup=/opt/mysql/meb-3.5/bin/ibbackup /etc/mysql/my.cnf /data/backups/mysql"
[root@pdtb2 scripts]# cat my_coldbackup_database.sh
#w_date=$(date '+%Y_%m_%d_%H_%M_%S')
w_date=$(date '+%A')
BACKUPDIR=/data/backups/mysql/${w_date}_coldbackup
DATADIR=/data/mysql
echo "rm -rf $BACKUPDIR"
rm -rf $BACKUPDIR
echo "stop mysql database"
/exploit/scripts/my_stop_database.sh
su mysql --command="mkdir $BACKUPDIR"
echo "copy my.cnf"
cp -p /etc/mysql/my.cnf $BACKUPDIR/
echo "copy database sans compression"
time cp -rp $DATADIR/ $BACKUPDIR/
echo "start mysql database"
/exploit/scripts/my_start_database.sh
sleep 120

my_backup_database.sh

w_date=$(date '+%Y_%m_%d_%H_%M_%S')
# avec generation log
# su mysql --command="mysqlbackup --user=root --password=motdepasse --ibbackup=/opt/mysql/meb-3.5/bin/ibbackup /etc/mysql/my.cnf /data/backups/mysql" > /exploit/logs/my-backup-${w_date}.log
# sans log pour remonter dans VTOM
su mysql --command="mysqlbackup --user=root --password=motdepasse --ibbackup=/opt/mysql/meb-3.5/bin/ibbackup /etc/mysql/my.cnf /data/backups/mysql"

my_alertlog.sh

#!/bin/sh
echo "----------------------------------------------"
echo " Recherche des erreurs dans les log"
echo "----------------------------------------------"
echo " "
fic=$1 # nom du fichier
day=$2 # jour recherché
error="$3" # chaine erreur
#fic=/data/mysql/databases/pdtb2.err
#day=131222
#error="ERROR"
echo "File : $fic"
echo "day : $day"
echo "error : $error"
nbligne=`cat $fic | wc -l`
echo "nom de lignes dans le fichier log : " $nbligne
numligne=`grep -n "$day " $fic |head -1 | awk -F ':' '{print $1}'`
if [ "x$numligne" == "x" ]; then
 echo "Pas d erreur trouvée"
 exit 0
else
 echo "Erreur trouvée en ligne : " $numligne
fi
# on compte le nombre d'erreurs trouvées et on affiche les 5 lignes suivantes du log
cpt=`tail -n +$numligne $fic | grep -C 5 $error |wc -l`
if [ $cpt == 0 ]; then
 # si pas d'erreur on sort
 exit 0
else
 # On affiche les erreur pour le log Vtom
 tail -n +$numligne $fic | grep -C 5 $error
 exit $cpt
fi