linux training in Thailand
| Home | Articles | Download | Free Linux Tips | Resources | Training | Web Link | Linux Training English|
| Courses | Schedule | Price & Promotion | Map | Customer Ref. | Instructors | Certification | FAQ | Registration Form |
ʶҺѹ 駻Դӡҧѹ 27 -31 áҤ 2558 Դӡûѹ 3 ԧҤ 2558
We are on vacations 5 days in July 27-31, 2015 Please contract Line ID : nok_fly or e-mail : info@itdestination.com
ITDestination лԴѺا䫵 ѹ 7 - 9 Զع¹ 2556
Ҩзҹ㹺ԡ Webboard Freetips E-Learning ֧㹤дǡ
ʶҺѹ 駻Դӡѹ 22-28 Ҿѹ 2560 ШԴӡûѹ 1 չҤ 2560
óյԴ觢ͤҷ Facebook: LinuxITDestination e-mail: info@itdestination.com 觨еԴ͡Ѻҳ 17.00 .
ŧ¹ͺöӢͺ online 㹪ǧͺͷǹ ӡѴӹǹ բ·١ͧй
ͺ´ 089 890-5494 >>> ҹ´...

ʹءѺ Network Block Device

ѷ ʵ,RHCE

͡Ƕ֧ԸաѺ͡èѴš¹ҧʵҹк͢ ·ѡй֧֡ԡþ鹰ҹͧٹԡҧ NFS Ҩ繺ԡâͧ͢Թҧ FTP ҡ͢·ѺкԺѵԡԹ礧˹鹡ⵤ SMB/CIFS ҡԨóǹ¡ѹ ҹԡк͢ҹеͧԡ (services) ءӧҹкԺѵԡչءա˹ ѡɳ Daemon ҡ ֧ǹ˹觢ͧкԺѵԡҧԧ ҧ ԡ NFS еͧ nfsd RPC port mapper ѹ ԡ FTP ͧ FTP Server ѹ ҡš¹ѺкԺѵԡԹͧѹ SAMBA Server ÷ͧ¹͡ҷӧҹкԺѵԡչء蹹ԴѾҡ ˹¤СûżŢͧҧҡ 件֧еͧաԴ¢鹵͹ͺͧ÷ӧҹ ¶֧ԷҾŴŧ繡ѧͧкԺѵԡ÷ ǤԴйкԡ͢ҷӧҹдѺ ٻẺͧŨ֧Դ


ٻ 1 ǹСͺͧк͢¢ͧ NBD

