Post

Visualizzazione dei post da dicembre, 2020

DATAFILE e TABLESPACE

Per visualizzare tutti i datafile avviare i pdbs e posizionarsi sotto il Root Container. SQL> show con_name CON_NAME ------------------------------ CDB$ROOT SQL> show pdbs     CON_ID CON_NAME             OPEN MODE            RESTRICTED ---------- ------------------------------ ---------- ---------------------------------          2 PDB$SEED                       READ ONLY             NO          3 ORCLPDB                        READ WRITE           NO SQL>  select file_name,file_id,tablespace_name,con_id      from CDB_DATA_FILES; Verranno visualizzati i data file e tablespace del container e dei pdb. Se invece si usa la vista dba_data_files verranno solo visualizzati solo i datafile del container. SQL>  select file_name,file_id,tablespace_name      from DBA_DATA_FILES; Se ci colleghiamoci come pdb ed è aperto le due query di prima restituiscono lo stesso risultato. Se invece il pdb è spento, compare il seguente messaggio di errore: SQL> alter pluggable database orclpdb

DELETE BACKUP

Verifica dei backup effettuati RMAN> list backup of database; Per cancellare tutti i backup del container e dei pdb fare RMAN> delete backup; oppure RMAN> delete noprompt backup; oppure RMAN> delete backup TAG 'tag_name'; Per quanto riguada uno specifico PDB RMAN> list backup of database orclpdb; using target database control file instead of recovery catalog List of Backup Sets =================== BS Key  Type LV Size       Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 34      Full    844.49M    DISK        00:00:02     14-DEC-20         BP Key: 34   Status: AVAILABLE  Compressed: NO  Tag: TAG20201214T163309         Piece Name: /u01/app/oracle/fast_recovery_area/ORCL/AE3ED9EC84541FB8E053C58E670AB441/backupset/2020_12_14/o1_mf_nnndf_TAG20201214T163309_hxh1fo7o_.bkp   List of Datafiles in backup set 34   Container ID: 3, PDB Name: ORCLPDB   File LV Type Ckp SCN    Ckp Time  Abs Fuz SCN Sparse Name   ---

Point in Time Recovery di un PDB

Connettersi ad Rman ed effettuare il backup del pdb e degli archivelog. [oracle@test ORCL]$ rman target / RMAN> backup database orlcpdb plus archivelog; Collegarsi con sqlplus al PDB SQL> show con_name CON_NAME ------------------------------ CDB$ROOT SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 ORCLPDB READ WRITE NO SQL> alter session set container=orclpdb; Session altered. SQL> show con_name; CON_NAME ------------------------------ ORCLPDB Creare due tabelle: SQL> create table test03 (x number); SQL> select * from test03; no rows selected SQL> insert into test03 values (1); 1 row created. SQL> ed Wrote file afiedt.buf   1* insert into test03 values (2) SQL> / 1 row created. SQL> ed Wrote file afiedt.buf   1* insert into test03 values (3) SQL> / 1 row created. SQL&

