lunes, 26 de agosto de 2024

Extract DDL Oracle

-- -----------------------------------------------------------------------------------
-- File Name    : https://oracle-base.com/dba/script_creation/user_ddl.sql
-- Author       : Tim Hall
-- Description  : Displays the DDL for a specific user.
-- Call Syntax  : @user_ddl (username)
-- Last Modified: 07/08/2018
-- -----------------------------------------------------------------------------------

set long 20000 longchunksize 20000 pagesize 0 linesize 1000 feedback off verify off trimspool on
column ddl format a1000

begin
   dbms_metadata.set_transform_param (dbms_metadata.session_transform, 'SQLTERMINATOR', true);
   dbms_metadata.set_transform_param (dbms_metadata.session_transform, 'PRETTY', true);
end;
/
 
variable v_username VARCHAR2(30);

exec :v_username := upper('&1');

select dbms_metadata.get_ddl('USER', u.username) AS ddl
from   dba_users u
where  u.username = :v_username
union all
select dbms_metadata.get_granted_ddl('TABLESPACE_QUOTA', tq.username) AS ddl
from   dba_ts_quotas tq
where  tq.username = :v_username
and    rownum = 1
union all
select dbms_metadata.get_granted_ddl('ROLE_GRANT', rp.grantee) AS ddl
from   dba_role_privs rp
where  rp.grantee = :v_username
and    rownum = 1
union all
select dbms_metadata.get_granted_ddl('SYSTEM_GRANT', sp.grantee) AS ddl
from   dba_sys_privs sp
where  sp.grantee = :v_username
and    rownum = 1
union all
select dbms_metadata.get_granted_ddl('OBJECT_GRANT', tp.grantee) AS ddl
from   dba_tab_privs tp
where  tp.grantee = :v_username
and    rownum = 1
union all
select dbms_metadata.get_granted_ddl('DEFAULT_ROLE', rp.grantee) AS ddl
from   dba_role_privs rp
where  rp.grantee = :v_username
and    rp.default_role = 'YES'
and    rownum = 1
union all
select to_clob('/* Start profile creation script in case they are missing') AS ddl
from   dba_users u
where  u.username = :v_username
and    u.profile <> 'DEFAULT'
and    rownum = 1
union all
select dbms_metadata.get_ddl('PROFILE', u.profile) AS ddl
from   dba_users u
where  u.username = :v_username
and    u.profile <> 'DEFAULT'
union all
select to_clob('End profile creation script */') AS ddl
from   dba_users u
where  u.username = :v_username
and    u.profile <> 'DEFAULT'
and    rownum = 1
/

jueves, 8 de agosto de 2024

Instalacion RAC ORacle 19c ++ en Linux

Pre-Requisitos Basicos
--Storage --
/u01 de 100GB
5 discos de 10 GB cada uno para los Vote+OCR
2 discos de 100 GB para la BD de metada del Rac- Colocar en redundancia NORMAL al crear el diskgroup
N Cantidad de Discos para +DATA y +FRA
/tmp 30 GB almenos
---------------------------------------
--Networking
2 Ip en segmento publico
2 Ip en un segmento privado aislado solo para el RAC
3 Ip en el segmento publico para el DNS
2 Ip en el segmento publico para las Vip

Se debe crear y asignar en el Dns la resolucion de nombre del Scan: 
Ejemplo: scan-prod:

[oracle@dbserver01 ~]$ nslookup scan-prod
Server:         10.10.1.140
Address:        10.10.1.140#53

Name:   scan-prod.local.db
Address: 10.129.2.82
Name:   scan-prod.local.db
Address: 10.129.2.83
Name:   scan-prod.local.db
Address: 10.129.2.81
---------------------------------------


Deshabilitar SElinux
vi /etc/selinux/config   --- colocar en disable

Deshablitar Firewall
service firewalld stop
service firewalld disable

Creacion de Grupos de S.O.
groupadd oinstall -g 501
groupadd dba -g 502
groupadd oper -g 503
groupadd backupdba -g 504
groupadd dgdba -g 505
groupadd kmdba -g 506
groupadd asmadmin -g 507
groupadd asmdba -g 508
groupadd asmoper -g 509

Creacion de usuarios de S.O.

