JavaScript must be enabled in order for you to see "WP Copy Data Protect" effect. However, it seems JavaScript is either disabled or not supported by your browser. To see full result of "WP Copy Data Protector", enable JavaScript by changing your browser options, then try again.

Setup the target of iSCSI under the RHEL 6.x/7.x

最近剛好碰到iSCSI功能上的驗證,不過在做該Function驗證之前,必須要在另一端Build一個iSCSI Target才能開始測試,所以此篇文章要來紀錄在RHEL下做iSCSI Target的架設,因為6.x與7.x所使用的套件不一樣,這邊會分成兩個部分來做介紹,如下所示:

I.RHEL 6.x

1) 確認是否已經裝了iSCSI Target的套件(如果沒裝,需要額外做補裝)
#rpm -qa | grep -i 'scsi-target-utils'

2) 建出50G的空檔案來做FileIO(這邊的Size可隨個人喜好做調整)
#mkdir -p /srv/iscsi
#dd if=/dev/zero of=/srv/iscsi/disk1.img bs=1M count=50000
#chcon -Rv -t thtd_var_lib_t /srv/iscsi/ -> 如有使用SELinux需執行該行

3) 編輯Tgtd服務的設定檔(/etc/tgt/targets.conf)
#vi /etc/tgt/targets.conf
backing-store /srv/iscsi/disk1.img
backing-store /dev/sdb1
# initator-address
# incominguser user passwd
# write-cache off

4) 啟動Tgtd的服務和Check Port已經Listen(TCP 3260)
#service tgtd start
#chkconfig tgtd on
#netstat -tunpl | grep -i tgtd
tcp 0 0* LISTEN 7953/tgtd
tcp 0 0 :::3260 :::* LISTEN 7953/tgtd
#tgt-admin --show
Target 1:
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 10486 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /srv/iscsi/disk1.img
Backing store flags:
Account information:
ACL information:
#iptables -L -> 如果Firewall沒關,可用Setup來做設定


5) 執行Targetcli開出Python Shell
/> iscsi/ info
Fabric module name: iscsi
ConfigFS path: /sys/kernel/config/target/iscsi
Allowed WWNs list type: iqn
Fabric module specfile: /var/target/fabric/iscsi.spec
Fabric module features: discovery_auth, acls, acls_auth, nps, tpgts
Corresponding kernel module: iscsi_target_mod

6) 建立出想要Storage的類型
/> cd backstores/
/backstore> iblock/ create name=rawdisk dev=/dev/sdb
/backstore> iblock/ create name=rawdisk_lvm lvm dev=/dev/vg0/lv1
/backstore> fileio/ create name=filedisk file_or_dev=/root/fileio size=2G
/backstore> rd_mcp/ create name=ramdiskN size=2GB
/backstore> ls -> Check所建出來的Backstores

7) Disable自動儲存功能
/> set global auto_cd_after_create=false
Parameter auto_cd_after_create is now 'false'.

8) 建出iSCSI Target的Name與Assign Lun
/> iscsi/ create
Created target
Selected TPG Tag 1.
Successfully created TPG 1.
Entering new node /iscsi/
/iscsi/iqn.20...a0e4a11/tpgt1 > luns/ create /backstores/fileio/filedisk
Selected LUN 0.
Successfully created LUN 0.
Entering new node /iscsi/

9) 加入Target的IP與Port
/iscsi/iqn.20...a0e4a11/tpgt1 > portals/ create
Using default IP port 3260
Successfully created network portal
Entering new node /iscsi/

10) 設定權限,這邊以完全不設限為例
/iscsi/iqn.20...a0e4a11/tpgt1 > set attribute authentication=0 demo_mode_write_protect=0
generate_node_acls=1 cache_dynamic_acls=1.
Parameter demo_mode_write_protect is now '0'.
Parameter authentication is now '0'.
Parameter generate_node_acls is now '1'.
Parameter cache_dynamic_acls is now '1'.
/> saveconfig

11) 下圖是在Intel Legacy OpRom iSCSI裡面的設定範例(SLES下的Initator可加withiscsi=1參數及Check是否有裝iscsi-client的套件)

12) 在iSCSI Initator下透過下列的Command來查詢iSCSI Target的資訊

◎、以上就是在RHEL下面Setup the target of iSCSI,至於SLES下面架設iSCSI Target可以直接執行yast2裡面的iSCSI Target做設定,如果各位看倌有任何疑問,可以自行查詢Tool的Help或參考這裡,先到這,收工!

  1. 你好,我现在的home_server是centos6.5,然后zfsonlinux,然后做了tgtd的target,现在有点想升级为centos7,不知道iol的性能比tgtd好多少?


    • 應該是有,因為可以各種的Backstore來Assign到iSCSI Target上,而且也可以直接裝LIO在CentOS 6.5上(Targetcli),你可以直接試看看.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This site is protected by WP-CopyRightPro