1.裸設(shè)備:
未分區(qū)的硬盤(獨立的),未被格式化的分區(qū)(包括主分區(qū)和邏輯分區(qū))
2.測試,創(chuàng)建裸設(shè)備
-bash-3.00# fdisk -l
Disk /dev/sda: 160.0 GB, 160000000000 bytes
255 heads, 63 sectors/track, 19452 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 7662 61440592+ 83 Linux
/dev/sda3 7663 14036 51199155 83 Linux
/dev/sda4 14037 19452 43504020 5 Extended
/dev/sda5 14037 14673 5116671 83 Linux
/dev/sda6 14674 15310 5116671 83 Linux
/dev/sda7 15311 15947 5116671 83 Linux
/dev/sda8 15948 16339 3148708+ 83 Linux
/dev/sda9 16340 16466 1020096 83 Linux
/dev/sda10 16467 19016 20482843+ 83 Linux
/dev/sda11 19017 19079 506016 83 Linux
/dev/sda12 19080 19141 497983+ 83 Linux
-bash-3.00# fdisk /dev/sda
The number of cylinders for this disk is set to 19452.
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)
Command (m for help): n
First cylinder (19142-19452, default 19142):
Using default value 19142
Last cylinder or +size or +sizeM or +sizeK (19142-19452, default 19452): +512M
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
-bash-3.00# reboot
Broadcast message from root (pts/2) (Sun Nov 2 21:54:12 2008):
The system is going down for reboot NOW!
-bash-3.00# raw /dev/raw/raw3 /dev/sda13
/dev/raw/raw3: bound to major 8, minor 13
3.修改屬主和權(quán)限
-bash-3.00# chown oracle10:oracle10 /dev/raw/raw3
-bash-3.00# chmod 777 /dev/raw/raw3
-bash-3.00# ls -l /dev/raw/raw3
crwxrwxrwx 1 oracle10 oracle10 162, 3 Nov 2 21:59 /dev/raw/raw3
4.oracle添加裸設(shè)備為數(shù)據(jù)文件(或redo log)
SQL> alter tablespace space_test add datafile '/dev/raw/raw3' size 400M;
Tablespace altered.
SQL> select name from v$datafile;
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
/work/oracle10/oracle/oradata/oracle10/system01.dbf
/work/oracle10/oracle/oradata/oracle10/space_test.dbf
/work/oracle10/oracle/oradata/oracle10/sysaux01.dbf
/work/oracle10/oracle/oradata/oracle10/users01.dbf
/work/oracle10/oracle/oradata/oracle10/example01.dbf
/work/oracle10/oracle/oradata/oracle10/dsgtest_part.dbf
/work/oracle10/oracle/oradata/oracle10/dsgtest_part_01.dbf
/work/oracle10/oracle/oradata/oracle10/undotbs02.db
/dev/raw/raw3
9 rows selected.
SQL>
證明裸設(shè)備和文件系統(tǒng)可以共存。
日志文件同理也可以創(chuàng)建,同時可以創(chuàng)建這樣形式的裸設(shè)備日志文件
SQL> select member from v$logfile;
MEMBER
------------------------------------------------------------------------------------------------------------------------------------------------------
/work/oracle10/oracle/oradata/oracle10/redo03.log
/work/oracle10/oracle/oradata/oracle10/redo02.log
/work/oracle10/oracle/oradata/oracle10/redo01.log
/work/oracle10/oracle/oradata/oracle10/redo04
SQL> !ls -l /work/oracle10/oracle/oradata/oracle10/redo04
lrwxrwxrwx 1 root root 13 Nov 2 18:43 /work/oracle10/oracle/oradata/oracle10/redo04 -> /dev/raw/raw1
4.插曲:
1.reboot之后發(fā)現(xiàn)找不到/dev/raw/raw3,修改/etc/sysconfig/rawdevices
添加:
# Applications needing raw device access should open regular
# block devices with O_DIRECT.
# raw device bindings
# format: <rawdev> <major> <minor>
# <rawdev> <blockdev>
# example: /dev/raw/raw1 /dev/sda1
# /dev/raw/raw2 8 5
/dev/raw/raw3 /dev/sda13
2.reboot之后提示找不到剛創(chuàng)建的裸設(shè)備形式的數(shù)據(jù)文件,查看裸設(shè)備掛載的塊設(shè)備,發(fā)現(xiàn)權(quán)限被改成root,修改成oracle10:oracle10之后,數(shù)據(jù)庫就可以open了
vi /etc/udev/permissions.d/50-udev.permissions
# raw devices
ram*:root:disk:0660
raw/*:oracle10:oracle10:0777
再重啟,權(quán)限就沒問題了
5.思考
查資料發(fā)現(xiàn)linux的裸設(shè)備需要指到一個塊設(shè)備上(/dev/raw/raw*),而unix并不需要這一步
裸設(shè)備是一種字符設(shè)備(character device),不需要操作系統(tǒng)緩沖就可以直接讀寫,可以提高效率
另一種是塊設(shè)備(block device),需要操作系統(tǒng)緩沖,可以mount文件系統(tǒng)
ls -l /dev/sd*
brw-rw---- 1 root disk 8, 11 Nov 3 2008 /dev/sda11
brw-rw---- 1 root disk 8, 12 Nov 3 2008 /dev/sda12
brw-rw---- 1 root disk 8, 13 Nov 3 2008 /dev/sda13
[oracle10@rhel4 dev]$ ls -l /dev/raw/*
crwxrwxrwx 1 oracle10 oracle10 162, 1 Nov 2 22:31 /dev/raw/raw1
crwxrwxrwx 1 oracle10 oracle10 162, 3 Nov 2 22:31 /dev/raw/raw3
我的理解是,linux本身把為未格式化的分區(qū)當(dāng)作塊設(shè)備,然后通過連接(raw /dev/raw/raw3 /dev/sda13),當(dāng)成c設(shè)備來用,而unix不需要這一步,直接就是字符設(shè)備,這個不確定~