--------- where the installation owner is grid and the OSASM group asmadmin -------------------
useradd -u 501 -g oinstall -G asmadmin,asmdba,asmoper,dba grid
useradd -u 502 -g oinstall -G dba,oper,asmdba,backupdba,dgdba,kmdba oracle



Directorios para los binarios:
mkdir -p /u01/app/19.0.0/grid
mkdir -p /u01/app/grid
mkdir -p /u01/app/oracle
chown -R grid:oinstall /u01
chown oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/



Editar archivos etc/hosts en los servidores:
--- IP PUBLICAS ---
10.129.2.72    server01
10.129.2.73    server02
--- IP PRIVADAS --
10.10.10.1    server01-priv
10.10.10.2   server02-priv
-- IP VIPS --
10.129.2.77    server01-vip
10.129.2.78    server02-vip
Nota no agregar el Servicio para el Scan #  Servicio scan: cl-scan-ip : 10.129.2.90, 10.129.2.91, 10.129.2.92




Configurar Interfaces de RED
#nmtui 
#nm-connection-editor 





export CV_ASSUME_DISTID=OEL7.8



[root@dsib0252]# cd /usr/bin
[root@dsib0252 bin]# mv scp scp.orig
[root@dsib0252 bin]# echo "/usr/bin/scp.orig -T \$*" > /usr/bin/scp
[root@dsib0252 bin]# chmod 555 /usr/bin/scp
[root@dsib0252 bin]# cat scp
/usr/bin/scp.orig -T $*


Convert Physical Standby into Snapshot Standby

 Convirtiendo una BD Standby en una Snapshot para pruebas.


Paso 0 

Asgurate que tengas suficiente espacio en el area de RECO para guardar los ARC que la producctiva generar durante la ventana

select * FROM V$FLASH_RECOVERY_AREA_USAGE;

select space_limit/1024/1024/1024 maxGB,space_used/1024/1024/1024 usedGB from v$recovery_file_dest;

On Primary:

Genera un par de ARC y valida que sean aplicados correctamente en tu Standby

alter system archive log current;



On standby:
===========
alter database recover managed standby database cancel;
select name, open_mode from v$database; ----make sure its mounted
select log_mode,flashback_on from v$database;
CREATE RESTORE POINT RESTORE_PRE_SNAPSHOT GUARANTEE FLASHBACK DATABASE;
alter database convert to snapshot standby;
alter database open;  
select name, open_mode, database_role from v$database;


On standby:
===========
Do TESTS

On standby:
===========
select name, open_mode, database_role from v$database;
shut immediate;
startup mount;
alter database convert to physical standby;
shutdown immediate
startup mount;
select name, open_mode from v$database; 
DROP RESTORE POINT RESTORE_PRE_SNAPSHOT;  --borra los puntos de fashback
alter database recover managed standby database disconnect; or alter database recover managed standby database using current logfile disconnect from session;

 

martes, 9 de marzo de 2021

Script to Collect Log File Sync Diagnostic Information (lfsdiag.sql)

 

set echo off
set feedback off
column timecol new_value timestamp
column spool_extension new_value suffix
select to_char(sysdate,'Mondd_hh24mi') timecol,
'.out' spool_extension from sys.dual;
column output new_value dbname
select value || '_' output
from v$parameter where name = 'db_name';
spool lfsdiag_&&dbname&&timestamp&&suffix
set trim on
set trims on
set lines 130
set pages 100
set verify off
alter session set optimizer_features_enable = '10.2.0.4';

PROMPT LFSDIAG DATA FOR &&dbname&&timestamp
PROMPT Note: All timings are in milliseconds (1000 milliseconds = 1 second)

PROMPT
PROMPT IMPORTANT PARAMETERS RELATING TO LOG FILE SYNC WAITS:
column name format a40 wra
column value format a40 wra
select inst_id, name, value from gv$parameter
where ((value is not null and name like '%log_archive%') or
name like '%commit%' or name like '%event=%' or name like '%lgwr%')
and name not in (select name from gv$parameter where (name like '%log_archive_dest_state%'
and value = 'enable') or name = 'log_archive_format')
order by 1,2,3;

