文章目录
一 需求
1)首先在服务端添加一块10G的硬盘,并进行分区,得到其中的1G作为远程存储设备
2)其次在服务端创建名为iqn.2023-01-05.com:server的新iscsi目标,并且仅限于客户端iqn.2023-01-06.com:client。
3)在客户端可以发现并登录到新目标。
4)在新磁盘上创建 XFS 文件系统,并将其持久挂载到/data目录上。
二 环境准备
服务端IP:10.0.0.100 主机名:rhel-6
客户端IP:10.0.0.101 主机名:rhel6-01
[root@rhel-6 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.9 (Santiago)
[root@rhel-6 ~]# uname -r
2.6.32-696.el6.x86_64
三 服务端配置
3.1 添加硬盘
添加一块10G硬盘。
Linux磁盘分区和管理

3.2 安装软件
执行命令安装软件 yum install scsi-target-utils -y

3.3 编写配置文件
[root@rhel-6 ~]# tail -4 /etc/tgt/targets.conf
<target iqn.2023-01-05.com:server>
backing-store /dev/sdb
initiator-address 10.0.0.101
</target>
此处补充说明配置文件下的一些常用参数:
| 参数 | 说明 |
|---|---|
| backing-store | 定义一个逻辑单元(LUN),这个LUN通常是一个普通文件或者块设备 |
| initiator-address | 限制可以连接target的客户端地址范围 |
| incominguser | 限制可以连接target的客户端用户 |
3.4 启动服务
[root@rhel-6 ~]# service tgtd start
Starting SCSI target daemon: [ OK ]
[root@rhel-6 ~]# chkconfig tgtd on
[root@rhel-6 ~]# service tgtd status
tgtd (pid 6464 6461) is running...
[root@rhel-6 ~]# netstat -lntup|grep 3260
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 6461/tgtd
tcp 0 0 :::3260 :::* LISTEN

该文章详细介绍了如何配置iSCSI服务,包括在服务端添加10G硬盘并创建1G远程存储设备,设置iscsi目标,限制客户端访问,以及启动和检查服务状态。在客户端,文章涵盖了安装iscsi-initiator-utils,启动iscsi服务,发现并登录到服务端目标,以及挂载和测试新磁盘的过程。
最低0.47元/天 解锁文章
638

被折叠的 条评论
为什么被折叠?



