Monday, January 30, 2012

Oracle and OCFS2 not releasing space used

Sometimes you have to drop a tablespace to recover storage space and use it to create other tablespace, like when you have to resize an undo tablespace. And usually is not a big issue unless you have OCFS2 file systems:

oracle@myserver$ df -m|egrep '(Filesystem)|(/mydb/undo)'
Filesystem 1M-blocks Used Available Use% Mounted on
24576 24572 4 100% /mydb/undo

oracle@myserver$ sqlplus '/ as sysdba'

SQL*Plus: Release 10.2.0.4.0 - Production on Thu Jan 26 22:57:35 2012

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> drop tablespace myundo including contents and datafiles;

Tablespace dropped.

SQL> create undo tablespace mynewundo datafile '/mydb/undo/undo.dbf' size 10g;
create undo tablespace mynewundo datafile '/mydb/undo/undo.dbf' size 10g
*
ERROR at line 1:
ORA-01119: error in creating database file '/mydb/undo/undo.dbf'
ORA-27044: unable to write the header block of file
Linux-ia64 Error: 28: No space left on device
Additional information: 4

SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

oracle@myserver$ df -m|egrep '(Filesystem)|(/mydb/undo)'
Filesystem 1M-blocks Used Available Use% Mounted on
24576 24572 4 100% /mydb/undo

oracle@myserver$ ls -la /mydb/undo
total 16
drwxr-xr-x 4 root root 4096 Jan 20 2010 .
drwxr-xr-x 4 root root 4096 Dec 17 2009 ..
drwxr-xr-x 2 root root 4096 Dec 17 2009 lost+found

As you might notice there is no space recovered from dropping that undo tablespace, and since we need to create a new undo tablespace in the same file system we have to do something.

I don't have a lot of dabatases placed in OCFS2 file systems so I didn't care about finding the root cause of this problem, and since I had this database with no users connected I just created a small undo tablespace somewhere else, shut down the instance, and after doing it I got that space back:

oracle@myserver$ df -m|egrep '(Filesystem)|(/mydb/undo)'
Filesystem 1M-blocks Used Available Use% Mounted on
24576 359 24217 2% /mydb/undo

oracle@myserver$ ls -la /mydb/undo
total 16
drwxr-xr-x 4 root root 4096 Jan 20 2010 .
drwxr-xr-x 4 root root 4096 Dec 17 2009 ..
drwxr-xr-x 2 root root 4096 Dec 17 2009 lost+found

oracle@myserver$ mount|grep /mydb/undo
/dev/mapper/myvg-undo on /mydb/undo type ocfs2 (rw,_netdev,datavolume,nointr,heartbeat=local)

oracle@myserver$ uname -a
Linux myserver.localdomain 2.6.9-67.EL #1 SMP Wed Nov 7 13:43:35 EST 2007 ia64 ia64 ia64 GNU/Linux

oracle@myserver$ /sbin/lsmod|grep ocf
ocfs2 744096 26
debugfs 27340 2 ocfs2
ocfs2_dlmfs 53416 1
ocfs2_dlm 424192 2 ocfs2,ocfs2_dlmfs
ocfs2_nodemanager 316791 32 ocfs2,ocfs2_dlmfs,ocfs2_dlm
configfs 65468 2 ocfs2_nodemanager
jbd 149272 2 ocfs2,ext3

oracle@myserver$ /sbin/modinfo ocfs2
filename: /lib/modules/2.6.9-67.EL/kernel/fs/ocfs2/ocfs2.ko
license: GPL
author: Oracle
version: 1.2.9 1B43458FD47258934A48F1C
description: OCFS2 1.2.9 Mon May 19 14:04:34 PDT 2008 (build a693806cb619dd7f225004092b675ede)
depends: ocfs2_nodemanager,ocfs2_dlm,jbd,debugfs
vermagic: 2.6.9-67.EL SMP ia64gcc-3.4

I know this is just a workaround and not a good one, but it works fine and you can move on the next thing.

No comments:

Post a Comment