加入收藏 | 设为首页 | 会员中心 | 我要投稿 海南站长网 (https://www.0898zz.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Windows > 正文

如何构建一台网络引导服务器(二)

发布时间:2019-01-19 06:09:41 所属栏目:Windows 来源:Gregory Bartholomew
导读:副标题#e# 在 如何构建一台网络引导服务器(一) 的文章中,我们展示了如何创建一个网络引导镜像,在那个镜像中使用了一个名为 liveuser 帐户,它的家目录位于内存中,重启后家目录中的内容将全部消失。然而很多用户都希望机器重启后保存他们的文件和设置。

接着,创建一个 fc28.img 稀疏文件。这个稀疏文件代表 iSCSI 目标的后备存储器:

  1. # FC28_SIZE=$(du -ms /fc28 | cut -f 1)
  2. # dd if=/dev/zero of=/fc28.img bs=1MiB count=0 seek=$(($FC28_SIZE*2))

(如果你有一个可使用的独立分区或磁盘驱动器,也可以用它,而不用再去创建这个稀疏文件了。)

接着,使用一个文件系统去格式化镜像、挂载它、然后将网络引导镜像复制进去:

  1. # mkfs -t xfs -L NETROOT /fc28.img
  2. # TEMP_MNT=$(mktemp -d)
  3. # mount /fc28.img $TEMP_MNT
  4. # cp -a /fc28/* $TEMP_MNT
  5. # umount $TEMP_MNT

在使用 SquashFS 测试时,客户端偶尔会出现小状况。似乎是因为 SquashFS 在多处理器客户端上没法执行随机 I/O。(更多内容见 squashfs 读取卡顿的奇怪案例)。如果你希望使用文件系统压缩来提升吞吐性能,ZFS 或许是个很好的选择。

如果你对 iSCSI 服务器的吞吐性能要求非常高(比如,成百上千的客户端要连接它),可能需要使用带 负载均衡 的 Ceph 集群了。更多相关内容,请查看 使用 HAProxy 和 Keepalived 负载均衡的 Ceph 对象网关。

安装和配置 iSCSI

为了给我们的客户端提供网络引导镜像,安装 scsi-target-utils 包:

  1. # dnf install -y scsi-target-utils

配置 iSCSI 守护程序去提供 fc28.img 文件:

  1. # MY_REVERSE_HOSTNAME=$(echo $MY_HOSTNAME | tr '.' "n" | tac | tr "n" '.' | cut -b -${#MY_HOSTNAME})
  2. # cat << END > /etc/tgt/conf.d/fc28.conf
  3. <target iqn.$MY_REVERSE_HOSTNAME:fc28>
  4. backing-store /fc28.img
  5. readonly 1
  6. </target>
  7. END

开头的 iqn./usr/lib/dracut/modules.d/40network/net-lib.sh 所需要的。

添加一个防火墙例外,并启用和启动这个服务:

  1. # firewall-cmd --add-service=iscsi-target
  2. # firewall-cmd --runtime-to-permanent
  3. # systemctl enable tgtd.service
  4. # systemctl start tgtd.service

你现在应该能够使用 tatadm 命令看到这个镜像共享了:

  1. # tgtadm --mode target --op show

上述命令的输出应该类似如下的内容:

  1. Target 1: iqn.edu.example.server-01:fc28
  2. System information:
  3. Driver: iscsi
  4. State: ready
  5. I_T nexus information:
  6. LUN information:
  7. LUN: 0
  8. Type: controller
  9. SCSI ID: IET 00010000
  10. SCSI SN: beaf10
  11. Size: 0 MB, Block size: 1
  12. Online: Yes
  13. Removable media: No
  14. Prevent removal: No
  15. Readonly: No
  16. SWP: No
  17. Thin-provisioning: No
  18. Backing store type: null
  19. Backing store path: None
  20. Backing store flags:
  21. LUN: 1
  22. Type: disk
  23. SCSI ID: IET 00010001
  24. SCSI SN: beaf11
  25. Size: 10488 MB, Block size: 512
  26. Online: Yes
  27. Removable media: No
  28. Prevent removal: No
  29. Readonly: Yes
  30. SWP: No
  31. Thin-provisioning: No
  32. Backing store type: rdwr
  33. Backing store path: /fc28.img
  34. Backing store flags:
  35. Account information:
  36. ACL information:
  37. ALL

(编辑:海南站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读