iscsi服务端IP192.168.254.172
客户端1 192.168.254.46
客户端2 192.168.254.158
一、服务端的配置
1、服务端安装scsi-target-utils
[root@localhost ~]# yum install scsi-target-utils -y
2、如果有独立的分区,可以使用独立的分区,如果没有合适的分区可以dd一个大文件来作为共享磁盘
[root@localhost /]# dd if=/dev/zero of=/disk1 bs=1M count=3000
3000+0 records in
3000+0 records out
3145728000 bytes (3.1 GB) copied, 11.618 seconds, 271 MB/s
3、修改iscsi的主配置文件
[root@localhost ~]# vi /etc/tgt/targets.conf
backing-store /disk1
4、启动tgtd服务
[root@localhost ~]# /etc/init.d/tgtd restart
Stopping SCSI target daemon: Stopping target framework daemon
[ OK ]
Starting SCSI target daemon: Starting target framework daemon
二、客户端的配置
1、安装客户端
[root@zabbix-client1 ~]# yum install iscsi-initiator-utils -y
2、启动客户端
[root@zabbix-client1 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.254.172
正在启动 iscsid: [确定]
192.168.254.172:3260,1 iqn.2013-12.com.make:ws.httpd
192.168.254.172:3260,1 iqn.2013-12.com.make:ws.mysqld
3、使用客户端发现挂载存储
[root@zabbix-client1 ~]# iscsiadm -m node -T iqn.2013-12.com.make:ws.httpd -l
Logging in to [iface: default, target: iqn.2013-12.com.make:ws.httpd, portal: 192.168.254.172,3260] (multiple)
Login to [iface: default, target: iqn.2013-12.com.make:ws.httpd, portal: 192.168.254.172,3260] successful.
4、在 客户端上对挂载的两个磁盘进行分区并格式化成ext4格式的文件系统
[root@localhost ~]# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xcc8d06f3.
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)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1021, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1021, default 1021):
Using default value 1021
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# mkfs.ext4 /dev/sda1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
192000 inodes, 767529 blocks
38376 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=788529152
24 block groups
32768 blocks per group, 32768 fragments per group
8000 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
三、在另一个客户端做相同的操作,但是无需重新格式化
在两个客户端上分别使用fdisk -l查看