在Linux上使用raw device方式
在Linux上使用raw device方式
在Linux上使用raw device一般有兩個方式,下面分別測試一下:
第一種方式是非lvm方式,直接使用partion方式如下:
一,建立分割槽
[root@localhost ~]# fdisk -l
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 514048+ 83 Linux
/dev/sda2 65 1174 8916075 83 Linux
/dev/sda3 1175 1435 2096482+ 82 Linux swap
/dev/sda4 1436 1566 1052257+ 5 Extended
/dev/sda5 1436 1566 1052226 83 Linux
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
[root@localhost oracle]# fdisk /dev/sdb
The number of cylinders for this disk is set to 1044.
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n p
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1): 65
Last cylinder or +size or +sizeM or +sizeK (65-1044, default 1044):
Using default value 1044
Command (m for help): p
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 65 1044 7871850 83 Linux
Command (m for help): p
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 65 1044 7871850 83 Linux
Command (m for help): h
h: unknown command
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): d
Selected partition 1
Command (m for help): p
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
1 p
Partition number (1-4): 1
First cylinder (1-1044, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): 65
Command (m for help): p
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 65 522081 83 Linux
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (66-1044, default 66):
Using default value 66
Last cylinder or +size or +sizeM or +sizeK (66-1044, default 1044): 130
Command (m for help): n
Command action
e extended
p primary partition (1-4)
3
Invalid partition number for type `3'
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (131-1044, default 131):
Using default value 131
Last cylinder or +size or +sizeM or +sizeK (131-1044, default 1044): 196
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Selected partition 4
First cylinder (197-1044, default 197): 4
Value out of range.
First cylinder (197-1044, default 197):
Using default value 197
Last cylinder or +size or +sizeM or +sizeK (197-1044, default 1044): 262
Command (m for help): p
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 65 522081 83 Linux
/dev/sdb2 66 130 522112+ 83 Linux
/dev/sdb3 131 196 530145 83 Linux
/dev/sdb4 197 262 530145 83 Linux
二,繫結raw device
[root@localhost oracle]# raw /dev/raw/raw1 /dev/sdb1
/dev/raw/raw1: bound to major 8, minor 18
[root@localhost oracle]# raw /dev/raw/raw2 /dev/sdb2
/dev/raw/raw2: bound to major 8, minor 18
[root@localhost oracle]# raw /dev/raw/raw3 /dev/sdb3
/dev/raw/raw3: bound to major 8, minor 18
[root@localhost oracle]# raw /dev/raw/raw4 /dev/sdb4
/dev/raw/raw4: bound to major 8, minor 18
[root@localhost oracle]#vi /etc/sysconfig/rawdevices
在檔案中加入如下內容:
/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdb2
/dev/raw/raw3 /dev/sdb4
/dev/raw/raw4 /dev/sdb4
另執行 /etc/init.d/rawdevices restart 使配置檔案中的裸裝置生效,執行 /sbin/chkconfig rawdevices on 保證機器啟動的時候裸裝置能夠載入。
三,授權
[root@localhost oracle]# chown -R oracle:dba /dev/raw/raw1
[root@localhost oracle]# chown -R oracle:dba /dev/raw/raw2
[root@localhost oracle]# chown -R oracle:dba /dev/raw/raw3
[root@localhost oracle]# chown -R oracle:dba /dev/raw/raw4
另修改配置檔案/etc/udev/permissions.d/50-udev.permissions
註釋掉raw/*:root:disk:0660,新增新行raw/*:oracle:dba:0660
此時,如繫結raw device,則預設許可權為oracle:dba了。
--另如需要可以進行相應連結,
如ln -s /dev/raw/raw1 /u1/oracle/oradata/test10g/test_raw1.dbf,然後可以直接為oracle所用了。
另一種是lvm的方式,測試如下:
一,建立pv
[root@localhost ~]# pvcreate -M2 --metadatasize 100M /dev/sdb7 /dev/sdb8 /dev/sdb9 /dev/sdb10 /dev/sdc
Physical volume "/dev/sdb7" successfully created
Physical volume "/dev/sdb8" successfully created
Physical volume "/dev/sdb9" successfully created
Physical volume "/dev/sdb10" successfully created
Physical volume "/dev/sdc" successfully created
[root@localhost ~]# lvmdiskscan
/dev/ramdisk [ 16.00 MB]
/dev/ram [ 16.00 MB]
/dev/sda1 [ 502.00 MB]
/dev/ram2 [ 16.00 MB]
/dev/root [ 8.50 GB]
/dev/ram3 [ 16.00 MB]
/dev/sda3 [ 2.00 GB]
/dev/ram4 [ 16.00 MB]
/dev/ram5 [ 16.00 MB]
/dev/sda5 [ 1.00 GB]
/dev/ram6 [ 16.00 MB]
/dev/ram7 [ 16.00 MB]
/dev/ram8 [ 16.00 MB]
/dev/ram9 [ 16.00 MB]
/dev/ram10 [ 16.00 MB]
/dev/ram11 [ 16.00 MB]
/dev/ram12 [ 16.00 MB]
/dev/ram13 [ 16.00 MB]
/dev/ram14 [ 16.00 MB]
/dev/ram15 [ 16.00 MB]
/dev/sdb1 [ 980.50 MB]
/dev/sdb2 [ 980.53 MB]
/dev/sdb3 [ 1.92 GB]
/dev/sdb5 [ 509.84 MB]
/dev/sdb6 [ 549.07 MB]
/dev/sdb7 [ 509.84 MB] LVM physical volume
/dev/sdb8 [ 509.84 MB] LVM physical volume
/dev/sdb9 [ 549.07 MB] LVM physical volume
/dev/sdb10 [ 627.51 MB] LVM physical volume
/dev/sdb11 [ 1011.88 MB]
/dev/sdc [ 8.00 GB] LVM physical volume
3 disks
23 partitions
1 LVM physical volume whole disk
4 LVM physical volumes
二,建立vg
[root@localhost ~]# vgcreate vg_db1 /dev/sdc -s 128m
Volume group "vg_db1" successfully created
[root@localhost ~]# vgcreate vg_db2 /dev/sdc -s 128m
Volume group "vg_db2" successfully created
三,建立lv
[root@localhost ~]# lvcreate -L 512m -I 64k vg_db2 -n lv_db2_02
Ignoring stripesize argument with single stripe
Logical volume "lv_db2_02" created
[root@localhost ~]# lvcreate -L 1024m -I 64k vg_db2 -n lv_db2_03
Ignoring stripesize argument with single stripe
Logical volume "lv_db2_03" created
[root@localhost ~]# lvcreate -L 512m -I 64k vg_db2 -n lv_db2_04
Ignoring stripesize argument with single stripe
Logical volume "lv_db2_04" created
[root@localhost ~]# lvcreate -L 2048m -I 64k vg_db2 -n lv_db2_05
Ignoring stripesize argument with single stripe
Logical volume "lv_db2_05" created
四,繫結
[root@localhost ~]# raw /dev/raw/raw1 /dev/mapper/vg_db2-lv_db2_01
/dev/raw/raw4: bound to major 253, minor 5
[root@localhost ~]# raw /dev/raw/raw2 /dev/mapper/vg_db2-lv_db2_02
/dev/raw/raw4: bound to major 253, minor 5
[root@localhost ~]# raw /dev/raw/raw3 /dev/mapper/vg_db2-lv_db2_03
/dev/raw/raw4: bound to major 253, minor 5
[root@localhost ~]# raw /dev/raw/raw4 /dev/mapper/vg_db2-lv_db2_04
/dev/raw/raw4: bound to major 253, minor 5
後面授權等作業和第一種方式類同,上面要注意的是lv的命名方式,命名方式分解如下:
/dev/mapper/+ vgname + '-' + lvname.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/670493/viewspace-1024916/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- redhat linux上不用dd清空raw device可以重複使用raw device嗎RedhatLinuxdev
- [Oracle] Raw device上Create TablespaceOracledev
- raw devicedev
- linux下如何使用raw device來建立管理asm diskLinuxdevASM
- raw device, first blockdevBloC
- about raw device[zt]dev
- Raw Device vs File Systemdev
- 建立raw device tablespace報Linux Error: 13: Permission denieddevLinuxError
- How to Choose Size of Datafile on Raw Devicedev
- 【轉】配置RAW Device磁碟組dev
- 如何遷移裸裝置raw device資料檔案到另一個raw devicedev
- 配置rhel4的raw device servicedev
- Red Hat Enterprise Linux AS 5.3 下配置裸裝置(raw device)Linuxdev
- Redhat 下raw device建庫介紹(ZT)Redhatdev
- random_device在windows上的實現randomdevWindows
- 在 Linux 上使用 MultitailLinuxAI
- 在 Linux 上使用 tarballLinux
- 在Linux上使用CANLinux
- ASM學習筆記_配置RAW Device磁碟組ASM筆記dev
- solaris 10_raw device_建立資料庫dev資料庫
- 【Raw Device】OEL4.8裸裝置對映方法dev
- 網友整理的一份Oracle10g RAC for all-version Linux -- raw deviceOracleLinuxdev
- 在 Linux 上使用 Window Maker 桌面Linux
- 在LINUX5.8上使用vncLinuxVNC
- Docker Desktop 現在可以在 Linux 上使用DockerLinux
- [Linux Device Driver] wifi adb 使用方法LinuxdevWiFi
- Linux Raw DevicesLinuxdev
- 在 Linux 上安裝和使用 DockerLinuxDocker
- 在 Linux 上使用 Ksnip 註釋截圖Linux
- 在linux上使用VNC遠端監控LinuxVNC
- 在ARM+LINUX上使用pppd拔號上網(GPRS)流程Linux
- 翻譯:Linux and the Device TreeLinuxdev
- 在Linux下使用ISDN撥號上網 (轉)Linux
- Oracle9i RAC (raw device) 自動開啟(rc.local) 設定Oracledev
- 以Raw的方式傳送POST請求
- 解決RAW在SQLPLUS上無法顯示的問題SQL
- linux下raw與基於lvm的raw的用法LinuxLVM
- 使用 xclip 在 Linux 命令列中複製貼上Linux命令列