PROMPT
PROMPT HISTOGRAM DATA FOR LFS AND OTHER RELATED WAITS:
PROMPT
PROMPT APPROACH: Look at the wait distribution for log file sync waits
PROMPT by looking at "wait_time_milli". Look at the high wait times then
PROMPT see if you can correlate those with other related wait events.
column event format a40 wra
select inst_id, event, wait_time_milli, wait_count
from gv$event_histogram
where event in ('log file sync','gcs log flush sync',
'log file parallel write','wait for scn ack',
'log file switch completion','gc cr grant 2-way',
'gc buffer busy','gc current block 2-way') or
event like '%LGWR%' or event like '%LNS%'
order by 2 desc,1,3;

PROMPT
PROMPT ORDERED BY WAIT_TIME_MILLI
select inst_id, event, wait_time_milli, wait_count
from gv$event_histogram
where event in ('log file sync','gcs log flush sync',
'log file parallel write','wait for scn ack',
'log file switch completion','gc cr grant 2-way',
'gc buffer busy','gc current block 2-way')
or event like '%LGWR%' or event like '%LNS%'
order by 3,1,2 desc;

PROMPT
PROMPT REDO WRITE STATS
PROMPT
PROMPT "redo write time" in centiseconds (100 per second)
PROMPT 11.1: "redo write broadcast ack time" in centiseconds (100 per second)
PROMPT 11.2: "redo write broadcast ack time" in microseconds (1000 per millisecond)
column value format 99999999999999999999
column milliseconds format 99999999999999.999
select v.version, ss.inst_id, ss.name, ss.value,
decode(substr(version,1,4),
'11.1',decode (name,'redo write time',value*10,
'redo write broadcast ack time',value*10),
'11.2',decode (name,'redo write time',value*10,
'redo write broadcast ack time',value/1000),
decode (name,'redo write time',value*10)) milliseconds
from gv$sysstat ss, v$instance v
where name like 'redo write%' and value > 0
order by 1,2,3;

PROMPT
PROMPT ASH THRESHOLD...
PROMPT
PROMPT This will be the threshold in milliseconds for average log file sync
PROMPT times. This will be used for the next queries to look for the worst
PROMPT 'log file sync' minutes. Any minutes that have an average log file
PROMPT sync time greater than the threshold will be analyzed further.
column threshold_in_ms new_value threshold format 999999999.999
select min(threshold_in_ms) threshold_in_ms
from (select inst_id, to_char(sample_time,'Mondd_hh24mi') minute,
avg(time_waited)/1000 threshold_in_ms
from gv$active_session_history
where event = 'log file sync'
group by inst_id,to_char(sample_time,'Mondd_hh24mi')
order by 3 desc)
where rownum <= 5;

PROMPT
PROMPT ASH WORST MINUTES FOR LOG FILE SYNC WAITS:
PROMPT
PROMPT APPROACH: These are the minutes where the avg log file sync time
PROMPT was the highest (in milliseconds).
column event format a30 tru
column program format a35 tru
column total_wait_time format 999999999999.999
column avg_time_waited format 999999999999.999
select to_char(sample_time,'Mondd_hh24mi') minute, inst_id, event,
sum(time_waited)/1000 TOTAL_WAIT_TIME , count(*) WAITS,
avg(time_waited)/1000 AVG_TIME_WAITED
from gv$active_session_history
where event = 'log file sync'
group by to_char(sample_time,'Mondd_hh24mi'), inst_id, event
having avg(time_waited)/1000 > &&threshold
order by 1,2;

PROMPT
PROMPT ASH LFS BACKGROUND PROCESS WAITS DURING WORST MINUTES:
PROMPT
PROMPT APPROACH: What is LGWR doing when 'log file sync' waits
PROMPT are happening? LMS info may be relevent for broadcast
PROMPT on commit and LNS data may be relevant for dataguard.
PROMPT If more details are needed see the ASH DETAILS FOR WORST
PROMPT MINUTES section at the bottom of the report.
column inst format 999
column event format a30 tru
column program format a35 wra
select to_char(sample_time,'Mondd_hh24mi') minute, inst_id inst, program, event,
sum(time_waited)/1000 TOTAL_WAIT_TIME , count(*) WAITS,
avg(time_waited)/1000 AVG_TIME_WAITED
from gv$active_session_history
where to_char(sample_time,'Mondd_hh24mi') in (select to_char(sample_time,'Mondd_hh24mi')
from gv$active_session_history
where event = 'log file sync'
group by to_char(sample_time,'Mondd_hh24mi'), inst_id
having avg(time_waited)/1000 > &&threshold)
and (program like '%LGWR%' or program like '%LMS%' or
program like '%LNS%' or event = 'log file sync')
group by to_char(sample_time,'Mondd_hh24mi'), inst_id, program, event
order by 1,2,3,5 desc, 4;

