centos6 10分钟快速搭建iscsi存储服务器

 

1、系统架构

 

 

2、安装软件

yum list | grep target

yum -y install scsi-target-utils.x86_64

 

3、修改配置文件

先准备一个硬盘进行分区 /dev/sdb1(这里省略)

 

vi /etc/tgt/targets.conf

16 default-driver iscsi

 

38 <target iqn.2017-05.com.qq:sdb1>

39 backing-store /dev/sdb1

40 initiator-address 192.168.60.0/24

41 </target>

 

 

说明,这里可以添加多个target

 

4、启动tgtd服务

/etc/init.d/tgtd start

 

5、查看iscsi设备

tgtadm --lld iscsi --op show --mode target

Target 1: iqn.2017-05.com.qq:sdb1

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: 10742 MB, Block size: 512

Online: Yes

Removable media: No

Prevent removal: No

Readonly: No

Backing store type: rdwr

Backing store path: /dev/sdb1

Backing store flags:

Account information:

ACL information:

192.168.60.0/24

 

6、客户端安装配置

rpm -ivh /mnt/Packages/iscsi-initiator-utils-6.2.0.873-2.el6.i686.rpm

warning: /mnt/Packages/iscsi-initiator-utils-6.2.0.873-2.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY

Preparing... ########################################### [100%]

1:iscsi-initiator-utils ########################################### [100%]

rpm -ivh /mnt/Packages/lsscsi-0.23-2.el6.i686.rpm

 

lsscsi 操作之前查看,只有3scsi设备

[2:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sda

[2:0:1:0] disk VMware, VMware Virtual S 1.0 /dev/sdb

[4:0:0:0] cd/dvd NECVMWar VMware SATA CD01 1.00 /dev/sr0

 

/etc/init.d/iscsi restart

停止 iscsi [确定]

正在启动 iscsi [确定]

 

发现并连接iscsi设备

iscsiadm -m discovery -t st -p 192.168.60.11

192.168.60.11:3260,1 iqn.2017-05.com.qq:sdb1

192.168.60.11:3260,1 iqn.2017-05.com.qq:vg1-lv1

 

iscsiadm -m node -T iqn.2017-05.com.qq:sdb1 --login

Logging in to [iface: default, target: iqn.2017-05.com.qq:sdb1, portal: 192.168.60.11,3260] (multiple)

Login to [iface: default, target: iqn.2017-05.com.qq:sdb1, portal: 192.168.60.11,3260] successful.

 

iscsiadm -m node -T iqn.2017-05.com.qq:sdb1 -u

Logging out of session [sid: 4, target: iqn.2017-05.com.qq:sdb1, portal: 192.168.60.11,3260]

Logout of [sid: 4, target: iqn.2017-05.com.qq:sdb1, portal: 192.168.60.11,3260] successful.

 

lsscsi

[2:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sda

[2:0:1:0] disk VMware, VMware Virtual S 1.0 /dev/sdb

[4:0:0:0] cd/dvd NECVMWar VMware SATA CD01 1.00 /dev/sr0

[37:0:0:1] disk IET VIRTUAL-DISK 0001 /dev/sdc

 

tree /var/lib/iscsi/nodes/

/var/lib/iscsi/nodes/

├── iqn.2017-05.com.qq:sdb1

   └── 192.168.60.11,3260,1

   └── default

└── iqn.2017-05.com.qq:vg1-lv1

└── 192.168.60.11,3260,1

└── default

 

4 directories, 2 files

 

fdisk /dev/sdc

partprobe /dev/sdc

mkfs -t ext4 /dev/sdc1

mount -t ext4 /dev/sdc1 /abc

uuid挂载

blkid /dev/sdc1

vi /etc/fstab

UUID=4b042691-a7e8-480d-bd0f-4c5fa409c1db /abc ext4 defaults,_netdev 0 0

chkconfig iscsi on

 

验证结果:

mount -a

[root@localhost ~]# df -h

文件系统     容量 已用 可用 已用%% 挂载点

/dev/mapper/VolGroup-lv_root

50G 4.7G 43G 10% /

tmpfs 250M 72K 250M 1% /dev/shm

/dev/sda1 485M 32M 428M 7% /boot

/dev/mapper/VolGroup-lv_home

28G 172M 26G 1% /home

/dev/sdc1 1008M 34M 924M 4% /abc

 

posted @ 2017-05-03 11:33  二勇的技术博客  阅读(6906)  评论(0编辑  收藏  举报