Ò»¡¢¹ØÓÚÂãÉ豸
1.1 ʲôÊÇÂãÉ豸(RAW DEVICE)
ÂãÉ豸ÊÇָδ´´½¨ÎļþϵͳµÄ´ÅÅÌ·ÖÇø(raw partition)»òÂß¼¾í(raw logical volume)£¬Ó¦ÓóÌÐòÖ±½Óͨ¹ýÒ»
¸ö×Ö·ûÉ豸Çý¶¯³ÌÐò¶ÔËü½øÐзÃÎÊ¡£ÈçºÎ¶ÔÉ豸ÉϵÄÊý¾Ý¶Áд¾ö¶¨ÓÚʹÓÃËüµÄÓ¦ÓóÌÐò¡£ÓÉÓÚ¶ÔÂãÉ豸µÄ²Ù×÷²»Í¨¹ýUNIXµÄ»º³åÇø£¬Êý¾ÝÔÚORACLEµÄÊý¾Ý»º³åÇø(BUFFER CACHE)ºÍ´ÅÅÌÖ®¼äÖ±½Ó´«µÝ£¬ËùÒÔʹÓÃÂãÉ豸ÔÚÒ»¶¨³Ì¶ÈÉÏÄܹ»Ìá¸ßI/OÐÔÄÜ£¬ÊʺÏI/OÁ¿´óµÄϵͳ¡£ÁíÍâOPS/RAC (Oracle Parallel Server/Real Application Cluster)»·¾³Ï£¬¶à¸ö½Úµãͬʱ·ÃÎÊͬһ¸öÊý¾Ý¿â£¬ËùÒÔCONTROL FILE¡¢DATA FILE¡¢REDO LOG¶¼±ØÐ뽨ÔÚRAW DEVICEÉÏ¡£
1.2 ÂãÉ豸µÄ¿ÉÓÿռä
²»Í¬µÄUNIX¶ÔÂãÉ豸µÄ¹ÜÀí²»ÍêÈ«Ïàͬ£¬ÌرðҪעÒâµÄÊÇijЩUNIXÔÚÿ¸öÂãÉ豸µÄÍ·²¿Òª±£ÁôÒ»¶¨µÄ¿Õ¼ä£¬Ó¦ÓóÌÐòÔÚʹÓÃÂãÉ豸ʱ²»¿ÉÒÔ¸²¸ÇÕâÒ»²¿·Ö£¬·ñÔò»á¶ÔÂãÉ豸Ôì³ÉË𻵡£ËùÒÔÒ»¸öÂãÉ豸µÄʵ¼Ê¿ÉÓÿռäÊÇ·ÖÅä¸øÂãÉ豸µÄ¿Õ¼äÔÙ¼õÈ¥Õⲿ·Ö²Ù×÷ϵͳ±£Áô¿Õ¼ä¡£ÏÂÃæÊdz£ÓÃUNIXµÄOS Reserved SizeÁÐ±í£º[code]UNIX¡¡¡¡¡¡¡¡¡¡OS Reserved Size
------------¡¡----------------
SUN Solaris¡¡¡¡¡¡¡¡¡¡¡¡¡¡0
HP-UX¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡0
IBM AIX¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡4k
Tru64 UNIX¡¡¡¡¡¡¡¡¡¡¡¡¡¡64k
Linux¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡0[/code]1.3 ddÃüÁî
UNIXÉ϶ÁдÂãÉ豸²»ÄÜʹÓÃcp, cpio, tarµÈÃüÁ±ØÐëÓÃdd£¬ÏÂÃæÊǼ¸¸ödd³£ÓòÎÊýµÄ¼òµ¥ËµÃ÷£¬¸üÏêϸµÄÐÅÏ¢Çë²Î¿¼UNIXʹÓÃÊÖ²á»òÓÃÃüÁîman dd¡£
dd [ operand=value ... ]
if=file Ö¸¶¨ÊäÈëÎļþ£¬È±Ê¡ÖµÊDZê×¼ÊäÈë
of=file Ö¸¶¨Êä³öÎļþ£¬È±Ê¡ÖµÊDZê×¼Êä³ö
bs=n ÉèÖÃÊäÈëºÍÊä³öµÄ¿é´óСΪn×Ö½Ú£¬Ò²¿ÉÒÔÓá°k¡±×÷µ¥Î»
skip=n ÔÚ¿½±´Ö®Ç°Ìø¹ýn¸öÊäÈë¿é£¬È±Ê¡ÖµÊÇ0
seek=n ÔÚ¿½±´Ö®Ç°´ÓÊä³öÎļþÊײ¿Ìø¹ýn¿é£¬È±Ê¡ÖµÊÇ0
count=n Ö¸¶¨¿½±´µÄ¿éÊý£¬È±Ê¡¿½±´µ½ÊäÈëÎļþ½áÊø
1.4 ¶Ô±¾ÎÄÖÐʾÀýµÄ˵Ã÷
a. ËùÓÐÀý×ÓÖÐORACLEµÄDB_BLOCK_SIZE¶¼ÊÇ8k
b. /oradataÊÇÒ»ÎļþϵͳĿ¼
c. /dev/rlv_data£¬/dev/rlv_redoºÍ/dev/rlv_ctrlÊÇÈý¸öRAW DEVICE£¬´óС¾ùΪ8MB(8192k)
d. ÔÚδÌáµ½²Ù×÷ϵͳʱ£¬Ä¬ÈÏÊÇAIX£¬OS_RESERVED_SIZE=4K
¶þ¡¢Òƶ¯Êý¾ÝÎļþ(DATAFILE)
2.1 ÔÚÂãÉ豸ÉϽ¨Á¢Êý¾ÝÎļþ
ÓÃÒÔÏÂÃüÁÁ¢±í¿Õ¼ä£º[code]SQL> CREATE TABLESPACE ts_test DATAFILE '/dev/rlv_data' SIZE 8180k;[/code]SIZEÖ¸¶¨µÄÊýÖµ±ØÐëСÓÚ»òµÈÓÚ8180k£¬·ñÔòÓï¾ä½«»áʧ°Ü£º[code]ORA-01119: error in creating database file '/dev/rlv_data'
ORA-27042: not enough space on raw partition to fullfill request[/code]Õâ¸ö×î´óÖµµÄ¼ÆËã·½·¨ÈçÏ£º[code]8192k(RAW DEVICE SIZE) - 4k (OS_RESERVED_SIZE) - 8k (DB_BLOCK_SIZE) = 8180k[/code]Ϊʲô»¹Òª¼õÈ¥Ò»¸öDB_BLOCK_SIZEÄØ£¿ÕâÊÇÒòΪORACLE½¨Á¢DATAFILEʱ£¬ÔÚÃüÁîÖÐSIZEÖ¸¶¨µÄ´óС֮Í⣬»¹ÒªÔÚÎļþÍ·Áí¼ÓÒ»¸öBLOCK£¬½Ð×÷¡°Oracle OS Header Block¡±£¬ÀïÃæ±£´æÓÐÕâ¸öÎļþµÄÂß¼¿é´óСºÍÎļþ¿éÊýµÈÐÅÏ¢¡£ÕâÒ»µã²¢²»ÊÇÔÚRAW DEVICEÉϽ¨DATAFILEÌØÓеģ¬Èç¹ûÄãÔÚÎļþϵͳÉϽ¨Ò»¸öDATAFILE£¬Ö¸¶¨SIZE 1000kµÄ»°£¬ÄãÓÃls -l»òdirÃüÁî¿´µ½µÄÎļþ´óС½«ÊÇ1008k (DB_BLOCK_SIZE=8K)¡£
2.2 ÔÚÎļþϵͳºÍÂãÉ豸֮¼äÒƶ¯Êý¾ÝÎļþ
2.2.1 ´ÓÎļþϵͳµ½ÂãÉ豸
a. ÔÚÎļþϵͳÉϽ¨Ò»¸ö4MµÄDATAFILE[code]SQL> CREATE TABLESPACE test DATAFILE '/oradata/test.dbf' SIZE 4M;[/code]b. ²é¿´Ò»ÏÂÕâ¸öн¨µÄDATAFILEµÄ´óС (×¢£º4202496 = 4M + 8K)[code]$ ls -l /oradata/test.dbf
-rw-r----- 1 oracle dba 4202496 Aug 29 15:01 /oradata/test.dbf[/code]c. °´ÏÂ±í¹«Ê½È·¶¨ddµÄ²ÎÊý
d. ÔÚÊý¾Ý¿âûÓÐOPENµÄ״̬Ï£¬ÓÃdd½øÐп½±´£¬ÏÂÃæ¸ø³öÃüÁî¼°Êä³ö[code]AIX$ dd if=/oradata/test.dbf of=/dev/rlv_data bs=4k seek=1
1026+0 records in
1026+0 records out
Tru64$ dd if=/oradata/test.dbf of=/dev/rlv_data bs=64k seek=1
64+1 records in
64+1 records out
Other$ dd if=/oradata/test.dbf of=/dev/rlv_data bs=1024k
4+1 records in
4+1 records out[/code]2.2.2 ´ÓÂãÉ豸µ½Îļþϵͳ
a. È·¶¨Êý¾ÝÎļþʵ¼Ê´óСfile_size£¬ÓÃÓÚÏÂÒ»²½¼ÆËãddµÄ²ÎÊýcount¡£Èç¹ûcount¼ÆËã²»¶Ô£¬¿½±´³öµÄÊý¾ÝÎļþÎÞЧ£¬Êý¾Ý¿âÎÞ·¨´ò¿ª¡£[code]SQL> SELECT bytes, blocks, bytes/blocks db_block_size, bytes+bytes/blocks file_size
FROM dba_data_files WHERE file_name='/dev/rlv_data';
BYTES¡¡¡¡¡¡BLOCKS¡¡¡¡DB_BLOCK_SIZE¡¡FILE_SIZE
---------- -------- ------------- ---------
4194304¡¡¡¡512¡¡¡¡¡¡¡¡8192¡¡¡¡¡¡¡¡¡¡4202496[/code]b. °´ÏÂ±í¹«Ê½È·¶¨ddµÄ²ÎÊý£¬min±íʾ¶þÕßÖ®ÖÐÈ¡½ÏСµÄ
c. ÔÚÊý¾Ý¿âûÓÐOPENµÄ״̬Ï£¬ÓÃdd½øÐп½±´£¬ÏÂÃæ¸ø³öÃüÁî¼°Êä³ö[code]AIX$ dd if=/dev/rlv_data of=/oradata/test2.dbf bs=4k skip=1 count=1026
1026+0 records in
1026+0 records out
Tru64$ dd if=/dev/rlv_data of=/oradata/test2.dbf bs=8k skip=8 count=513
513+0 records in
513+0 records out
Other$ dd if=/dev/rlv_data of=/oradata/test2.dbf bs=8k count=513
513+0 records in
513+0 records out[/code]2.2.3 ÎÞÂÛ´ÓFILE SYSTEM¿½±´µ½RAW DEVICE»¹ÊÇ·´Ö®£¬ÏëÈÃORACLEÒÔеÄÊý¾ÝÎļþ´ò¿ªÊý¾Ý¿â£¬±ØÐë½øÐÐRENAME²Ù×÷[code]SQL> STARTUP MOUNT;
SQL> ALTER DATABASE RENAME FILE 'oldfilename' TO 'newfilename';
SQL> ALTER DATABASE OPEN;[/code]