PROMPT
PROMPT AWR WORST AVG LOG FILE SYNC SNAPS:
PROMPT
PROMPT APPROACH: These are the AWR snaps where the average 'log file sync'
PROMPT times were the highest.
column begin format a12 tru
column end format a12 tru
column name format a13 tru
select dhs.snap_id, dhs.instance_number inst, to_char(dhs.begin_interval_time,'Mondd_hh24mi') BEGIN,
to_char(dhs.end_interval_time,'Mondd_hh24mi') END,
en.name, se.time_waited_micro/1000 total_wait_time, se.total_waits,
se.time_waited_micro/1000 / se.total_waits avg_time_waited
from dba_hist_snapshot dhs, wrh$_system_event se, v$event_name en
where (dhs.snap_id = se.snap_id and dhs.instance_number = se.instance_number)
and se.event_id = en.event_id and en.name = 'log file sync' and
dhs.snap_id in (select snap_id from (
select se.snap_id, se.time_waited_micro/1000 / se.total_waits avg_time_waited
from wrh$_system_event se, v$event_name en
where se.event_id = en.event_id and en.name = 'log file sync'
order by avg_time_waited desc)
where rownum < 4)
order by 1,2;

PROMPT
PROMPT AWR REDO WRITE STATS
PROMPT
PROMPT "redo write time" in centiseconds (100 per second)
PROMPT 11.1: "redo write broadcast ack time" in centiseconds (100 per second)
PROMPT 11.2: "redo write broadcast ack time" in microseconds (1000 per millisecond)
column stat_name format a30 tru
select v.version, ss.snap_id, ss.instance_number inst, sn.stat_name, ss.value,
decode(substr(version,1,4),
'11.1',decode (stat_name,'redo write time',value*10,
'redo write broadcast ack time',value*10),
'11.2',decode (stat_name,'redo write time',value*10,
'redo write broadcast ack time',value/1000),
decode (stat_name,'redo write time',value*10)) milliseconds
from wrh$_sysstat ss, wrh$_stat_name sn, v$instance v
where ss.stat_id = sn.stat_id
and sn.stat_name like 'redo write%' and ss.value > 0
and ss.snap_id in (select snap_id from (
select se.snap_id, se.time_waited_micro/1000 / se.total_waits avg_time_waited
from wrh$_system_event se, v$event_name en
where se.event_id = en.event_id and en.name = 'log file sync'
order by avg_time_waited desc)
where rownum < 4)
order by 1,2,3;

PROMPT
PROMPT AWR LFS AND OTHER RELATED WAITS FOR WORST LFS AWRs:
PROMPT
PROMPT APPROACH: These are the AWR snaps where the average 'log file sync'
PROMPT times were the highest. Look at related waits at those times.
column name format a40 tru
select se.snap_id, se.instance_number inst, en.name,
se.total_waits, se.time_waited_micro/1000 total_wait_time,
se.time_waited_micro/1000 / se.total_waits avg_time_waited
from wrh$_system_event se, v$event_name en
where se.event_id = en.event_id and (en.name in
('log file sync','gcs log flush sync',
'log file parallel write','wait for scn ack',
'log file switch completion','gc cr grant 2-way',
'gc buffer busy','gc current block 2-way')
or en.name like '%LGWR%' or en.name like '%LNS%')
and se.snap_id in (select snap_id from (
select se.snap_id, se.time_waited_micro/1000 / se.total_waits avg_time_waited
from wrh$_system_event se, v$event_name en
where se.event_id = en.event_id and en.name = 'log file sync'
order by avg_time_waited desc)
where rownum < 4)
order by 1, 6 desc;

