思路:全部用vmware workstation 来模拟,
共享存储服务器share_server和访问客户端client1,client2都是RHEL 6.3
share_server上增加一个独立的硬盘,并分区/dev/sdb1,作为共享存储用。
配置存储服务器端 (iSCSI Target),安装scsi-target-utils相关软件包,创建要输出的存储Target(启动tgt服务,创建target,划分lun)
target端步骤:
1.在share_server虚拟机上增加磁盘,不要在fstab中指定mount点。
2. 安装target端软件
yum install scsi-target-utils -y
3.启动tgtd
service tgtd start
4.设置tgtd服务开机启动
chkconfig tgdtd on
5.定义一个target 设置iqn和tid
tgtadm --lld iscsi --op new --mode target --tid 1 --targetname iqn.2012-11.com.test.www:target1
6.检查
tgtadm --lld iscsi --op show --mode target
7.分配LUN
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 --backing-store /dev/sdb1
8.保存配置,下次开机自动就有了LUN和target
vi tgt/targets.conf (注意ALL要大写,不限制访问地址)
<target iqn.2012-11.com.test.www:target1>
backing-store /dev/sdb1
initiator-address ALL
</target>
9. 查看LUN
tgtadm --lld iscsi --op show --mode target
client端步骤
1.yum install iscsi-initiator-utils -y
2.service iscsi start (/etc/init.d/iscsi start,
3.chkconfig iscsi on
4.service iscsi status
5。
- 侦测target
- $ iscsiadm -m discovery -t sendtargets -p 10.0.100.99
- 10.0.100.99:3260,1 iqn.2012-04.com.test:server.target1
-
- $ ll -R /var/lib/iscsi/nodes/
6.
- 査看可用的target
- $ iscsiadm -m node
7、
- 载入target
- $ iscsiadm -m node -T iqn.2012-04.com.test:server.target1 --login
8. fdisk -l
在vmware workstation虚拟机中增加磁盘。两种方法,方法1要重启,方法2不重启。
1.Adding a new disk to a VMWare Virtual Machine in Linux
参见:http://www.matttopper.com/2006/05/adding-a-new-disk-to-a-vmware-virtual-machine-in-linux/
2.http://www.cyberciti.biz/tips/vmware-add-a-new-hard-disk-without-rebooting-guest.html
要用到的工具:
1.分区软件fdisk
2.查看文件系统类型,使用blkid命令加上设备名就可以获取该设备的所有信息:
[root@rhel_ha ~]# blkid
/dev/sda3: UUID="5f759db8-ef80-4851-a4ba-227899f3d0c8" TYPE="ext4"
/dev/sda1: UUID="a3d2aaab-9ab4-4c75-9819-883e06bdcbba" TYPE="ext4"
/dev/sda2: UUID="5574e3a6-bd33-4404-87cd-6334d211e538" TYPE="swap"
3.格式化分区
[root@rhel_ha ~]# mkfs -V -t ext4 /dev/sdb1
mkfs (util-linux-ng 2.17.2)
mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
4.tune2fs
(调整/查看ext2/ext3文件系统的文件系统参数,Windows下面如果出现意外断电死机情况,下次开机一般都会出现系统自检。Linux系统下面也有文件系统自检,而且是可以通过tune2fs命令,自行定义自检周期及方式。)
[root@rhel_ha ~]# tune2fs -l /dev/sdb1
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name: <none>
Last mounted on: <not available>
Filesystem UUID: 0973912f-ea9f-412e-ab82-f472d9f5d888
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 1310720
Block count: 5241198
Reserved block count: 262059
Free blocks: 5114909
Free inodes: 1310709
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 1022
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
Flex block group size: 16
Filesystem created: Wed Nov 14 18:58:49 2012
Last mount time: n/a
Last write time: Wed Nov 14 18:59:02 2012
Mount count: 0
Maximum mount count: 33
Last checked: Wed Nov 14 18:58:49 2012
Check interval: 15552000 (6 months)
Next check after: Mon May 13 19:58:49 2013
Lifetime writes: 452 MB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 30bcae6f-2257-4d70-8e82-8467f057bf36
Journal backup: inode blocks
5.iSCSI节点名称有两种格式,即 iqn-type 格式和 eui-type 格式。
iqn-type的格式为:
iqn.yyyy-mm.backward_naming_authority:unique_device_name
在Linux上的格式为:
iqn.1987-05.com.cisco:RandomNumber
通常我们可以把RandomNumber更改为具有意义的名称如主机名称等。
缺省的,生成的节点名称可以在/etc/initiatorname.iscsi 得到.
InitiatorName=iqn.1987-05.com.cisco:01.ed671bf29e
我们可以修改为:
InitiatorName=iqn.1987-05.com.cisco:test2