Post

Visualizzazione dei post da 2024

SYS_AUTO_SQL_TUNING_TASK - "Process 0x%p appears to be hung in Auto SQL Tuning task"

Vale dalla versione 11 in poi  Occasionalmente, durante l'esecuzione di "SYS_AUTO_SQL_TUNING_TASK", nel alert log potrebbero comparire messaggi di avviso come il seguente: "Process 0x%p appears to be hung in Auto SQL Tuning task" "Current time = %u, process death time = %u" "Attempting to kill process 0x%p with OS pid = %s" "OSD kill skipped for process %p" "OSD kill succeeded for process %p" "OSD kill failed for process %p" Cosa è SYS_AUTO_SQL_TUNING_TASK? è un task automatico eseguito dal database che seglie un set di SQL ad alto carico ( high-load SQL ) da AWR ed esegue SQL Tuning Advisor su questo SQL.  Il pacchetto DBMS_AUTO_SQLTUNE è l'interfaccia per SQL Tuning Advisor (DBMS_SQLTUNE) quando eseguito all'interno del framework Autotask.  Questo task controlla i profili SQL che trova eseguendo sia i vecchi che i nuovi query plan. Automatic SQL Tuning differisce da manual SQL tuning in questo modo:  Se

Estrarre IP da file di log del LISTENER

Per cercare il log de listener fare: # lsnrctl status Esempio: Da questa riga che è in un file LISTENER.log di interesse 31-JAN-2023 23:58:53 * (CONNECT_DATA=(SID=PROT)(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=tomcat))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.161.2.9)(PORT=41294)) * establish * PROT1 * 0 devo estrarre queste informazioni (PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=tomcat))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.161.2.9)(PORT=41294)) Questi permette di avere una tabella che puoi portare anche in excel.   Ogni campo è separato da un pipe. echo "SID|PROGRAM|HOST|USER|PROTOCOL|HOST|PORT" &&  cat listener.log | awk -F= '{print $3 "§1§" $5 "§2§" $6 "§3§" $7 "§4§" $9 "§5§" $10 "§6§" $11}' | sed 's/).*§1§/|/' | sed 's/).*§2§/|/' | sed 's/).*§3§/|/'| sed 's/).*§4§/|/'| sed 's/).*§5§/|/'| sed 's/).*§6§/|/'| sed 's/).*$//' > estr

CLONE REMOTE PDB da un Container ad un altro usando DBLINK

--->>>>DOC  2882174.1 --- How to clone remote pdb from one cdb to another cdb using db link We are cloning the pluggable database, PDB1 from root container database, CDB1 to PDB2 in root container database, CDB2. a) Close and Open the PDB1 in READ WRITE mode to create cloneuser. SQL> alter pluggable database pdb1 close; Pluggable database altered. SQL> alter pluggable database pdb1 open; Pluggable database altered. Login to PDB1  e creare l'utente cloneuser usato dal dblink creato su CDB2 SQL> alter session set container=pdb1; SQL> create user cloneuser identified by cloneuser; Grant create session and create pluggable database privileges to cloneuser. SQL> grant create session, create pluggable database to cloneuser; Controlla i privileges granted to the cloneuser. SQL> select * from dba_sys_privs where grantee = 'CLONEUSER'; Aprire PDB1 in modalità read only. SQL> alter session set container=PDB1; SQL> alter pluggable database close; SQ

ORA-02020: too many database links in use

 Questo errore è legato al numero di database link aperti per sessione che può essere vista dalla seguente query SQL>  select db_link,logged_on,open_cursors from v$dblink;  Il parametro di sistema è SQL> show parameter open_links; NAME                                           TYPE        VALUE ------------------------------------ ----------- ------------------------------ open_links                                     integer     4 open_links_per_instance              integer     4 E' possibile aumentarlo con il seguente comando SQL> alter system set open_links_per_instance=10 scope=spfile; SQL> alter system set open_links=10 scope=spfile;

FLASHBACK DATABASE dalla 11.2.0.1 (Guarantee Restore Point)

Flashback Database is much faster than point-in-time recovery because it does not require restoring datafiles from backup and requires applying fewer changes from the archived redo logs. Creare un "guarantee restore point" del database così da potere effettuare un restore del db ad uno specifico valore SCN in un qualsiasi instante di tempo anche al di là del periodo definito dal paramatro di retention DB_FLASHBACK_RETENTION_TARGET. Occorre abilitare la modalità Archivelog e la Flashback Database . Dalla 11.2.0.1 non c'è bisogno di spegnere il db per metterlo in modalità Flashback ON ma il db deve essere in modalità archivelog.  -- Verificare lo stato archive e flash recovery area select log_mode,flashback_on from v$database; -- Verificare il puntamento degli archievelog  SQL> archive log list;  Database log mode Archive Mode  Automatic archival Enabled  Archive destination /u05/oradata/CORE/  Oldest online log sequence 2088  Next log sequence to archive 2090  Current

Schedulazione IMP a crontab - NETWORK LINK

 Copiare ogni martedì alle 9 solo i dati dello schema SAKAMO dal db di prodzune PROD02 a l db di test TEST02. Creare su TEST02 un network link verso PROD02 CREATE DATABASE LINK DB_PROD02  CONNECT TO SYSTEM  IDENTIFIED BY <PWD>  USING '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL = TCP)(HOST=server06.intra.camera.it)(PORT = 1521)))(CONNECT_DATA=(SERVICE_NAME = PROD02)))'; oppure così CREATE DATABASE LINK DB_PROD02  CONNECT TO SYSTEM  IDENTIFIED BY <PWD>  USING 'PROD02'; Controllare che PROD02 sia definito nel tnsnames.ora del server di test. Lo script sh a crontab lancia in sequenza da sqlplus: - disabilita trigger - disabilita FK - import utilizzando un netwok link  - abilita FK - abilita trigger [oracle@server06 ~]$ crontab -l 00 09 2 * * /home/oracle/work/schedul_exp.sh 1>>/home/oracle/work/schedul_exp.log 2>&1 [oracle@server06 work]$ cat schedul_exp.sh #!/bin/bash -x export ORACLE_HOME=/u01/app/oracle/product/11gR24 export ORACLE_BASE=/u01/a

SEQUENCE: aggiornare una sequence ad un valore

E' chiesto di portare la sequence T180_SEQ al valore 558631 Per vedere il valore attuale fare la query  SQL> select T180_SEQ.currval  from dual; se va in errore, calcolare prima il nuovo valore e poi quello attuale: SQL> select T180_SEQ.nextval  from dual; SQL> select T180_SEQ.currval  from dual; Otteniamo 558145 Calcolare la differenza: SQL> select 558633 - 558145 from dual; 488 Incrementare la sequence di 488 (ho messo 486 per incrementarlo successivamente "a mano") SQL> A LTER SEQUENCE T180_SEQ INCREMENT BY 486; Incrementare la sequence di 486 SQL> select T180_SEQ.nextval  from dual; SQL> select T180_SEQ.currval  from dual; Ottengo 558631 Reimposto l'incremnto a 1 (che era il valore originale): SQL> ALTER SEQUENCE T180_SEQ INCREMENT BY 1; Rieseguo altre due volte la seguente query per incrementare di due posizioni la sequence SQL> select T180_SEQ.nextval  from dual; SQL>  select T180_SEQ.currval  from dual; Ottengo 558631