Redhat5.8 X64建立裸裝置

woshishui11211發表於2014-03-18

Redhat5.8 X64建立裸裝置

1)    裸裝置建立在sdb

# fdisk -l

 

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14         268     2048287+  82  Linux swap / Solaris

/dev/sda3             269        2610    18812115   83  Linux

 

Disk /dev/sdb: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/sdb doesn't contain a valid partition table

 

2)    建立分割槽

# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

 

 

The number of cylinders for this disk is set to 1958.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

   (e.g., DOS FDISK, OS/2 FDISK)

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-1958, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-1958, default 1958): +1024M

//1GB

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

3)    檢視分割槽

# fdisk -l

 

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14         268     2048287+  82  Linux swap / Solaris

/dev/sda3             269        2610    18812115   83  Linux

 

Disk /dev/sdb: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         125     1004031   83  Linux

 

 

4)    利用分割槽建立PV

# pvcreate /dev/sdb1

  Writing physical volume data to disk "/dev/sdb1"

  Physical volume "/dev/sdb1" successfully created

 

 

5)    檢視PV資訊

# pvdisplay /dev/sdb1

  "/dev/sdb1" is a new physical volume of "980.50 MB"

  --- NEW Physical volume ---

  PV Name               /dev/sdb1

  VG Name              

  PV Size               980.50 MB

  Allocatable           NO

  PE Size (KByte)       0

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               KhQgMz-onKa-6gAL-Nybp-jt59-ux7O-CItJef

 

 

6)    建立VG

# vgcreate oravg /dev/sdb1

  Volume group "oravg" successfully created

 

檢視VG

# vgs

  VG    #PV #LV #SN Attr   VSize   VFree 

  oravg   1   0   0 wz--n- 980.00M 980.00M

 

7)    建立LV

# lvcreate -n test_lv -L 512M oravg

# lvs

  LV      VG    Attr   LSize   Origin Snap%  Move Log Copy%  Convert

  test_lv oravg -wi-a- 512.00M     

# ls -l /dev/oravg/

total 0

lrwxrwxrwx 1 root root 25 Oct 20 22:39 test_lv -> /dev/mapper/oravg-test_lv

lvremove /dev/oravg/ test_lv   --刪除lv

 

 

8)    繫結裸裝置

# raw /dev/raw/raw1 /dev/mapper/oravg-test_lv

/dev/raw/raw1:  bound to major 253, minor 0

--注意,之前是沒有/dev/raw目錄的,執行後會自動建立

 

查詢裸裝置

# raw -qa

/dev/raw/raw1:  bound to major 253, minor 0

 

9)    給新建立的裸裝置增加許可權,以使oracle能使用

# chown -R oracle:oinstall /dev/mapper/oravg-test_lv

 

重啟許可權會丟失,寫到開機啟動裡

vi /etc/rc.d/rc.local

chown -R oracle:oinstall /dev/mapper/oravg-test_lv

10)            為了保證重啟後,可以掛載裸裝置,修改下面檔案,新增內容

# vi /etc/sysconfig/rawdevices

/dev/raw/raw1 /dev/mapper/oravg-test_lv

 

重啟裸裝置服務,檢視裝置是否存在

# /etc/init.d/rawdevices restart

Assigning devices:

           /dev/raw/raw1  --&gt   /dev/mapper/oravg-test_lv

/dev/raw/raw1:  bound to major 253, minor 0

done

[root@oracle mapper]# ls -l /dev/mapper/

total 0

crw------- 1 root   root      10, 60 Oct 20 22:28 control

brw-rw---- 1 oracle oinstall 253,  0 Oct 20 22:39 oravg-test_lv

 

 

 

 

 

11)            建立ORACLE表空間

SQL> create tablespace test datafile '/dev/mapper/oravg-test_lv';

 

Tablespace created.

 

SQL> select file_name,tablespace_name,bytes/1024/1024 MB from dba_data_files;

 

FILE_NAME                           TABLESPACE_NAME                        MB

----------------------------------- ------------------------------ ----------

/u01/oradata/oral/system01.dbf      SYSTEM                                700

/u01/oradata/oral/sysaux01.dbf      SYSAUX                                560

/u01/oradata/oral/undotbs01.dbf     UNDOTBS1                              890

/u01/oradata/oral/users01.dbf       USERS                                   5

/dev/mapper/oravg-test_lv           TEST                           511.992188

 

 

-- SQL> drop tablespace test;  --裸裝置上drop表空間,不需要帶including ... and ... ,否則會連裸裝置也刪除了

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26217983/viewspace-1123876/,如需轉載,請註明出處,否則將追究法律責任。

相關文章