I've noticed that on some of my databases, the SYSAUX tablespace kept on
growing to unreasonable proportions.
The following objects would grow to several gigabytes in size .
SYS WRI$_OPTSTAT_HISTGRM_HISTORY
TABLE
SYS WRI$_OPTSTAT_HISTHEAD_HISTORY
TABLE
SYS WRI$_OPTSTAT_IND_HISTORY TABLE
SYS I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST
INDEX
SYS I_WRI$_OPTSTAT_H_ST
INDEX
This is due to the retention of system statistics by Oracle (default 1
month).
SQL> select dbms_stats.get_stats_history_retention present_retention
from dual;
PRESENT_RETENTION
-----------------
31
It is possible to modify the retention period through the dbms_stats
package.
SQL> exec DBMS_STATS.ALTER_STATS_HISTORY_RETENTION(7);
PL/SQL procedure successfully completed.
SQL> select dbms_stats.get_stats_history_retention
present_retention from dual;
PRESENT_RETENTION
-----------------
7
It is also possible to purge the statistics history, through the use of the
same package.
exec DBMS_STATS.PURGE_STATS(SYSDATE-7);
Beware, the process can be quite long (several hours), and
undo tablespace-consuming.
Be sure you dispose of enough diskspace to accomodate the resulting rollback
segment and archivelog creation, and be prepared to delete archivelogs through
RMAN.
Leave me a note if this post has been useful to you.
Happy computing
Nixman.
Oracle
lundi 22 août 2011
SYSAUX tablespace grows because of statistics retention
Par Nixman le lundi 22 août 2011, 13:57
mardi 21 septembre 2010
Purge des logs sous adrci
Par Nixman le mardi 21 septembre 2010, 16:17
Par contre, au vu de la quantité de logs générées par Oracle 11gR2, il est important de mettre en place une politique de purge efficace.
Purge automatique des logs sous adrci:
L'âge des logs est exprimée en
heures
Par défaut, les logs sont purgés tous les mois pour les logs à vie courte (720
heures) et tous les ans pour les logs à vie longue (8760 heures).
Nous allons baisser ces valeurs à 7 et 30 jours (168 et 720 heures).
adrci> show home
ADR Homes:
diag/tnslsnr/srv_1/listener
diag/tnslsnr/srv_1/listener_scan1
diag/asm/+asm/+ASM1
adrci> set home diag/tnslsnr/srv_1/listener
adrci> show control
ADR Home = /u01/app/grid/diag/tnslsnr/srv_1/listener:
*************************************************************************
ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
3936991633 720 8760 2010-01-18 18:23:33.022104 +01:00 2010-09-21 11:59:19.401387 +02:00 1 2 76 1 2010-01-18 18:23:33.022104 +01:00
1 rows fetched
adrci> set control (SHORTP_POLICY=168)
adrci> set control (LONGP_POLICY=720)
adrci> show control
ADR Home = /u01/app/grid/diag/tnslsnr/srv_1/listener:
*************************************************************************
ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
3936991633 168 720 2010-09-21 12:05:06.248617 +02:00 2010-09-21 11:59:19.401387 +02:00 1 2 76 1 2010-01-18 18:23:33.022104 +01:00
1 rows fetched
Réaliser la même modification pour les autres homes
adrci> set home diag/tnslsnr/srv_1/listener_scan1
adrci> set control (SHORTP_POLICY=168)
adrci> set control (LONGP_POLICY=720)
adrci> set home diag/asm/+asm/+ASM1
adrci> set control (SHORTP_POLICY=168)
adrci> set control (LONGP_POLICY=720)
Purge manuelle des logs sous adrci:
Cette fois-ci, l'âge des logs est exprimée en
minutes
adrci> show home
ADR Homes:
diag/tnslsnr/srv_1/listener
diag/tnslsnr/srv_1/listener_scan1
diag/asm/+asm/+ASM1
adrci> set home diag/tnslsnr/srv_1/listener
adrci> purge -age 5400
jeudi 8 avril 2010
Multiplexer les redo logs Oracle sous ASM
Par Nixman le jeudi 8 avril 2010, 15:04
SQL> select group#, member from v$logfile;
GROUP# MEMBER
---------- --------------------------------------------------
1
+FRA/MYDB/onlinelog/group_1.257.715620719
2
+FRA/MYDB/onlinelog/group_2.258.715620719
3
+FRA/MYDB/onlinelog/group_3.259.715620719
SQL> select group#, status, bytes/1024 from v$log;
GROUP#
STATUS
BYTES/1024
---------- ---------------- ----------
1
ACTIVE
51200
2
CURRENT
51200
3
ACTIVE
51200
SQL> alter system switch logfile;
SQL> alter system switch logfile;
SQL> alter system switch logfile;
SQL> alter system checkpoint global;
SQL> select group#, status from v$log;
GROUP# STATUS
---------- ----------------
1 CURRENT
2 INACTIVE
3 INACTIVE
Prendre un des groupes en état INACTIVE et le supprimer, puis le recréer avec
deux membres.
Dans cet exemple, on suppose que l'instance est en mode OMF.
SQL> alter database drop logfile group 3;
(si le groupe 3 est en état INACTIVE)
SQL> select group#, status, bytes/1024 from v$log;
GROUP#
STATUS
BYTES/1024
---------- ---------------- ----------
1
CURRENT
51200
2
INACTIVE
51200
SQL> alter database add logfile group 3 ('+DATA','+FRA') size 51200K;
SQL> alter system switch logfile;
On vérifie que le groupe 3 possède désormais deux membres
SQL> select group#, status, members, bytes/1024 from v$log;
GROUP#
STATUS
MEMBERS BYTES/1024
---------- ---------------- ---------- ----------
1
ACTIVE
1 51200
2
INACTIVE
1 51200
3
CURRENT
2 51200
SQL> select group#, member from v$logfile order by 1
GROUP# MEMBER
---------- --------------------------------------------------
1
+FRA/MYDB/onlinelog/group_1.257.715710709
1
+DATA/MYDB/onlinelog/group_1.285.715710709
2
+FRA/MYDB/onlinelog/group_2.258.715710073
2
+DATA/MYDB/onlinelog/group_2.284.715710073
3
+FRA/MYDB/onlinelog/group_3.259.715709881
3
+DATA/MYDB/onlinelog/group_3.282.715709881
Et faire ainsi de suite pour les trois groupes... Ici, on peut dropper et
recréer le groupe 2 car il est inactif
Attention à ne pas dropper les trois groupes de logs en même temps ou de
dropper un logfile group actif!
N'hésitez pas à un message si cet article vous a été utile.
Nixman
mercredi 7 avril 2010
Multiplexing an Oracle controlfile in ASM
Par Nixman le mercredi 7 avril 2010, 15:54
1) Check current controlfile's name and restart the database
NOMOUNT
SQL> show parameter control_files
NAME
TYPE VALUE
------------------------------------ -----------
-----------------------------------------------
control_files
string
+FRA/MYDB/controlfile/current.256.715620719
SQL> shutdown immediate
SQL> startup nomount
2) Copy/restore current controlfile through RMAN
$ rman target /
RMAN> restore controlfile to '+DATA' from
'+FRA/MYDB/controlfile/current.256.715620719';
Starting restore at 07-APR-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=272 device type=DISK
channel ORA_DISK_1: copied control file copy
Finished restore at 07-APR-10
3) Find out the name of the new controlfile through
asmcmd
ASMCMD> ls -lsa +DATA/MYDB/controlfile
Type Redund Striped
Time
Sys Block_Size Blocks
Bytes Space Name
CONTROLFILE UNPROT FINE APR 07
14:00:00 Y
16384 595 9748480 16777216 none =>
current.283.715704921
4) Modify your spfile to take into account the new
controlfile
SQL> alter system set
control_files='+DATA/MYDB/controlfiles/current.283.715704921','+FRA/MYDB/controlfile/current.256.715620719'
scope=spfile;
5) Restart the database and check
SQL> shutdown immediate
SQL> startup
SQL> show parameter control_files;
NAME
TYPE VALUE
------------------------------------ -----------
------------------------------
control_files
string +DATA/MYDB/controlfiles/cu
rrent.283.715704921, +FRA/mmtw
ebdv/controlfile/current.256.7
15620719
Leave me a line if this note has been useful to you.
Happy computing
Nixman
Multiplexer le fichier de contrôle Oracle sous ASM
Par Nixman le mercredi 7 avril 2010, 15:50
1) Vérifier le nom du fichier de contrôle actuel:
SQL> show parameter control_files
NAME
TYPE VALUE
------------------------------------ -----------
-----------------------------------------------
control_files
string
+FRA/MYDB/controlfile/current.256.715620719
SQL> shutdown immediate
SQL> startup nomount
2) Effetuer la copie du fichier de contrôle via rman
$ rman target /
RMAN> restore controlfile to '+DATA' from
'+FRA/MYDB/controlfile/current.256.715620719';
Starting restore at 07-APR-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=272 device type=DISK
channel ORA_DISK_1: copied control file copy
Finished restore at 07-APR-10
3) Retrouver le nom du nouveau fichier de contrôle via
asmcmd:
ASMCMD> ls -lsa +DATA/MYDB/controlfile
Type Redund Striped
Time
Sys Block_Size Blocks
Bytes Space Name
CONTROLFILE UNPROT FINE APR 07
14:00:00 Y
16384 595 9748480 16777216 none =>
current.283.715704921
4) Modifier les paramètres d'init pour prendre en compte le nouveau
fichier de contrôle:
SQL> alter system set
control_files='+DATA/MYDB/controlfiles/current.283.715704921','+FRA/MYDB/controlfile/current.256.715620719'
scope=spfile;
5) Redémarrer la base et vérifier:
SQL> shutdown immediate
SQL> startup
SQL> show parameter control_files;
NAME
TYPE VALUE
------------------------------------ -----------
------------------------------
control_files
string +DATA/MYDB/controlfiles/cu
rrent.283.715704921, +FRA/mmtw
ebdv/controlfile/current.256.7
15620719
Laissez-moi une note si cet article vous a été utile.
Bonne journée.
Nixman
lundi 22 mars 2010
Purge backups OCR non fonctionnel sous Cluster Oracle 11gR2
Par Nixman le lundi 22 mars 2010, 14:31
Dans un cluster Oracle 11gR2, la purge des backups automatiques de l'OCR ne fonctionne pas (depuis version 10.2.4) si les fichiers *.ocr situés sous $ORA_CRS_HOME/cdata/<cluster_name> (ex:/u01/app/11.2.0/grid/cdata/inbdor0809-rac/) ont les mauvaises permissions. De ce fait, les fichiers *.ocr avec des noms aléatoires ne sont pas renoimmés en backupXX.ocr et ne sont pas purgés, saturant la partition.
ocrconfig -showbackup montre bien la bonne date de sauvegarde,
mais les fichiers backupXX.ocr ont une date bien antérieure.
Un grand nombre de fichiers XXXXXXXXX.ocr existe sous
$ORA_CRS_HOME/cdata/<cluster_name>.
# ls -rtl $ORA_CRS_HOME/cdata/<cluster_name>
-rw------- 1 grid oinstall 7081984 jan 18 22:24 day.ocr
-rw------- 1 grid oinstall 7081984 jan 19 02:24 day_.ocr
-rw------- 1 grid oinstall 7081984 jan 19 06:24 backup02.ocr
-rw------- 1 grid oinstall 7081984 jan 19 10:24 backup01.ocr
-rw------- 1 grid oinstall 7081984 jan 19 14:24 backup00.ocr
...
-rw------- 1 root root 7413760 mar 19 22:06 40778839.ocr
-rw------- 1 root root 7413760 mar 20 02:06 26378630.ocr
-rw------- 1 root root 7413760 mar 20 06:06 11332652.ocr
-rw------- 1 root root 7413760 mar 20 10:06 35215677.ocr
-rw------- 1 root root 7413760 mar 20 14:06 41977816.ocr
-rw------- 1 root root 7413760 mar 20 18:06 18335174.ocr
-rw------- 1 root root 7413760 mar 20 22:06 90743999.ocr
-rw------- 1 root root 7413760 mar 21 02:06 20182690.ocr
-rw------- 1 root root 7413760 mar 21 06:06 28125568.ocr
-rw------- 1 root root 7413760 mar 21 10:06 20121708.ocr
-rw------- 1 root root 7413760 mar 21 14:06 34916120.ocr
-rw------- 1 root root 7413760 mar 21 18:06 24068304.ocr
Solution:
chown root:root $ORA_CRS_HOME/cdata/<cluster_name>/*.ocr
Les fichiers XXXXXXXX.ocr peuvent être ensuite supprimés.
Référence: Note Metalink 741271.1
mardi 17 novembre 2009
STREAMS alter table move bug
Par Nixman le mardi 17 novembre 2009, 17:03
A very annoying STREAMS bug, which should be corrected in the 11GR2 release, is
the failure of STREAMS to keep up with an alter table move tablespace
command.
If your table contains a LOB, and want to do some reorg through a move, then
you will very likely hit the bug and receive the following error message in
your alert.log:
ORA-26744: STREAMS capture process "STREAMS_CAPTURE" does not support
"OWNER"."TABLE_NAME" because of the following reason:
ORA-26773: Invalid data type for column "malformed redo"
No workarounds exist, except excluding your table from your STREAMS
propagation.
Reimporting the table with a new flashback SCN won't work. You have to
reimplement the whole STREAMS process to get back on your feet.
Metalink réference:Bug 5623403.
vendredi 9 octobre 2009
Configuration particulière de STREAMS pour RAC
Par Nixman le vendredi 9 octobre 2009, 16:31
Dans le cadre d'un RAC, si l'on a configuré la propagation via un dblink, il faut indiquer un des noeuds comme propriétaire par défaut de la queue capture et apply de STREAMS. Sinon, on peut se retrouver confroté à une erreur ORA-25315 de façon aléatoire.
Le mieux, sur des configurations 10.2 ou supérieurs, étant de positionner le paramètre queue_to_queue à TRUE lors de la mise en place de la propagation avec DBMS_PROPAGATION_ADM.CREATE_PROPAGATION. On ne passera alors plus par le dblink. Il est impossible de modifier le paramètre en cours de route.
Réf: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_prop_a.htm
Retrouver les noms des queues STREAMS
set lines 150
SELECT q.OWNER, q.NAME, t.QUEUE_TABLE, t.OWNER_INSTANCE
- FROM DBA_QUEUES q, DBA_QUEUE_TABLES t
- WHERE t.OBJECT_TYPE = 'SYS.ANYDATA'
- AND q.QUEUE_TABLE = t.QUEUE_TABLE
- AND q.OWNER = t.OWNER;
Indiquer un propriétaire par défaut et un propriétaire secondaire
DBMS_AQADM.ALTER_QUEUE_TABLE (
- queue_table IN VARCHAR2,
- comment IN VARCHAR2 DEFAULT NULL,
- primary_instance IN BINARY_INTEGER DEFAULT NULL,
- secondary_instance IN BINARY_INTEGER DEFAULT NULL);
ex:
BEGIN
- DBMS_AQADM.ALTER_QUEUE_TABLE(
-
queue_table => 'MON_QUEUE_TABLE_APPLY',
-
primary_instance => 1,
-
secondary_instance => 2);
-
END; /
BEGIN
- DBMS_AQADM.ALTER_QUEUE_TABLE(
-
queue_table => 'MON_QUEUE_TABLE_CAPTURE',
-
primary_instance => 1,
-
secondary_instance => 2);
-
END; /
BEGIN
- DBMS_AQADM.ALTER_QUEUE_TABLE(
-
queue_table => 'SCHEDULER$_JOBQTAB',
-
primary_instance => 1,
-
secondary_instance => 2);
-
END; /
samedi 19 septembre 2009
Oracle 11gr2 RAC on Red Hat Linux 5.3 install guide part1
Par Nixman le samedi 19 septembre 2009, 14:55
Oracle 11gr2 RAC on Red Hat Linux 5.3 install guide part1: Installing the grid infrastructure:
Oracle 11gR2 has been released for Linux, and the installation has somewhat changed from precedent versions, including 11gR1. In this step-by-step guide, we will lead you through a real-life Oracle Real Application Cluster (RAC) installation, its novelties, incompatibilities, and the caveats of Oracle install documentation.
The installation process is divided into two parts: The grid infrastructure installation, which now includes the clusterware, but also ASM installation, which has been moved there from the regular database installation. This stems from the fact that ASM now supports voting disks, and OCR files, and you are no longer required (actually, its now discouraged) to place the voting disks and OCR files on raw devices.
Grid infrastructure also installs for you the ACFS cluster file system, which allows you to share the ORACLE_HOME of your database installation between all the nodes of your RAC cluster. However, it doesn't allow you to share the grid infrastructure ORACLE_HOME between the nodes. For that, you would need to install the grid infrastructure binaries on an ocfs2 filesystem. However, that's not supported by Oracle, nor does it work. Last year, Oracle had promised an Oracle Universal File System (UFS), and it is a bit disappointing to see that ACFS is not what we expected yet.
Download the necessary files:
You will need the grid infrastructure disk, as well as the two database disks from Oracle's site. Download as well the deinstall disk, as Oracle Universal Installer doesn't support the deinstallation of the binaries anymore, and everything has moved to this 300Mb plus disk.
You will also need the three asmlib files from OTN, that are downloadable here.
Do a uname -rm on your platform in order to find out which ones
are the right ones for you.
Oracle validate rpm will also be useful in order to ensure you have all the necessary rpm's installed on your server.
Setting the system parameters and prerequisites:
Nothing much new here. Simply follow the install guide's instructions. The installer will check anyhow if you have set the parameters right, and even generate a fixup script for most of the prerequisites.
# cat >> /etc/sysctl.conf <<EOF
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmax = 4294967296
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
EOF
# sysctl -p
An extremely intriguing fact is the necessity to set up ntpd with the -x option which disallows any brutal adjustment of the system clock under a drift of 600s (instead of 128ms by default). This is a workaround for a RAC bug that was supposed to have been corrected in release 10.2.0.3... Well, actually, it may not be a bug, but a feature for any cluster that needs synchronization. The downside of the -x option is, that if your hardware is down for a month, and the system clock goes off half an hour, it will take days for it to adjust slowly to network time.
Be sure to do a chkconfig oracleasm on after setting up
oracleasm on a RHEL 5.3. Else, you will corrupt your voting disks and OCR upon
the first reboot. The install guide has simply forgotten to mention that
oracleasm enable/disable have been deprecated on this platform.
Don't bother setting up VIP's or passwordless ssh connectivity, contrarily to what the install guide instructs you to do: the installer won't appreciate your initiative, and you will have to set them up the way Oracle wants it. Simply give the same password to your grid and oracle users on both nodes.
Creating the UNIX groups, users, and directories:
Create two separate users (grid and oracle for example), one for grid infrastructure installation, and one for the database installation, with separate ORACLE_BASE and ORACLE_HOME directories.
A new set of three groups have been created to manage asm. Grid user should be member of them.
A change to OFA is that the grid user's ORACLE_HOME cannot be under its ORACLE_BASE directory, but on a separate path.
Here, we will point oracle user's home to a shared ACFS mount. We'll mount that filesystem later, after grid infrastructure's installation when we will have ACFS installed. Indeed, ACFS is built on top of ASM, which in turn is installed as part of grid infrastructure. Hence the separation of grid infrastructure and database installation.
(As a footnote: you may change u01 to get27, for example, and still be OFA-compliant)
# /usr/sbin/groupadd oinstall
# /usr/sbin/groupadd dba
# /usr/sbin/groupadd oper
# /usr/sbin/groupadd asmadmin
# /usr/sbin/groupadd asmdba
# /usr/sbin/groupadd asmoper
# /usr/sbin/groupadd orauser
# /usr/sbin/usermod -g oinstall -G dba,asmdba oracle# /usr/sbin/usermod -g oinstall -G dba,asmdba,oper,oinstall,asmadmin grid
# mkdir /u01/app/11.2.0/grid
# mkdir /u01/app/grid
# mkdir /u01/app/acfsmounts/oracle
# chown -R grid:oinstall /u01/app
# chmod -R 775 /u01/app
# chown -R oracle:oinstall /u01/app/acfsmounts
# chmod -R 775 /u01/app/acfsmounts
# cat >> /etc/security/limits.conf <<EOFgrid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
To be continued ... stay tuned.
mercredi 16 septembre 2009
Enabling server-side failover, TAF and load-balancing on Oracle 1OgR2 RAC
Par Nixman le mercredi 16 septembre 2009, 20:26
Sometimes, you don't have the possiblity enable Transparent application failover on the client side (in the tnsnames.ora file for example).
That's where this new feature in Oracle 10gR2 RAC comes handy:
You can enable both failover and load-balancing on the server side, by executing a simple dbms_service procedure.
EXECUTE DBMS_SERVICE.MODIFY_SERVICE (service_name =>
'MY_SERVICE_NAME'
, aq_ha_notifications => TRUE
, failover_method => DBMS_SERVICE.FAILOVER_METHOD_BASIC
, failover_type => DBMS_SERVICE.FAILOVER_TYPE_SELECT
, failover_retries => 60
, failover_delay => 10
, clb_goal => DBMS_SERVICE.CLB_GOAL_LONG);
To disable the feature, it's as simple:
begindbms_service.modify_service(
service_name=>'MY_SERVICE_NAME',
failover_type=>DBMS_SERVICE.FAILOVER_TYPE_NONE,
failover_method=>DBMS_SERVICE.FAILOVER_METHOD_NONE
);
end;
/
For complete documentation, you can check:
http://download.oracle.com/docs/cd/B19306_01/rac.102/b14197/hafeats.htm#BABIAICG
Happy computing,
Nixman
Purger les jobs Datapump terminés ou orphelins
Par Nixman le mercredi 16 septembre 2009, 20:11
Réf: Metalink Doc ID: 336014.1
SQL > SET lines 200
COL owner_name FORMAT a10
COL job_name FORMAT a20
COL state FORMAT a11
COL operation LIKE state
COL job_mode LIKE state
SQL> SELECT owner_name, job_name, operation, job_mode, state, attached_sessions FROM dba_datapump_jobs WHERE job_name NOT LIKE 'BIN$%' order by 1,2;
EXPIMP SYS_EXPORT_TABLE_02 EXPORT TABLE NOT RUNNING 0
EXPIMP SYS_EXPORT_FULL_01 EXPORT FULL NOT RUNNING 0
Ne sélectionner que ceux qui sont en "NOT RUNNING". Voir où se trouvent leurs Master tables:
SQL> SELECT o.status, o.object_id, o.object_type,
o.owner||'.'||object_name "OWNER.OBJECT"
FROM dba_objects o, dba_datapump_jobs j
WHERE o.owner=j.owner_name AND o.object_name=j.job_name
AND j.job_name NOT LIKE 'BIN$%' ORDER BY 4,2;
VALID 85215 TABLE EXPIMP.SYS_EXPORT_TABLE_02
VALID 85162 TABLE EXPIMP.SYS_EXPORT_FULL_01
Dropper les Master tables concernés:
SQL> DROP TABLE EXPIMP.sys_export_table_02;
SQL> DROP TABLE EXPIMP.sys_export_full_01;Killer un job datapump non interactif proprement
Par Nixman le mercredi 16 septembre 2009, 20:07
Réf: Metalink Doc ID: 336014.1
SQL> SET lines 200
COL owner_name FORMAT a10
COL job_name FORMAT a20
COL state FORMAT a11
COL operation LIKE state
COL job_mode LIKE state
SQL> SELECT owner_name, job_name, operation, job_mode, state, attached_sessions FROM dba_datapump_jobs WHERE job_name NOT LIKE 'BIN$%';
EXPIMP SYS_EXPORT_FULL_05 EXPORT FULL RUNNING 0
SQL> connect expimp/expimp
SQL> DECLARE h1 number;
- BEGIN
- h1 := DBMS_DATAPUMP.ATTACH('SYS_EXPORT_FULL_05','EXPIMP');
- DBMS_DATAPUMP.STOP_JOB (h1);
- END;
/
La session passe en "STOP PENDING" pendant un certain temps, puis en "NOT RUNNING"jeudi 14 août 2008
HR ACCESS user logins and passwords
Par Nixman le jeudi 14 août 2008, 12:03
HR ACCESS stores the user passwords without encryption in the UC10 table. As an Oracle DBA, if you have access to the database instance, all you have to do is issue the following command through SQL*PLUS:
SQL> select cdutil, cdpass from UC10;
CDUTIL CDPASS-------- --------
USER1 PASWORD1
USER2 PASWORD2
USER3 PASWORD3
USER4 PASWORD4
USER5 PASWORD5
Happy computing.
Drop me a comment if this post has been useful to you, or if you see any reason for add-on or modification.
Nixman
dimanche 18 mai 2008
Installing and configuring Oracle Heterogeneous Services for SQLServer
Par Nixman le dimanche 18 mai 2008, 16:59
All databases share a common set of normalized SQL, which, in theory, allows them to interoperate directly using database links.
However, reality is not so simple, as those who've tried to connect DB2 with SQLServer might have realized.
Luckily, with Oracle, there are at least two ways to achieve direct SQL*NET connectivity to foreign databases: Oracle Heterogeneous Services ODBC (HSODBC) and Oracle Transparent Gateways.
Here, we will achieve a simple database link between an Oracle database on a UNIX server and an SQLServer database residing on a Windows Server 2003 machine through the simplest of the two methods: Oracle Heterogeneous services. Bluntly, it consists in installing an Oracle pseudo-listener on the target non-Oracle database server.
As Microsoft doesn't provide any sort of UNIX client for SQL Server, all this interoperability is achieved thanks to work done by Oracle coders. Kudos to them, and the opposite to the other guys.
X = Windows Server 2003 with SQLServer 2005 + Oracle 8iR3 with Oracle HS
Y = Solaris 8 server with Oracle 8iR3 + Heterogeneous Services installed.
On X:
Step 0) On X: Install Oracle Server 8iR3 software or later with Heterogenous Database connectivity (Check that ODBC DRIVERS have really been installed). I won't detail the installation of Oracle on Windows here.
Step 1) On X: Configure DSN:
Go to: Settings -> Control Panel. Double-click on ODBC icon.
Then click on the System DSN tab and Add button. Add SQL Server, as local server. Name it, for example, MSQL (we will be using "MSQL" in our example configuration files from now on).
Test it. The default database is the on we're targetting.
Step 2) On X : Copy the file inithsodbc.ora into initMSQL.ora in the $ORACLE_HOME\hs\admin directory (If you'd named the DSN "ZOZO" in the previous step, you would have named the file initZOZO.ora, of course).
Step 3) On X: Modify the initMSQL.ora file in the following manner (HS_FDS_CONNECT_INFO must have the same name as the DSN):
###########
#
# HS init parameters
#
HS_FDS_CONNECT_INFO = MSQL
HS_FDS_TRACE_LEVEL = NO
###########
Step 4) On X: Modify the listener.ora file in $ORACLE_HOME\network\admin directory in the following manner (you're modifying the SID_LIST_LISTENER paragraph. SID_NAME must be the same as the DSN) :
###########
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=MSQL)
(ORACLE_HOME = c:\Orant)
(PROGRAM=hsodbc)
)
)
###########
Another solution would be to add an altogether new listener, that you've called MSQL, like this (here, we've set it to listen on port 1522):
###########
MSQL =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1522))
(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
SID_LIST_MSQL=
(SID_LIST=
(SID_DESC=
(SID_NAME=MSQL)
(ORACLE_HOME = c:\Orant)
(PROGRAM=hsodbc)
)
)
###########
In that case, you would have to start this listener specifically by issuing a
lsnrctl start MSQLStep 5) On X: restart the listener by issuing a
lsnrctl
reload.On Y:
Step 1) On Y: set GLOBAL_NAMES=FALSE in your database's init.ora file or in the initialization parameters.
Step 2) On Y: Add an entry pointing at server X listener by adding the following lines to the tnsnames.ora file:
###########
testMSQL =
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=tcp)
(HOST=SERVER_X_IP_ADDRESS)
(PORT=SERVER_X_LISTENER_PORT)
)
(CONNECT_DATA=
(SID=MSQL)
)
(HS=OK)
)
###########
Step 3) On Y: Test connectivity by issuing a
tnsping
testMSQLStep 4) On Y: Create the database link between your Oracle database and testMSQL by issuing the following SQL command:
SQL>
create public database link testingMSQL connect to USER
identified by PASSWORD using 'testMSQL';Step 5) On Y: Do some selects on Server X's tables:
SQL>
select * from TABLE_NAME@testingMSQL;
You're done!Beware that you're restricted to normalized SQL. between the two databases. Old-timers will find themselves back in Oracle 6 days: You won't be able to use INSERT SELECT statements or other Oracle enhancements, but will have to go through a cursor, etc... However, you will be able to issue simple SELECT, INSERT and UPDATE commands. Which is what you wanted in the first place.
Happy computing.
Drop me a comment if this post has been useful to you, or if you see any reason for add-on or modification.
Nixman
vendredi 9 mai 2008
Selecting tables for an import parfile
Par Nixman le vendredi 9 mai 2008, 21:40
This little SQL script is quite handy when constructing a parfile for an import from a dump file of a previous Oracle export
Suppose you want to import all tables beginning with "XY", and there are several hundreds of them.
You would first construct a parfile named my_parfile.par, with the following content:
USERID=USER/PASSWORDBUFFER=40960
FILE=DUMP_FILE_NAME.dmp
LOG=IMPORT_LOG_FILE_NAME.log
INDEXES=Y
ROWS=Y
CONSTRAINTS=Y
Then, you would create the following sql script (that you've called select_xy_tables_parfile.sql), in order to construct the list of tables you want to import (supposing the tables still have the same names as at the moment of the initial export):
set head off
set pages 0
set trims on
set echo off
set feedback off
spool my_XY_tables.txt
select decode( rownum, 1, 'TABLES=(', ',' ), table_name
from user_tables
where table_name like 'XY%'
union all
select ')', null
from dual ;
spool off
quitThen, just run the script against your database:
SQL> @select_xy_tables_parfile.sqlAfter that, just do a
cat my_XY_tables.txt >>
my_parfile.parFinally, after setting the correct ORACLE_SID, do an
imp
parfile=./my_parfile.par
You're done.
Happy computing.
Drop me a comment if this post has been useful to you, or if you see any reason for add-on or modification.
Nixman
mercredi 30 avril 2008
Trouver le process ID UNIX d'une session Oracle
Par Nixman le mercredi 30 avril 2008, 23:07
(If you're looking for the english version, it's here)
(Ceci est la traduction française de l'article précédent.)
Fonctionne sur: Solaris, Linux, AIX
Supposons que vous ayiez un processus Oracle qui ait généré un verrou sur votre base de données et n'arrivez pas à le tuer avec une simple commande
ALTER
SYSTEM KILL SESSION 'sid, serial#'
Il vous suffit alors d'effecuer la jointure suivante entre les tables V$SESSION et V$PROCESS d'Oracle, afin de retrouver le process ID système (spid) qu'il faudra tuer:
SELECT s.sid, s.serial#, s.username, s.osuser, p.spid, s.machine,
p.terminal, s.program
FROM v$session s, v$process p
WHERE s.paddr = p.addr;La colonne spid vous donne la valeur du process ID qu'il faudra tuer avec une commande shell
kill -9 spid.Et voilà!
Rem: Sur un serveur Windows, on utiliserait la commande suivante:
orakill $ORACLE_SID spidLaissez-moi un commentaire si cet article vous a été utile.
Bien à vous
Nixman
vendredi 14 mars 2008
Finding the UNIX process ID of an Oracle session to kill
Par Nixman le vendredi 14 mars 2008, 23:41
Works with: Solaris, Linux, AIX
Let us start with something easy and frequently used on sites with badly written PL/SQL code.
Let's suppose that you have an Oracle process that has gone astray, or even worse, is generating a lock on your database, preventing other users from making updates on a table.
The first step would be to find the Oracle session that's causing the lock (not the ones that are suffering from the lock, which you would find easily by quering the V$SESSION table).
It's as easy as:
SELECT * FROM dba_blockers;
You might have to wait for a while before getting the magic serial# and sid
(not to be mistaken with ORACLE_SID of course) needed to run your ALTER
SYSTEM KILL SESSION 'sid , serial#' command.
Note: on Oracle 8i and earlier, you would first have to run the catblock.sql script in $ORACLE_HOME/rdbms/admin/ directory in order to create the DBA_BLOCKERS table.
However, sometimes killing the session simply won't work. In that case, you could have to kill the session, or an Oracle proces gone astray through UNIX system utilities.For that purpose, on UNIX systems, Oracle has the V$PROCESS table, which can be joined with the V$SESSION table to find the UNIX process ID matching your Oracle session ID (the sid field of DBA_BLOCKERS).
The following query will yield you the needed system process ID (spid), among other useful information about your rogue process or session:
SELECT s.sid, s.serial#, s.username, s.osuser, p.spid, s.machine,
p.terminal, s.program
FROM v$session s, v$process p
WHERE s.paddr = p.addr;All you need to do now is to run a
kill -9 spid on
your UNIX machine upon the process number given by the spid column of the above
query.Note: On a windows box, you would use the orakilll.exe utility located in $ORACLE_HOME/bin. Like this:
orakill $ORACLE_SID spidHappy computing.
Drop me a comment if this post has been useful to you.
Alternatively, you could also visit a few links to keep me in business ;-)
Nixman