linux 搭建iscsi共享存储

本文详细介绍了如何在服务端部署scsi-target-utils并创建共享磁盘,以及在客户端安装iscsi-initiator-utils并成功连接服务端进行存储访问的过程。通过实例演示了从安装到配置的完整步骤,确保了客户端能够访问到服务端提供的存储资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

<target iqn.2013-12.com.make:ws.httpd>
    backing-store /disk1
</target>

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查看




评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值