PROMPT
PROMPT AWR HISTOGRAM DATA FOR LFS AND OTHER RELATED WAITS FOR WORST LFS AWRs:
PROMPT Note: This query won't work on 10.2 - ORA-942
PROMPT
PROMPT APPROACH: Look at the wait distribution for log file sync waits
PROMPT by looking at "wait_time_milli". Look at the high wait times then
PROMPT see if you can correlate those with other related wait events.
select eh.snap_id, eh.instance_number inst, en.name, eh.wait_time_milli, eh.wait_count
from wrh$_event_histogram eh, v$event_name en
where eh.event_id = en.event_id and
(en.name in ('log file sync','gcs log flush sync',
'log file parallel write','wait for scn ack',
'log file switch completion','gc cr grant 2-way',
'gc buffer busy','gc current block 2-way')
or en.name like '%LGWR%' or en.name like '%LNS%')
and snap_id in (select snap_id from (
select se.snap_id, se.time_waited_micro/1000 / se.total_waits avg_time_waited
from wrh$_system_event se, v$event_name en
where se.event_id = en.event_id and en.name = 'log file sync'
order by avg_time_waited desc)
where rownum < 4)
order by 1,3 desc,2,4;

PROMPT
PROMPT ORDERED BY WAIT_TIME_MILLI
PROMPT Note: This query won't work on 10.2 - ORA-942
select eh.snap_id, eh.instance_number inst, en.name, eh.wait_time_milli, eh.wait_count
from wrh$_event_histogram eh, v$event_name en
where eh.event_id = en.event_id and
(en.name in ('log file sync','gcs log flush sync',
'log file parallel write','wait for scn ack',
'log file switch completion','gc cr grant 2-way',
'gc buffer busy','gc current block 2-way')
or en.name like '%LGWR%' or en.name like '%LNS%')
and snap_id in (select snap_id from (
select se.snap_id, se.time_waited_micro/1000 / se.total_waits avg_time_waited
from wrh$_system_event se, v$event_name en
where se.event_id = en.event_id and en.name = 'log file sync'
order by avg_time_waited desc)
where rownum < 4)
order by 1,4,2,3 desc;

PROMPT
PROMPT ASH DETAILS FOR WORST MINUTES:
PROMPT
PROMPT APPROACH: If you cannot determine the problem from the data
PROMPT above, you may need to look at the details of what each session
PROMPT is doing during each 'bad' snap. Most likely you will want to
PROMPT note the times of the high log file sync waits, look at what
PROMPT LGWR is doing at those times, and go from there...
column program format a45 wra
column sample_time format a25 tru
column event format a30 tru
column time_waited format 999999.999
column p1 format a40 tru
column p2 format a40 tru
column p3 format a40 tru
select sample_time, inst_id inst, session_id, program, event, time_waited/1000 TIME_WAITED,
p1text||': '||p1 p1,p2text||': '||p2 p2,p3text||': '||p3 p3
from gv$active_session_history
where to_char(sample_time,'Mondd_hh24mi') in (select
to_char(sample_time,'Mondd_hh24mi')
from gv$active_session_history
where event = 'log file sync'
group by to_char(sample_time,'Mondd_hh24mi'), inst_id
having avg(time_waited)/1000 > &&threshold)
order by 1,2,3,4,5;

select to_char(sysdate,'Mondd hh24:mi:ss') TIME from dual;

spool off

PROMPT
PROMPT OUTPUT FILE IS: lfsdiag_&&dbname&&timestamp&&suffix
PROMPT

jueves, 21 de enero de 2021

ASM Disk Header Corruption

 Ok... Luego de una migracion de discos de ASM de un storage a otro y un reinicio del servidor... un disco me quedo con estado fuera del listado de discos del oracleasm... 

Lo agrege nuevamente y ahora era visible por la instancia ASM pero con el estado PROVISIONED en su cabecera....

Lo cual no permitia que el diskgroup fuese montado. 

Aplique esta solucion:


https://sites.google.com/site/wikiofdba/courses/med300/asm-disk-header-corruption


Buscar loS discos con problemas

SQL> select name,path ,header_status,mount_status from v$asm_disk;


Ojo, antes de realizar este paso tuve que agregar nuevamete el disco mediante oracleasm ya que nisiquiera estaba en el listado de discos

# oracleasm createdisk DATA_N02 /dev/dm-23

Ahora compilar y utilizar la herramienta:

kfed

[oracle@xxxx ~]$ cd $ORACLE_HOME/rdbms/lib
[oracle@xxxxx lib]$ make -f ins_rdbms.mk ikfed


