redhat linux上不用dd清空raw device可以重複使用raw device嗎

wisdomone1發表於2013-06-24

測試目標:
     如何清空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部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-764677/,如需轉載,請註明出處,否則將追究法律責任。

相關文章