nouveaus scripts rman et autotask

This commit is contained in:
Yacine31
2021-11-24 06:05:16 +01:00
parent fc5ca9a2df
commit ee7c8f1645
3 changed files with 160 additions and 0 deletions

72
check_rman_backup.sh Normal file
View File

@@ -0,0 +1,72 @@
#!/bin/bash
#---------------------------------------------------------------------------
# 24/01/2019 - YAO Adaptation après migration Crossway vers oda-cw
#---------------------------------------------------------------------------
# Environnement Variables
export NLS_DATE_FORMAT='DD/MM/YYYY HH24:MI:SS'
export ORAENV_ASK=NO
unset NLS_LANG
#---------------------------------------------------------------------------
# Fonction test_dba : teste si l'utilisateur est DBA
#---------------------------------------------------------------------------
function test_dba {
if test "$(id|grep dba)"
then
#return 0
echo " OK => Test Utilisateur DBA"
else
echo ""
echo "============================================================="
echo " Abandon, l'utilisateur doit appartenir au groupe DBA "
echo "============================================================="
exit 1
fi
}
test_dba;
#---------------------------------------------------------------------------
# reporter toutes les instances préntes sur ce serveur
#---------------------------------------------------------------------------
# for r in $(ps -eaf | grep pmon | grep -v grep | cut -d '_' -f3)
for r in $(ps -eaf | grep pmon | egrep -v 'grep|ASM1|APX1' | cut -d '_' -f3)
do
echo " Base de donnee a traiter: " $r
export ORACLE_SID=$r
. oraenv -s
echo $ORACLE_SID $ORACLE_HOME
sqlplus -S / as sysdba << EOF > /home/oracle/digora/log/rapport_rman_$r.log
alter session set nls_date_format='DD/MM/YYYY HH24:MI:SS' ;
set serveroutput on
set linesize 250 heading off;
set heading on pagesize 999;
column status format a25;
column input_bytes_display format a12;
column output_bytes_display format a12;
column device_type format a10;
declare
base varchar2(40) ;
serv varchar2(40) ;
begin
select instance_name into base from v\$instance ;
select host_name into serv from v\$instance ;
dbms_output.put_line (' Vous trouverez ci dessous le rapport pour la base de donné :' || base || ' sur le serveur : '|| serv );
end ;
/
select
b.input_type,
b.status,
to_char(b.start_time,'DD-MM-YY HH24:MI') "Start Time",
to_char(b.end_time,'DD-MM-YY HH24:MI') "End Time",
b.output_device_type device_type,
b.input_bytes_display,
b.output_bytes_display
FROM v\$rman_backup_job_details b
WHERE b.start_time > (SYSDATE - 30)
ORDER BY b.start_time asc;
EOF
done

31
check_rman_backup.sql Normal file
View File

@@ -0,0 +1,31 @@
set pages 25 lines 250
col HEURE_DEBUT for a20
col HEURE_FIN for a20
col LAST_BKP for a10
col status for a25
col IN_BYTES for a15
col OUT_BYTES for a15
set head off
select '---------------------------------- '
|| 'Database name : ' || name || ', Instance name = ' || instance_name
|| ' ----------------------------------'
from v$database, v$instance;
set head on
select
d.NAME || '_' || i.instance_name "DBNAME_INSTANCE"
,SESSION_KEY "KEY"
,INPUT_TYPE "BKP_TYPE"
,to_char(START_TIME,'DD-MM-YYYY HH24:MI:SS') "HEURE_DEBUT"
,to_char(END_TIME,'DD-MM-YYYY HH24:MI:SS') "HEURE_FIN"
,to_char(trunc(sysdate) + numtodsinterval(ELAPSED_SECONDS, 'second'),'hh24:mi:ss') "DUREE"
,cast((floor(sysdate-start_time)) as int) || 'd ' || round((round(sysdate-start_time, 2) - cast(floor(sysdate-start_time) as int))*24,0) || 'h' as "LAST_BKP"
,INPUT_BYTES_DISPLAY "IN_BYTES"
,OUTPUT_BYTES_DISPLAY "OUT_BYTES"
,r.STATUS
from V$RMAN_BACKUP_JOB_DETAILS r, v$database d, v$instance i
where start_time > (SYSDATE - 7)
order by SESSION_KEY
;
exit

57
disable_auto_tasks.sql Normal file
View File

@@ -0,0 +1,57 @@
--
-- lorsqu'on vérifie les options utilisées par la base, "Automatic SQL Tuning Advisor" sort aussi
-- même si la base n'est pas licenciée avec Tuning Pack
-- Ce script permet de voir et désactiver les tâches automatiques
-- pour ne pas avoir à licencier Tuning Pack
--
set lines 180 pages 1000
col client_name for a40
col attributes for a60
select client_name, status,attributes,service_name from dba_autotask_client
/
BEGIN
DBMS_AUTO_TASK_ADMIN.disable(
client_name => 'auto space advisor',
operation => NULL,
window_name => NULL);
END;
/
BEGIN
DBMS_AUTO_TASK_ADMIN.disable(
client_name => 'sql tuning advisor',
operation => NULL,
window_name => NULL);
END;
/
-- BEGIN
-- DBMS_AUTO_TASK_ADMIN.disable
-- (
-- client_name => 'auto optimizer stats collection',
-- operation => NULL,
-- window_name => NULL);
-- END;
-- /
select client_name, status,attributes,service_name from dba_autotask_client
/
-- pour réactiver les auto task remplacer DBMS_AUTO_TASK_ADMIN.disable par DBMS_AUTO_TASK_ADMIN.enable
-- BEGIN
-- dbms_auto_task_admin.enable(client_name => 'sql tuning advisor', operation => NULL, window_name => NULL);
-- END;
-- /
-- BEGIN
-- DBMS_AUTO_TASK_ADMIN.enable(client_name => 'sql tuning advisor', operation => NULL, window_name => NULL);
-- END;
-- /
-- BEGIN
-- DBMS_AUTO_TASK_ADMIN.enable(client_name => 'auto optimizer stats collection', operation => NULL, window_name => NULL);
-- END;
-- /