最近需要dd備份磁盤,而服務器上沒有硬盤插槽了,nfs共享出來的目錄在dd出來以後只是一個文件,無法實現硬盤對拷的需求,所以只能使用iscsi共享的方式。
iscsi target (server):192.168.224.43
iscsi initiator(client):192.168.224.180
iscsi共享出來的lun需要是一個單獨的分區,不能像nfs一樣是一個目錄
服務器的操作:
[root@maomao43 ~]# yum install scsi-target-utils.x86_64 —安裝
[root@maomao43 ~]# service tgtd start —啓動tgtd服務
[root@maomao43 ~]# tgtadm –lld iscsi –op new –mode target –tid 1 -T iqn:2011-10.itianjing.com:test-3274893 —生成共享設備名稱
|
[root@maomao43 ~]# tgtadm –lld iscsi –op new –mode logicalunit –tid 1 –lun 1 -b /dev/sdc —劃分lun
-b 也可以指定爲一個文件:
|
[root@maomao43 ~]# tgtadm –lld iscsi –op bind –mode target –tid 1 -I ALL —-共享給所有主機
[root@maomao43 ~]# tgtadm –lld iscsi –op bind –mode target –tid 1 –initiator-address 192.168.224.180 —-指定共享給192.168.224.180
[root@maomao43 ~]# netstat -ntpl |grep :3260 —iscsi用到的防火牆端口
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 28854/tgtd
tcp 0 0 :::3260 :::* LISTEN 28854/tgtd
[root@maomao43 ~]# tgtadm –lld iscsi -o show -m target —–查看共享出來的設備
Target 1: iqn:2011-10.itianjing.com:test-3274893
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
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: None
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 146813 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: /dev/sdc1
Account information:
ACL information:
ALL