NBD : Network Block Device NBD Ţͧչء öҹ㹡ԡҹк͢ Ըա÷ӹͧǡѹѺèѴػóѴ红Ż Block Device 촴ʡҧ (/dev/hda ,/dev/sda) ˹¤ (/dev/ram0) §ػóͷѴ红Źʵҧ͡к͢ (Remote) ʵǡѹ (Local) çҧ÷ӧҹͧ NBD 鹨ŷӧҹԴѺŢͧչءҡش ѧ鹨֧դ٧ 㹡óշӧҹз˹ҷ繵ǡҧҧػóѴ红ŨԧѺԡ͡ѧк͢ TCP/IP (¡˹Ţ쵢ҧԧ) ǹ÷ӧҹ㹰ҹͧ١¹ NBD §ԡèҡŧٻͧ Block Device ˹ (/dev/nbd0) кԺѵԡý١öҵҹ͹繴ʡͧͧͧ ҡѴõԴǡѺա˹觡ѧҹ͹ءС ǹСͺͧ NBD 繴ѧٻ 1 ªСûءҹͧ NBD лҡ㹧ҹ» ҹǡѺͧ鹵Ȩҡʡ㹵ͧ (Diskless Clients) кѴ红͢ SAN (Storage Area Networks) 仨֧кżѹẺ (Cluster Computing) ෤ NBD ѧѲҵʹաç
ANBD (Another Network Block Device) ¡ʹѺʹع÷ӧҹẺ Multithreading ա駢ͤԴҴҧ 觢
ENBD (Enhanced Network Block Device) سѵԡѵѵ þ٨ԷԼҹ ʹѺʹعػó쪹Դ Removable
DNBD (Distributed Network Block Device) ¹ⵤŪԴ UDP 㹡Ѻ觢ʹѺʹع Multicast ᤪ㹽ͧ١ ÷ Server Redundancy
GNBD (Global Network Block Device) 繰ҹͧþѲ GFS (Global File System)
ŧͻԺѵԡѺ NBD
㹡÷ͺҹ NBD ¹ Fedora Core 5 ѡ 2.6.15 ҾѹʹѺʹعẺ¹͡ (LKM : Loadable Kernel Module) öǨͺѧ
  • ҡ locate nbd о nbd.ko nbd.h к
  • ҡ grep -i nbd /boot/config-2.6.15-1.2054_FC5 繢ͤ CONFIG_BLK_DEV_NBD = m
  • ͹ҹ֧ͧŴŹ¡͹¤ modprobe nbd
  • ǨͺŴŴ¤ lsmod | head
  • ԴͧʹѺʹع NBD
    ֧ҨʹѺʹع NBD ǡ 㹡ҹ鹨еͧͧʹѺʹعҹͧ User space tools ա硹¨֧öҹԧ ѧ鹨֧ͧբ鹵͹äеԴʹѺʹعѧ
  • ǹŴ鹩Ѻ nbd-2.8.8.tar.bz2 ҡ䫵 http://sourceforge.net/projects/nbd
  • ᵡ礷Դ (nbd-2.8.8) ä
  • /usr/include/linux/nbd.h
  • ͤ仹 nbd.h (еͧáͤ㹢ͺࢵͧٻẺͧҫ 㹷˹ͤ endif ) enum {
    NBD_CMD_READ = 0,
    NBD_CMD_WRITE = 1,
    NBD_CMD_DISC = 2
    };

  • ӡä еԴ ѧش觵仹 # ./configure
    # make
    # make install

  • Ѿ nbd-server /usr/local/bin nbd-client /usr/local/sbin ͡ҡ鹨͡ Man Page ҧ աӹǹ˹ ͨҡ仨öͧ觹㹡ҹ NBD
  • 鹵͹÷ͺҹ NBD
    кͧշʹѺʹعҹ ҹ NBD ͡ 2 ǹ NBD Server Ѻ NBD Client NBD Server зӡҧԪͺѹ֡Ţ ǿöѴ红 ҡ鹨֧ nbd-server ӡ Export ͺѹ֡Ź͡价ҧк͢ TCP Ţ쵷ö˹ͧ # mkdir /exports
    # dd if=/dev/zero of=/exports/network-media.img bs=1024 count=100000
    # mke2fs /exports/network-media.img
    ش觢ҧ繡ҧ좹Ҵҳ 102 MB ǿкẺ ext2 злҡӶ Continue anyway? (y/n) ͺ y # nbd-server 5000 /exports/network-media.img
    # netstat -lntp | grep nbd-server
    ͨҡѹ nbd-server ԡ÷ TCP/5000 Export кҧ͡к͢ ǹ͡Ѻ NBD Server nbd-client բ鹵͹ªҡ nbd.ko ѹ nbd-client ͺԡѧ NBD Server 쵷ԡ ǹҧԧªػó Block Device ͧ NBD /dev/nbd0 ҡ ҹ鹵ö Block Device ҹǡѺ Block Device ẺŤŸѹ ѧҧ仹 (öͺʵǡѹѺʵ˹ҷ NBD Server) # modprobe nbd
    # nbd-client 127.0.0.1 5000 /dev/nbd0
    # mkdir /mnt/net
    # mount /dev/nbd0 /mnt/net
    # ls -l /mnt/net
    # df -h
    # dd if=/dev/zero of=/mnt/net/test.dat count=8192 bs=1024
    # ls -l /mnt/net
    # df -h
    鹵͹ҧ繡Ŵ nbd ͹ҹ ҡ鹨֧͡Ѻ(ʵǡѹ) 5000 ҧԧ /dev/nbd0 Ƿӡҵҹ /mnt/net ·ͧҧ좹Ҵ 8MB ͷͺúѹ֡ ҡͧõѴ͡Ѻ NBD Server еͧӡ unmount ¡͹Ǩ֧ͻ -d disconnect ͡ # umount /mnt/net
    # nbd-client -d /dev/nbd0
    ҹ NBD Server ѺԹ硫
    ͡ҡöҹʵչء NBD Server ѧöʵԹ硾˹ҷ NBD Server ա ״㹡ҹ NBD ҡաҧ˹ ҧáҨеͧǹŴ NBD Server ҹдǡҡҵͧͧ öǹŴҡ http://www.vanheusden.com/windows/nbdsrvr/ պѴ nbdsrvr-0.2.zip ᵡ͡Ǩ nbdsrvr.exe C:\ 鹵͹ҹФ¡Ѻóշʵչء еͧҧ¡͹ 鹵͹ҧ Ӵѧ
  • Դ˹ҵҧẺҹŹͧ¾ cmd 㹡ͺ Run.. ҡ Start
  • C Prompt cd \ 价 Root Directory
  • echo 1 > image.dat
  • dir image.dat Ҵ 4 byte
  • ҧش觵仹Ҵͧ image.dat բҴ 16 MB
  • C:\> FOR /L %i IN (1,1,22) DO type image.dat >> image.dat
    image.dat ѧࡵѧк ͹ҧ㹡óբͧʵչء 㹢з㹴蹹ҡöпա ҧáö觿ѧ ѧҡʹ NBD 价ʵչء ѹ NBD Server ʵԹ硾 EXE ǹŴ Export ͡价ҧ TCP Ţ 5001 ѧ
    C:\> nbdsrvr image.dat 5001
    ҧʵչء Ҩö͡Ѻ NBD Server ԹǡѺзӡѺNBD Server ʵչء 㹨鹵͹㹡ÿ Network Block Device ͹ҹ (á§) բ鹵͹ҧѧ # modprobe nbd
    # nbd-client 192.168.100.200 5001 /dev/nbd1
    # mke2fs /dev/nbd1
    # tune2fs -j /dev/nbd1
    # mkdir /mnt/winbd
    # mount /dev/nbd1 /mnt/winbd
    # mount
    # ls -l /mnt/winbd
    # df -h
    # cp /usr/share/sounds/*.wav /mnt/winbd
    # ls -l /mnt/winbd
    # df -h
    # umount /mnt/winbd
    # nbd-client -d /dev/nbd1
    ҡ鹵͹ҧ繡ѧ NBD Server Ţ; 192.168.100.200 ʵԹ ҧԧ繴ǫ /dev/nbd1 ӡÿ ҵкҷ /mnt/winbd зͺ纷ҵµѧ ҡ鹨֧¡ԡõԴҹ繢鹵͹ش ɢͧ NBD
    Ըաҹ NBD Network Block Device ѹ仺ҧ ѧࡵѡɳФ¡Ѻҹ NFS ͹ҧҡ еҧѹçջԷҾ٧зӧҹҡдѺ ͡ҡѧ˹觷ҧ͡令 ҡ͢·ͧ١¨ӹǹҡö˹Ţ TCP ͧҨ¡觺ѹ֡ 觢͹حҵͧ١·ءͷѹ NBD 餹蹷Ңͧͧͷӡ Ѻͧͧ ֧դᵡҧҡԡ NFS ЪͧҹФդǢͧѹ Ѻ͡ѡɳ੾Тͧ NBD Ѵҡ мй NBD еͧ㹤سѵӤѭ