測試系統爲Redhat 5.4,內核版本爲2.6.18,iSCSI Server已經配置好,此處再也不說明。node
一、 安裝iSCSI Initiatorlinux
a) 使用命令mount /dev/cdrom /media掛載Redhat5.4安裝光盤到/media下。bash
b) 使用命令rpm --ivh /media/Server/iscsi-initiator-utils-6.2.0.871-0.7.el5.i386.rpm安裝iscsi Initiator。ide
c) 使用命令rpm --qa | grep iscsi確認系統中已經成功安裝了iscsi Initiator。而且在/etc下會產生iscsi文件夾,該文件夾下同時生成兩個文件initiatorname.iscsi、iscsid.conf。測試
d) 使用命令chkconfig --list查看iscsi、iscsid服務在運行級別三、5中是否屬於自動啓動狀態。(注意:若是不是能夠使用chkconfig --level將其設置爲自動啓動。ui
若是iscsid和iscsi沒有隨系統的啓動而啓動,則用chkconfig設置這兩個服務在系統運行級別爲3和5時隨系統啓動而啓動3d
# chkconfig iscsi --level 345 on # chkconfig iscsid --level 345 on
二、 執行Target發現。blog
a) 首先使用命令/etc/init.d/iscsid start啓動iscsi守護進程。進程
b) 用命令iscsiadm –m discovery –t sendtargets –p 192.168.1.92發現192.168.1.92上的iscsi資源。ci
c) 使用命令iscsiadm –m node查看已發現的全部iscsi資源(該步驟可選)
三、 設置Initiator Name。
a) 編輯/etc/iscsi/initiatorname.iscsi文件,將「InitiatorName=」後的內容改成以前發現的iscsi資源名,如圖:
b) 編輯/etc/iscsi/iscsid.conf文件,將「# isns.address = 192.168.0.1」前的「#」去掉,並將IP地址改成ISCSI Server的IP地址192.168.1.92。將「isns.port = 3205」前的「#」去掉並將端口號改成3260如圖:
四、 啓動iscsi服務,將經過iscsi掛載的磁盤分區格式化。
a) 使用命令/etc/init.d/iscsi start啓動iscsi服務,此時將會掛載iscsi設備,如圖。
b) 使用fdisk –l能夠查看到系統中多了一塊硬盤/dev/sdb,這即是經過iscsi掛載而來。
若是顯示 disk /dev/sdb doesn’t contain a vilid partition table
須要運行如下命令進行掛載
# fdisk /dev/sdf Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-1009, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-1009, default 1009): Using default value 1009 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.