Linking KFED utility (kfed)
rm -f /oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/kfed
gcc -o /oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/kfed -m64 -z noexecstack -L/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/ -L/oracle/app/oracle/product/11.2.0/dbhome_1/lib/ -L/oracle/app/oracle/product/11.2.0/dbhome_1/lib/stubs/  /oracle/app/oracle/product/11.2.0/dbhome_1/lib/s0main.o /oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/sskfeded.o /oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/skfedpt.o -ldbtools11 -lcommon11 -lcell11 -lskgxp11 -lhasgen11 -lskgxn2 -lnnz11 -lzt11 -lxml11 -locr11 -locrb11 -locrutl11 -lhasgen11 -lskgxn2 -lnnz11 -lzt11 -lxml11  -lasmclnt11 -lclntsh  `cat /oracle/app/oracle/product/11.2.0/dbhome_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnro11 `cat /oracle/app/oracle/product/11.2.0/dbhome_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnnz11 -lzt11 -lztkg11 -lclient11 -lnnetd11  -lvsn11 -lcommon11 -lgeneric11 -lmm -lsnls11 -lnls11  -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 `cat /oracle/app/oracle/product/11.2.0/dbhome_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnro11 `cat /oracle/app/oracle/product/11.2.0/dbhome_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lclient11 -lnnetd11  -lvsn11 -lcommon11 -lgeneric11   -lsnls11 -lnls11  -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 -lclient11 -lnnetd11  -lvsn11 -lcommon11 -lgeneric11 -lsnls11 -lnls11  -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11   `cat /oracle/app/oracle/product/11.2.0/dbhome_1/lib/sysliblist` -Wl,-rpath,/oracle/app/oracle/product/11.2.0/dbhome_1/lib -lm    `cat /oracle/app/oracle/product/11.2.0/dbhome_1/lib/sysliblist` -ldl -lm   -L/oracle/app/oracle/product/11.2.0/dbhome_1/lib
test ! -f /oracle/app/oracle/product/11.2.0/dbhome_1/bin/kfed ||\
       mv -f /oracle/app/oracle/product/11.2.0/dbhome_1/bin/kfed /oracle/app/oracle/product/11.2.0/dbhome_1/bin/kfedO
mv /oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/lib/kfed /oracle/app/oracle/product/11.2.0/dbhome_1/bin/kfed
chmod 751 /oracle/app/oracle/product/11.2.0/dbhome_1/bin/kfed

Cruzar los dedos y esperar que funcione correctamente

[oracle@xxxx lib]$ kfed repair /dev/oracleasm/disks/DATA_N02

Consultar nuevamente y validar que el estado del disco sea MEMBER

select name,path ,header_status,mount_status from v$asm_disk;


Luego que todos los discos aparezcan como MEMBER intentar montar el diskgroup nuevamente. 




lunes, 7 de mayo de 2018

Copiar Datafile de Filesytem a ASM

Escenario:
Tenemos un datafile que ha sido creado erroneamente en filestem y no en ASM como debio ser.

1 - Conseguimos el nombre del datafile:
SQL> select file_name from dba_data_files where tablespace_name='UNDOTS1'
/oracle/app/oracle/product/11.2.0.4/db_1/dbs/DATA

2 - Colocamos el tablespace OFFLINE si es el caso.
SQL>alter tablespace UNDOTS1 offline;

3 - Nos conectamos a Rman y ejecutamos un copy
RMAN> copy datafile '/oracle/app/oracle/product/11.2.0.4/db_1/dbs/DATA' TO '+DATA';

4 - Muy pendientes en este punto ya que debemos ubicar el nombre del datafile que nos da RMAN
la linea es similar a esta:

output file name=+DATA/mxxxxx/datafile/UNDO1.733.935381641 tag=TAG20170208T041400 RECID=3 STAMP=935381644

5- Ahora desde sqlplus recombramos en nuestro controlfile el dafafile (la ubicacion anterior a la nueva en el ASM)
SQL> alter database rename file '/oracle/app/oracle/product/11.2.0.4/db_1/dbs/DATA' to '+DATA/mxxxxx/datafile/UNDO1.733.935381641';

6- TRaemos el tablespace ONLINE si hicimos el paso 2
SQL> alter tablespace UNDOTS1 online;


miércoles, 25 de abril de 2018

Excluir tabla de un expdp


Para usar el parametro EXCLUDE en un expdp desde la consola o un parfile debe hacerse asi:

 ...   "EXCLUDE=TABLE:\"IN('NEG','INT','NEI','CEI','PEI')\""

 Asi tal cual con las dobles comillas antes del EXCLUDE...