Linux RAW DEVICE 裸设备

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:30

在学rac的时候,发现这个东西,找了些资料放在这。
-----------------------------------------------------------
在linux上使用raw device一般有两个方式,下面分别测试一下:
第一种方式是非lvm方式,直接使用partion方式如下:
一,创建分区[root@localhost ~]#fdisk -l
Disk /dev/sda: 12.8GB, 12884901888 bytes255 heads, 63sectors/track, 1566 cylindersUnits = cylinders of16065 * 512 = 8225280 bytes
Device Boot StartEnd Blocks Id System/dev/sda1 * 1 64514048+ 83 Linux/dev/sda2 65 11748916075 83 Linux/dev/sda3 1175 14352096482+ 82 Linux swap/dev/sda4 1436 15661052257+ 5 Extended/dev/sda5 1436 15661052226 83 Linux
Disk /dev/sdb: 8589MB, 8589934592 bytes255 heads, 63sectors/track, 1044 cylindersUnits = cylinders of16065 * 512 = 8225280 bytes
Disk/dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 8589MB, 8589934592 bytes255 heads, 63sectors/track, 1044 cylindersUnits = cylinders of16065 * 512 = 8225280 bytes
Disk /dev/sdcdoesn't contain a valid partition table[root@localhostoracle]# fdisk /dev/sdb