Point in Time Recovery del CDB

 Connettersi ad Rman ed effettuare il backup del db e degli archivelog. [oracle@test ORCL]$ rman target / RMAN> backup database plus archivelog; Collegarsi con sqlplus al PDB SQL> show con_name CON_NAME ------------------------------ CDB$ROOT SQL> show pdbs     CON_ID CON_NAME                       OPEN MODE  RESTRICTED ---------- ------------------------------ ---------- ----------          2 PDB$SEED                       READ ONLY  NO          3 ORCLPDB                        READ WRITE NO SQL> alter session set container=orclpdb; Session altered. SQL> show con_name; CON_NAME ------------------------------ ORCLPDB Creare due tabelle: SQL> create table test03 (x number); Estarre la data di sistema prima di creare la secodna tabella. SQL> select TO_CHAR(sysdate,'DD-MON-YYYY HH24:MI:SS') from dual; TO_CHAR(SYSDATE,'DD-MON-YYYYH ----------------------------- 14-DEC-2020 16:15:45 SQL>  create table test04 (x number); A  questo punto voglio effettuare i

Backup e Restore PDB

 Assicurarsi che i pdb sono up e running SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 ORCLPDB READ WRITE NO [oracle@test ~]$ rman target =/ Recovery Manager: Release 18.0.0.0.0 - Production on Mon Dec 7 16:36:29 2020 Version 18.3.0.0.0 Copyright (c) 1982, 2018, Oracle and/or its affiliates.  All rights reserved. connected to target database: ORCL (DBID=1577757327) Backup del pdb + archivelog RMAN> backup database orclpdb plus archivelog; Verifiche post backup. RMAN> list backup of database orclpdb; List of Backup Sets =================== BS Key  Type LV Size       Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 5       Full    776.48M    DISK        00:00:09     07-DEC-20         BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20

Backup e Restore per Container e PDB

 Utilizziamo il tool RMAN che interroga il catalog file,  Assicurarsi che i container e i pdb sono up e running. Ricordarsi di  - abilitare l'archivelog mode - abilitare la fast recovery area se si vuole effettuare il backup classico. [oracle@test ~]$ rman target / Recovery Manager: Release 18.0.0.0.0 - Production on Mon Dec 7 14:08:22 2020 Version 18.3.0.0.0 Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved. connected to target database: ORCL (DBID=1577757327) oppure [oracle@test ~]$ rman target =/ Recovery Manager: Release 18.0.0.0.0 - Production on Mon Dec 7 14:08:30 2020 Version 18.3.0.0.0 Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved. connected to target database: ORCL (DBID=1577757327) Individuiamo la presenza di backup . RMAN> list backup of database; using target database control file instead of recovery catalog specification does not match any backup in the repository Individuiamo la presenza di archivelog . RM

Fast Recovery Area

Fast Recovery Area è un directory fisica nel server o in automatic storage management diskgroup che viene gestito da Oracle per salvare i backup e i file di recovery.La FRA viene configurata in automatico durante l'installazione. In genere contiene: - archivelogs - flashback database change logs - backup sets prodotti da RMAN. I parametri associati alla FRA sono: db_recovery_file_dest db_recovery_file_dest_size Verifichaimo se esite; accedere come root container: SQL> show con_name CON_NAME ------------------------------ CDB$ROOT SQL> show parameter db_reco NAME TYPE VALUE ------------------------------------ ----------- ---------------- db_recovery_file_dest string db_recovery_file_dest_size     big integer      0 Come si abilita? Creare un direcotry su file system [oracle@test oracle]$ mkdir  /u01/app/oracle/ fast_recovery_area Accedere come root container: SQL>   alter system set DB_RECOVERY_FILE_DEST_SIZE=5G; SQL&g

Enabling\Disabling Archivelog mode

 Quando è abilitata la modalità Archvielog, ad ogni switch dei redo log file e quando si riempe un redo log, viene effettuata una copia dei redo log file in un archived redo log file. Questi file contengno informazioni di tutte le transazioni committate. Ogni volta che un redolog file è pieno il processo ARCn - Archiver process - lo copia in una altra location come un archivio di quel file che può essere mantenuto per un tempo definito dal periodo di retention . I redolog file sono scritti in maniera circolare e quindi per evitare che si sovrascrivi una transazione non ancora scritta da DBW sui datafile, si abilita la modalità ARCHIVELOG che assicura la sovrascrittura dei redolog solo dopo che sono stati archiviati. La modalità archivelog è esenziale per un hot backups e per abilitare la Flashback Database. Come si verifica se è abilitato? Accedere come root container [oracle@test ~]$ sqlplus / as sysdba SQL*Plus: Release 18.0.0.0.0 - Production on Mon Dec 7 11:43:39 2020 Version 18.3

Concetti Backup e Recovery

 E' possibile classificare il backup in 4 classi: 1) User-managed hot backups :  consiste nell'effettuare manulamente una copia dei datafile, control file, redo log file usando i camondi del sistema operatio, tipo "cp" 2) RMAN (oracle recovery manager) è una command-line utility che effettua il backup full e incrementale, gestisce i backup e permette di effettuare il recovery. 3) Dat Pump è una database export-import utility che effettua una copia logica del database e quindi degli schema, tablespace, dati in generale. 4) Flashback è una tecnologia che permette di recuperare dati persi per errore umano, come la drop di una tabella, e non supporta recovery da perdita di file come un media or disk failure e inoltre funziona solo con il database online.

Point in Time Recovery

 Il point in time recovey (PITR) consiste nel restore e recovery del db ad uno specifico istante. I prerequisiti sono: - abilitare Archive Log - effettuare un Backup del db ad un determinato istante o valore di SCN (system change number) - verificare che gli archivelog file vengono generati (ogni volta che c'è uno switch dei redo log il processo di background LOG scrive i redo log negli archive log file)

ORA-03137: Errore interno del protocollo TTC: [12333] [0] [250] [0] [] [] [] []

 Nel file di trace ho trovato queste info: ***  2020-12-04  13:12:05.614 *** SESSION ID: (129.39309) 2020-12-04  13:12:05.614 *** CLIENT ID:()  2020-12-04  13:12:05.614 *** SERVICE NAME:(SYS$USERS)  2020-12-04  13:12:05.614 *** MODULE NAME:( sqlnavigator. exe)  2020-12-04  13:12:05.614 *** ACTION NAME:()  2020-12-04  13:12:05.614 Dump continued from file: /u01/app/oracle/diag/rdbms/prtt/PR0T/trace/PR0T_ora_5027.trc ORA-03137: Errore interno del protocollo TTC: [12333] [0] [250] [0] [] [] [] [] ========= Dump for incident 7593 (ORA 3137 [12333]) ======== ***  2020-12-04  13:12:05.630 dbkedDefDump(): Starting incident default dumps (flags=0x2, level=3, mask=0x0) ----- Current SQL Statement for this session (sql_id=fg3bj99vk5n84) ----- select username from sys.dba_users where exists (select 'x' from sys.dba_objects where owner=username) or username = user order by username Questo errore dice che il processo di comunicazione tra client e server è terminato a causa di un evento. Gli