测试目标:
如何清空lvm的lv,并让oracle再次使用
显示lv逻辑卷
[root@rhel5 ~]# lvdisplay /dev/vg2/lv2
--- Logical volume ---
LV Name /dev/vg2/lv2
VG Name vg2
LV UUID WMs2Xf-dZ7f-mUyc-OHnh-C50U-DvAc-I7TZBU
LV Write Access read/write
LV Status available
# open 1
LV Size 52.00 MB --逻辑卷大小为52m
Current LE 13
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
[root@rhel5 ~]# ls -l /dev/nu*
crw-rw-rw- 1 root root 1, 3 Jun 24 01:44 /dev/null
---清空lv
[root@rhel5 ~]# dd if=/dev/null f=/dev/vg2/lv2
0+0 records in
0+0 records out
0 bytes (0 B) copied, 4.1775e-05 seconds, 0.0 kB/s
[root@rhel5 ~]# su - oracle
-bash-3.2$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 24 06:20:41 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> col file_name for a50
SQL> set linesize 300
SQL> select tablespace_name,file_name,bytes/1024/1024 as curmb,increment_by from dba_data_files;
TABLESPACE_NAME FILE_NAME CURMB INCREMENT_BY
------------------------------ -------------------------------------------------- ---------- ------------
SYSTEM /oracle/app/oracle/oradata/zxy/system01.dbf 700 1
SYSAUX /oracle/app/oracle/oradata/zxy/sysaux01.dbf 600 1280
UNDOTBS1 /oracle/app/oracle/oradata/zxy/undotbs01.dbf 1080 640
USERS /oracle/app/oracle/oradata/zxy/users01.dbf 235 160
---裸设备不能完全分配给oracle使用
SQL> create tablespace tbs_raw datafile '/dev/vg2/lv2' size 52m;
create tablespace tbs_raw datafile '/dev/vg2/lv2' size 52m
*
ERROR at line 1:
ORA-01119: error in creating database file '/dev/vg2/lv2'
ORA-27042: not enough space on raw partition to fullfill request
Additional information: 1
SQL> create tablespace tbs_raw datafile '/dev/vg2/lv2' size 51m;
Tablespace created.
---在裸设备表空间建表并插入数据
SQL> create table t_raw(a int) tablespace tbs_raw;
Table created.
SQL> insert into t_raw values(1);
1 row created.
SQL> insert into t_raw values(3);
1 row created.
SQL> commit;
Commit complete.
---如果在已使用的数据文件上建表空间会报错
SQL> create tablespace tbs_exist datafile '/dev/vg2/lv2' size 50m;
create tablespace tbs_exist datafile '/dev/vg2/lv2' size 50m
*
ERROR at line 1:
ORA-01537: cannot add file '/dev/vg2/lv2' - file already part of database
---如何不清空裸设备再次使用裸设备会报错吗
SQL> drop tablespace tbs_raw including contents and datafiles;
Tablespace dropped.
---不清空裸设备也可以正常再次使用裸设备
SQL> create tablespace tbs_reuse datafile '/dev/vg2/lv2' size 10m;
Tablespace created.
SQL> create table t_raw(a int) tablespace tbs_reuse;
Table created.
SQL> insert into t_raw values(1);
1 row created.
SQL> commit;
Commit complete.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9240380/viewspace-764677/ ,如需转载,请注明出处,否则将追究法律责任。