The number ofcylinders for this disk is set to 1044.There is nothingwrong with that, but this is larger than 1024,and could in certainsetups cause problems with:1) software thatruns at boot time (e.g., old versions of LILO)2) booting andpartitioning software from other OSs(e.g., DOS FDISK,OS/2 FDISK)Warning: invalidflag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m forhelp): mCommand actiona toggle a bootableflagb edit bsd disklabelc toggle the doscompatibility flagd delete a partitionl list knownpartition typesm print this menun add a newpartitiono create a new emptyDOS partition tablep print thepartition tableq quit withoutsaving changess create a new emptySun disklabelt change apartition's system idu changedisplay/entry unitsv verify thepartition tablew write table todisk and exitx extrafunctionality (experts only)
Command (m forhelp): n p
Disk /dev/sdb: 8589MB, 8589934592 bytes255 heads, 63sectors/track, 1044 cylindersUnits = cylinders of16065 * 512 = 8225280 bytes
Device Boot StartEnd Blocks Id System
Command (m forhelp): nCommand actione extendedp primary partition(1-4)pPartition number(1-4): 1First cylinder(1-1044, default 1): 65Last cylinder or+size or +sizeM or +sizeK (65-1044, default 1044):Using default value1044
Command (m forhelp): p
Disk /dev/sdb: 8589MB, 8589934592 bytes255 heads, 63sectors/track, 1044 cylindersUnits = cylinders of16065 * 512 = 8225280 bytes
Device Boot StartEnd Blocks Id System/dev/sdb1 65 10447871850 83 Linux
Command (m forhelp): p
Disk /dev/sdb: 8589MB, 8589934592 bytes255 heads, 63sectors/track, 1044 cylindersUnits = cylinders of16065 * 512 = 8225280 bytes
Device Boot StartEnd Blocks Id System/dev/sdb1 65 10447871850 83 Linux
Command (m forhelp): hh: unknown commandCommand actiona toggle a bootableflagb edit bsd disklabelc toggle the doscompatibility flagd delete a partitionl list knownpartition typesm print this menun add a newpartitiono create a new emptyDOS partition tablep print thepartition tableq quit withoutsaving changess create a new emptySun disklabelt change apartition's system idu changedisplay/entry unitsv verify thepartition tablew write table todisk and exitx extrafunctionality (experts only)
Command (m forhelp): dSelected partition 1
Command (m forhelp): p
Disk /dev/sdb: 8589MB, 8589934592 bytes255 heads, 63sectors/track, 1044 cylindersUnits = cylinders of16065 * 512 = 8225280 bytes
Device Boot StartEnd Blocks Id System
Command (m forhelp): nCommand actione extendedp primary partition(1-4)1 pPartition number(1-4): 1First cylinder(1-1044, default 1): 1Last cylinder or+size or +sizeM or +sizeK (1-1044, default 1044): 65
Command (m forhelp): p
Disk /dev/sdb: 8589MB, 8589934592 bytes255 heads, 63sectors/track, 1044 cylindersUnits = cylinders of16065 * 512 = 8225280 bytes
Device Boot StartEnd Blocks Id System/dev/sdb1 1 65522081 83 Linux
Command (m forhelp): nCommand actione extendedp primary partition(1-4)pPartition number(1-4): 2First cylinder(66-1044, default 66):Using default value66Last cylinder or+size or +sizeM or +sizeK (66-1044, default 1044): 130
Command (m forhelp): nCommand actione extendedp primary partition(1-4)3Invalid partitionnumber for type `3'Command actione extendedp primary partition(1-4)pPartition number(1-4): 3First cylinder(131-1044, default 131):Using default value131Last cylinder or+size or +sizeM or +sizeK (131-1044, default 1044): 196
Command (m forhelp): nCommand actione extendedp primary partition(1-4)pSelected partition 4First cylinder(197-1044, default 197): 4Value out of range.First cylinder(197-1044, default 197):Using default value197Last cylinder or+size or +sizeM or +sizeK (197-1044, default 1044): 262
Command (m forhelp): p
Disk /dev/sdb: 8589MB, 8589934592 bytes255 heads, 63sectors/track, 1044 cylindersUnits = cylinders of16065 * 512 = 8225280 bytes
Device Boot StartEnd Blocks Id System/dev/sdb1 1 65522081 83 Linux/dev/sdb2 66 130522112+ 83 Linux/dev/sdb3 131 196530145 83 Linux/dev/sdb4 197 262530145 83 Linux
二,绑定raw device[root@localhostoracle]# raw /dev/raw/raw1 /dev/sdb1/dev/raw/raw1: boundto major 8, minor 18[root@localhostoracle]# raw /dev/raw/raw2 /dev/sdb2/dev/raw/raw2: boundto major 8, minor 18[root@localhostoracle]# raw /dev/raw/raw3 /dev/sdb3/dev/raw/raw3: boundto major 8, minor 18[root@localhostoracle]# raw /dev/raw/raw4 /dev/sdb4/dev/raw/raw4: boundto major 8, minor 18[root@localhostoracle]#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@localhostoracle]# chown -R oracle:dba /dev/raw/raw1[root@localhostoracle]# chown -R oracle:dba /dev/raw/raw2[root@localhostoracle]# chown -R oracle:dba /dev/raw/raw3[root@localhostoracle]# 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/sdcPhysical volume"/dev/sdb7" successfully createdPhysical volume"/dev/sdb8" successfully createdPhysical volume"/dev/sdb9" successfully createdPhysical volume"/dev/sdb10" successfully createdPhysical volume"/dev/sdc" successfully created[root@localhost ~]#lvmdiskscan/dev/ramdisk [ 16.00MB]/dev/ram [ 16.00 MB]/dev/sda1 [ 502.00MB]/dev/ram2 [ 16.00MB]/dev/root [ 8.50 GB]/dev/ram3 [ 16.00MB]/dev/sda3 [ 2.00 GB]/dev/ram4 [ 16.00MB]/dev/ram5 [ 16.00MB]/dev/sda5 [ 1.00 GB]/dev/ram6 [ 16.00MB]/dev/ram7 [ 16.00MB]/dev/ram8 [ 16.00MB]/dev/ram9 [ 16.00MB]/dev/ram10 [ 16.00MB]/dev/ram11 [ 16.00MB]/dev/ram12 [ 16.00MB]/dev/ram13 [ 16.00MB]/dev/ram14 [ 16.00MB]/dev/ram15 [ 16.00MB]/dev/sdb1 [ 980.50MB]/dev/sdb2 [ 980.53MB]/dev/sdb3 [ 1.92 GB]/dev/sdb5 [ 509.84MB]/dev/sdb6 [ 549.07MB]/dev/sdb7 [ 509.84MB] LVM physical volume/dev/sdb8 [ 509.84MB] LVM physical volume/dev/sdb9 [ 549.07MB] LVM physical volume/dev/sdb10 [ 627.51MB] LVM physical volume/dev/sdb11 [ 1011.88MB]/dev/sdc [ 8.00 GB]LVM physical volume3 disks23 partitions1 LVM physicalvolume whole disk4 LVM physicalvolumes
二,创建vg[root@localhost ~]#vgcreate vg_db1 /dev/sdc -s 128mVolume group"vg_db1" successfully created[root@localhost ~]#vgcreate vg_db2 /dev/sdc -s 128mVolume group"vg_db2" successfully created
三,创建lv[root@localhost ~]#lvcreate -L 512m -I 64k vg_db2 -n lv_db2_02Ignoring stripesizeargument with single stripeLogical volume"lv_db2_02" created[root@localhost ~]#lvcreate -L 1024m -I 64k vg_db2 -n lv_db2_03Ignoring stripesizeargument with single stripeLogical volume"lv_db2_03" created[root@localhost ~]#lvcreate -L 512m -I 64k vg_db2 -n lv_db2_04Ignoring stripesizeargument with single stripeLogical volume"lv_db2_04" created[root@localhost ~]#lvcreate -L 2048m -I 64k vg_db2 -n lv_db2_05Ignoring stripesizeargument with single stripeLogical volume"lv_db2_05" created
四,绑定[root@localhost ~]# raw /dev/raw/raw1/dev/mapper/vg_db2-lv_db2_01/dev/raw/raw4: boundto major 253, minor 5[root@localhost ~]# raw /dev/raw/raw2/dev/mapper/vg_db2-lv_db2_02/dev/raw/raw4: boundto major 253, minor 5[root@localhost ~]# raw /dev/raw/raw3/dev/mapper/vg_db2-lv_db2_03/dev/raw/raw4: boundto major 253, minor 5[root@localhost ~]# raw /dev/raw/raw4/dev/mapper/vg_db2-lv_db2_04/dev/raw/raw4: boundto major 253, minor 5后面授权等作业和第一种方式类同,上面要注意的是lv的命名方式,命名方式分解如下:/dev/mapper/+ vgname+ '-' + lvname.

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】