当前位置: 首页 > news >正文

ISCSI:后端卷以LVM 的方式配置 ISCSI 目标启动器

写在前面


  • 准备考试整理相关笔记
  • 博文内容涉及使用 LVM 做ISCSI 目标后端块存储 Demo
  • 理解不足小伙伴帮忙指正

对每个人而言,真正的职责只有一个:找到自我。然后在心中坚守其一生,全心全意,永不停息。所有其它的路都是不完整的,是人的逃避方式,是对大众理想的懦弱回归,是随波逐流,是对内心的恐惧 ——赫尔曼·黑塞《德米安》


目标端配置

配置 servera 提供一个 iSCSI 服务,磁盘名为 iqn.2014-11.com.example:servera ,并符合下列
要求:

  • 服务端口为 3260
  • 使用 iscsi_store 作其后端卷 其大小为 3G
  • 此服务只能被 serverb.lab.example.com 访问
  • 后端卷为 LVM 形式

LVM 准备

查看磁盘情况

NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda    252:0    0  20G  0 disk
└─vda1 252:1    0  10G  0 part /
vdb    252:16   0   5G  0 disk

给 vda 做一个分区

[root@servera iscsi-review]# fdisk /dev/vdaWelcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): n
Partition typep   primary (1 primary, 0 extended, 3 free)e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (20971487-41943039, default 20971520):
Last sector, +sectors or +size{K,M,G,T,P} (20971520-41943039, default 41943039):Created a new partition 2 of type 'Linux' and of size 10 GiB.Command (m for help): w
The partition table has been altered.
Syncing disks.[root@servera iscsi-review]# lsblk
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda    252:0    0  20G  0 disk
├─vda1 252:1    0  10G  0 part /
└─vda2 252:2    0  10G  0 part
vdb    252:16   0   5G  0 disk

创建 物理卷,卷组,逻辑卷

在卷组 myvg 中创建一个名为 myvg 的逻辑卷(Logical Volume),大小为 3GB

[root@servera iscsi-review]# pvcreate /dev/vd
vda   vda1  vda2  vdb
[root@servera iscsi-review]# pvcreate /dev/vda2Physical volume "/dev/vda2" successfully created.
[root@servera iscsi-review]# vgcreate  myvg /dev/vda2Volume group "myvg" successfully created
[root@servera iscsi-review]# lvcreate -n myvg -L 3G myvgLogical volume "myvg" created.

ISCSI 相关配置

安装 targetcli 软件包并启用 target 服务。

[root@servera iscsi-review]# yum -y install  targetcli >> /dev/null
[root@servera iscsi-review]# systemctl enable  --now target.service
Created symlink /etc/systemd/system/multi-user.target.wants/target.service → /usr/lib/systemd/system/target.service.
[root@servera iscsi-review]#
  • 使用 targetcli 工具进入交互式命令行界面。
  • 创建了一个块存储对象 iscsi_store,并将 /dev/myvg/myvg 分配给它。
  • 创建了一个名为 iqn.2014-11.com.example:servera 的 iSCSI 目标。
  • 在 iqn.2014-11.com.example:servera 目标的 TPG1 下创建了一个 LUN,并将 iscsi_store 块存储对+ 象映射到该 LUN。
  • 创建了一个 ACL,允许名为 iqn.2014-11.com.example:serverb 的 iSCSI Initiator 访问上述目标。
  • 删除了一个名为 0.0.0.0:3260 的网络端口。
  • 创建了一个新的网络端口 172.25.250.10:3260。
[root@servera ~]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb49
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'./> /backstores/block create  iscsi_store /dev/myvg/myvg
Created block storage object iscsi_store using /dev/myvg/myvg.
/> /iscsi create iqn.2014-11.com.example:servera
Created target iqn.2014-11.com.example:servera.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/> /iscsi/iqn.2014-11.com.example:servera/tpg1/luns create  /backstores/block/iscsi_store
Created LUN 0.
/> /iscsi/iqn.2014-11.com.example:servera/tpg1/acls create iqn.2014-11.com.example:serverb
Created Node ACL for iqn.2014-11.com.example:serverb
Created mapped LUN 0.
/> /iscsi/iqn.2014-11.com.example:servera/tpg1/portals delete 0.0.0.0 3260
Deleted network portal 0.0.0.0:3260
/> /iscsi/iqn.2014-11.com.example:servera/tpg1/portals create  172.25.250.10 3260
Using default IP port 3260
Created network portal 172.25.250.10:3260.

查看配置情况

/> ls /
o- / ............................................................................................ [...]o- backstores ................................................................................. [...]| o- block ..................................................................... [Storage Objects: 1]| | o- iscsi_store ................................... [/dev/myvg/myvg (3.0GiB) write-thru activated]| |   o- alua ...................................................................... [ALUA Groups: 1]| |     o- default_tg_pt_gp .......................................... [ALUA state: Active/optimized]| o- fileio .................................................................... [Storage Objects: 0]| o- pscsi ..................................................................... [Storage Objects: 0]| o- ramdisk ................................................................... [Storage Objects: 0]o- iscsi ............................................................................... [Targets: 1]| o- iqn.2014-11.com.example:servera ...................................................... [TPGs: 1]|   o- tpg1 .................................................................. [no-gen-acls, no-auth]|     o- acls ............................................................................. [ACLs: 1]|     | o- iqn.2014-11.com.example:serverb ......................................... [Mapped LUNs: 1]|     |   o- mapped_lun0 .............................................. [lun0 block/iscsi_store (rw)]|     o- luns ............................................................................. [LUNs: 1]|     | o- lun0 ............................. [block/iscsi_store (/dev/myvg/myvg) (default_tg_pt_gp)]|     o- portals ....................................................................... [Portals: 1]|       o- 172.25.250.10:3260 .................................................................. [OK]o- loopback ............................................................................ [Targets: 0]
/> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/target/saveconfig.json

使用 systemctl 命令重启 target 服务。这将重新启动 iSCSI 目标服务,以应用任何配置更改或修复可能的问题。使用 firewall-cmd 命令将 iscsi-target 服务添加到防火墙的永久规则中

[root@servera ~]# systemctl  restart  target.service
[root@servera ~]# firewall-cmd  --permanent  --add-service=iscsi-target
success
[root@servera ~]# firewall-cmd  --reload
success

启动器配置

配置 serverb 使其能连接 在node1上提供的 iqn.2014-11.com.example:servera 并符合以下要
求:

  • iSCSI设备在系统启动的期间自动加载
  • 块设备iSCSI上包含一个大小为 2100MiB 的分区,并格式化为 ext4
  • 此分区挂载在 /mnt/data 上,同时在系统启动的期间自动挂载
[root@serverb ~]# yum search iscsi
[root@serverb ~]# yum -y install  iscsi-initiator-utils
[root@serverb ~]# cat /etc/iscsi/initiatorname.iscsi
[root@serverb ~]# echo "InitiatorName=iqn.2014-11.com.example:servera" > /etc/iscsi/initiatorname.iscsi[root@serverb ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2014-11.com.example:servera
[root@serverb ~]# systemctl enable --now iscsid.service
Created symlink /etc/systemd/system/multi-user.target.wants/iscsid.service → /usr/lib/systemd/system/iscsid.service.
[root@serverb ~]# man iscsiadm

通过 iSCSI 发现操作找到了目标服务器的 IP 地址和名称,并使用 iscsiadm 命令登录到该目标。然后使用 lsblk 命令确认已连接的块设备

[root@serverb ~]#  iscsiadm --mode discoverydb --type sendtargets --portal   172.25.250.10 --discover
172.25.250.10:3260,1 iqn.2014-11.com.example:servera
[root@serverb ~]# man iscsiadm
[root@serverb ~]#  iscsiadm  --mode  node --targetname iqn.2014-11.com.example:servera --portal 172.25.
250.10:3260 -l
Logging in to [iface: default, target: iqn.2014-11.com.example:servera, portal: 172.25.250.10,3260]
Login to [iface: default, target: iqn.2014-11.com.example:servera, portal: 172.25.250.10,3260] successful.
[root@serverb ~]# lsblk
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda      8:0    0   3G  0 disk
vda    252:0    0  20G  0 disk
└─vda1 252:1    0  10G  0 part /
vdb    252:16   0   5G  0 disk
[root@serverb ~]# lsblk  --fs /dev/sda
NAME FSTYPE LABEL UUID MOUNTPOINT
sda

通过 fdisk 命令创建了一个新的分区表,并在 /dev/sda 上创建了一个 2.1GB 大小的主分区 /dev/sda1。然后使用 mkfs.ext4 命令在该分区上创建了 ext4 文件系统,验证分区和文件系统的创建情况。

[root@serverb ~]# fdisk /dev/sdaWelcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xf9fbdda4.Command (m for help): n
Partition typep   primary (0 primary, 0 extended, 4 free)e   extended (container for logical partitions)
Select (default p):Using default response p.
Partition number (1-4, default 1):
First sector (2048-6291455, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-6291455, default 6291455): +2100MCreated a new partition 1 of type 'Linux' and of size 2.1 GiB.Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.[root@serverb ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0    3G  0 disk
└─sda1   8:1    0  2.1G  0 part
vda    252:0    0   20G  0 disk
└─vda1 252:1    0   10G  0 part /
vdb    252:16   0    5G  0 disk
[root@serverb ~]# mkfs.ext4 /dev/sda1
mke2fs 1.44.6 (5-Mar-2019)
Creating filesystem with 537600 4k blocks and 134640 inodes
Filesystem UUID: 74d0c4f2-cc5f-46cc-a80d-5750690b5f56
Superblock backups stored on blocks:32768, 98304, 163840, 229376, 294912Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done[root@serverb ~]# lsblk --fs /dev/sda1
NAME FSTYPE LABEL UUID                                 MOUNTPOINT
sda1 ext4         74d0c4f2-cc5f-46cc-a80d-5750690b5f56

将 /dev/sda1 分区(文件系统类型为 ext4)挂载到 /mnt/data 目录,并将该挂载配置添加到 /etc/fstab 文件中,以便在系统启动时自动挂载该文件系统。

[root@serverb ~]# blkid  /dev/sda1
/dev/sda1: UUID="74d0c4f2-cc5f-46cc-a80d-5750690b5f56" TYPE="ext4" PARTUUID="f9fbdda4-01"
[root@serverb ~]# mkdir /mnt/data
[root@serverb ~]# echo  "UUID='74d0c4f2-cc5f-46cc-a80d-5750690b5f56'  /mnt/data  ext4 _netdev 0 0" >> /
etc/fstab
[root@serverb ~]# cat /etc/fstab#
# /etc/fstab
# Created by anaconda on Tue Oct 29 16:26:01 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=f7614c41-2835-4125-bb13-50772dc2f30c /                       xfs     defaults        0 0
servera.lab.example.com:/nfsshare /share                          nfs      defaults        0 0
UUID='74d0c4f2-cc5f-46cc-a80d-5750690b5f56'  /mnt/data  ext4 _netdev 0 0
[root@serverb ~]# mount  /mnt/data
[root@serverb ~]# df -ht ext4
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       2.0G  6.2M  1.9G   1% /mnt/data
[root@serverb ~]#

博文部分内容参考

© 文中涉及参考链接内容版权归原作者所有,如有侵权请告知


红帽服务管理与自动化(RH358)授课笔记


© 2018-2023 liruilonger@gmail.com, All rights reserved. 保持署名-非商用-相同方式共享(CC BY-NC-SA 4.0)

相关文章:

ISCSI:后端卷以LVM 的方式配置 ISCSI 目标启动器

写在前面 准备考试整理相关笔记博文内容涉及使用 LVM 做ISCSI 目标后端块存储 Demo理解不足小伙伴帮忙指正 对每个人而言,真正的职责只有一个:找到自我。然后在心中坚守其一生,全心全意,永不停息。所有其它的路都是不完整的&#…...

八公山豆腐发展现状与销售对策研究

1.引言 八公山豆腐作为中国传统特色食品之一,一直以来备受人们的喜爱。然而,在现代社会中,由于消费者对于营养健康的追求以及市场竞争的加剧,八公山豆腐的市场份额逐渐缩小。因此,为了更好地推广和发展八公山豆腐&…...

排序算法-插入排序

属性 当插入第i(i>1)个元素时,前面的array[0],array[1],…,array[i-1]已经排好序,此时用array[i]的排序码与array[i1],array[i-2],…的排序码顺序进行比较,找到插入位置即将array[i]插入,原来位置上的元素顺序后移 直接插入排序…...

多位数按键操作(闪烁)数码管显示

/*----------------------------------------------- 内容&#xff1a;按键加减数字&#xff0c;多个数码管显示 ------------------------------------------------*/ #include<reg52.h> //包含头文件&#xff0c;一般情况不需要改动&#xff0c;头文件包含特殊功能寄存…...

MyEclipse项目导入与导出

一、项目导出 1、右键选择项目名称&#xff0c;弹出菜单中选择“export”&#xff0c;如下图所示 2、选择“恶心“export”&#xff0c;弹出菜单如下&#xff1b;在“General“选项中&#xff0c;选择“File System”选项 3、点击“next”&#xff0c;进入保存位置选择界面&am…...

ArrayList和LinkedList

最近在刷回溯算法时&#xff0c;遇见了List<Integer> A new ArrayList<>(); LinkedList<Integer> B new LinkedList<>();这类型的表达方式 很好奇的问题是&#xff1a; 1、List<Integer> A new ArrayList<>();为什么是正确的写法 2…...

Linux 配置 Nginx 服务完整详细版

目录 前言 配置Nginx监听端口和服务器块 # 防DDoS配置 # 日志配置 # 设置服务器块 监听端口 网站根目录 默认文件 静态文件目录 图像文件目录 # 自定义错误页面 # 反向代理配置 # 配置SSL/TLS 1、获取SSL/TLS证书 2、安装证书 3、配置SSL/TLS # 配置SSL协议版本…...

Python实现猎人猎物优化算法(HPO)优化LightGBM回归模型(LGBMRegressor算法)项目实战

说明&#xff1a;这是一个机器学习实战项目&#xff08;附带数据代码文档视频讲解&#xff09;&#xff0c;如需数据代码文档视频讲解可以直接到文章最后获取。 1.项目背景 猎人猎物优化搜索算法(Hunter–prey optimizer, HPO)是由Naruei& Keynia于2022年提出的一种最新的…...

无涯教程-JavaScript - ODD函数

描述 ODD函数返回四舍五入到最接近的奇数整数的数字。 ODD函数是Excel中的15个舍入函数之一。 语法 ODD (number)争论 Argument描述Required/OptionalNumberThe value to round.Required Notes 无论数字的符号如何,值都将从零舍入到下一个奇数。如果number是一个奇数整数…...

Easyui里的datagrid嵌入select下拉框

问题&#xff1a; 想使用datagird里嵌入select下拉框&#xff0c;并在提交form表单时获取datagrid选中的每行数据里的每个下拉框选中的值。 解决方案&#xff1a; 其中economicIssuesSelect使用下拉框&#xff0c;重点关注 initEconomicIssues(row)方法。这里的方法需要传递ro…...

计算机专业毕业设计项目推荐03-Wiki系统设计与实现(JavaSpring+Vue+Mysql)

Wiki系统设计与实现&#xff08;JavaSpringVueMysql&#xff09; **介绍****系统总体开发情况-功能模块****各部分模块实现** 介绍 本系列(后期可能博主会统一为专栏)博文献给即将毕业的计算机专业同学们,因为博主自身本科和硕士也是科班出生,所以也比较了解计算机专业的毕业设…...

微服务的艺术:构建可扩展和弹性的分布式应用

文章目录 什么是微服务架构&#xff1f;微服务的设计原则1. 基于业务边界划分服务2. 松耦合和强内聚3. 自动化测试和部署4. 监控和日志5. 弹性设计 微服务的实施细节1. 服务发现示例代码&#xff1a;使用Consul进行服务发现 2. 负载均衡示例代码&#xff1a;Nginx配置负载均衡 …...

在PHP8中对数组进行排序-PHP8知识详解

在php8中&#xff0c;提供了丰富的排序函数&#xff0c;可以对数组进行排序操作。常见的排序函数如下几个&#xff1a;sort() 函数、rsort() 函数、asort() 函数、arsort() 函数、ksort() 函数、krsort() 函数、natsort()函数和natcascsort()函数。 1、sort() 函数&#xff1a;…...

Redis混合模式持久化原理

前言 前面文章中我们也介绍过Redis的持久化方式有两种&#xff1a;rdb持久化和aof持久化&#xff0c;具体详情可查看之前文章redis持久化。rdb持久化还是aof持久化它们都有各自的缺点。 rdb和aof缺点 rdb持久化&#xff1a;由于是定期对内存数据快照进行持久化&#xff0c;因此…...

《BPF Performance Tools —— 洞悉Linux系统和应用性能》学习笔记 —— 第一章 介绍(2)

接前一篇文章&#xff1a;《BPF Performance Tools —— 洞悉Linux系统和应用性能》学习笔记 —— 第一章 介绍&#xff08;1&#xff09; 1.2 Tracing、Snooping、Sampling、Profiling和Observability是什么&#xff1f; 这些都是用于对分析技术和工具进行分类的术语。 Trac…...

【计算机网络】网络编程接口 Socket API 解读(7)

Socket 是网络协议栈暴露给编程人员的 API&#xff0c;相比复杂的计算机网络协议&#xff0c;API 对关键操作和配置数据进行了抽象&#xff0c;简化了程序编程。 本文讲述的 socket 内容源自 Linux man。本文主要对各 API 进行详细介绍&#xff0c;从而更好的理解 socket 编程。…...

crypto++下载、安装(VS2017)及加解密使用

crpto 下载按个人喜好下载&#xff0c;我使用了图中框选的8.8.0 Release.解压 安装打开修改以适应本机配置整理至标准库 调用加解密使用 Crypto&#xff08;也称为Crypto Library或Crypto STL&#xff09;是一个C密码学库&#xff0c;它提供了各种密码学算法和安全编程工具&…...

R语言画图

简单记录一下 plot(lad_profile_relative$lad, lad_profile_relative$height, type"l", lwd1.5, xlabexpression(paste("LAD ", "(", m^2, m^-3, ")" )), ylab"Height (m)")X轴数据&#xff0c; Y轴数据 type, 标记类型 lw…...

redis 核心数据结构

一、简述 redis是一个开源的使用C语言编写的一个kv存储系统&#xff0c;是一个速度非常快的非关系远程内存数据库。它支持包括String、List、Set、Zset、hash五种数据结构。 除此之外&#xff0c;通过复制、持久化和客户端分片等特性&#xff0c;用户可以很方便地将redis扩展…...

RabbitMQ消息可靠性(一)-- 生产者消息确认

前言 在项目中&#xff0c;引入了RabbitMQ这一中间件&#xff0c;必然也需要在业务中增加对数据安全性的一层考虑&#xff0c;来保证RabbitMQ消息的可靠性&#xff0c;否则一个个消息丢失可能导致整个业务的数据出现不一致等问题&#xff0c;对系统带来巨大的影响&#xff0c;…...

Vim 调用外部命令学习笔记

Vim 外部命令集成完全指南 文章目录 Vim 外部命令集成完全指南核心概念理解命令语法解析语法对比 常用外部命令详解文本排序与去重文本筛选与搜索高级 grep 搜索技巧文本替换与编辑字符处理高级文本处理编程语言处理其他实用命令 范围操作示例指定行范围处理复合命令示例 实用技…...

Objective-C常用命名规范总结

【OC】常用命名规范总结 文章目录 【OC】常用命名规范总结1.类名&#xff08;Class Name)2.协议名&#xff08;Protocol Name)3.方法名&#xff08;Method Name)4.属性名&#xff08;Property Name&#xff09;5.局部变量/实例变量&#xff08;Local / Instance Variables&…...

九天毕昇深度学习平台 | 如何安装库?

pip install 库名 -i https://pypi.tuna.tsinghua.edu.cn/simple --user 举个例子&#xff1a; 报错 ModuleNotFoundError: No module named torch 那么我需要安装 torch pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple --user pip install 库名&#x…...

Python 实现 Web 静态服务器(HTTP 协议)

目录 一、在本地启动 HTTP 服务器1. Windows 下安装 node.js1&#xff09;下载安装包2&#xff09;配置环境变量3&#xff09;安装镜像4&#xff09;node.js 的常用命令 2. 安装 http-server 服务3. 使用 http-server 开启服务1&#xff09;使用 http-server2&#xff09;详解 …...

适应性Java用于现代 API:REST、GraphQL 和事件驱动

在快速发展的软件开发领域&#xff0c;REST、GraphQL 和事件驱动架构等新的 API 标准对于构建可扩展、高效的系统至关重要。Java 在现代 API 方面以其在企业应用中的稳定性而闻名&#xff0c;不断适应这些现代范式的需求。随着不断发展的生态系统&#xff0c;Java 在现代 API 方…...

嵌入式常见 CPU 架构

架构类型架构厂商芯片厂商典型芯片特点与应用场景PICRISC (8/16 位)MicrochipMicrochipPIC16F877A、PIC18F4550简化指令集&#xff0c;单周期执行&#xff1b;低功耗、CIP 独立外设&#xff1b;用于家电、小电机控制、安防面板等嵌入式场景8051CISC (8 位)Intel&#xff08;原始…...

Java 与 MySQL 性能优化:MySQL 慢 SQL 诊断与分析方法详解

文章目录 一、开启慢查询日志&#xff0c;定位耗时SQL1.1 查看慢查询日志是否开启1.2 临时开启慢查询日志1.3 永久开启慢查询日志1.4 分析慢查询日志 二、使用EXPLAIN分析SQL执行计划2.1 EXPLAIN的基本使用2.2 EXPLAIN分析案例2.3 根据EXPLAIN结果优化SQL 三、使用SHOW PROFILE…...

JS红宝书笔记 - 3.3 变量

要定义变量&#xff0c;可以使用var操作符&#xff0c;后跟变量名 ES实现变量初始化&#xff0c;因此可以同时定义变量并设置它的值 使用var操作符定义的变量会成为包含它的函数的局部变量。 在函数内定义变量时省略var操作符&#xff0c;可以创建一个全局变量 如果需要定义…...

【笔记】AI Agent 项目 SUNA 部署 之 Docker 构建记录

#工作记录 构建过程记录 Microsoft Windows [Version 10.0.27871.1000] (c) Microsoft Corporation. All rights reserved.(suna-py3.12) F:\PythonProjects\suna>python setup.py --admin███████╗██╗ ██╗███╗ ██╗ █████╗ ██╔════╝…...

安宝特方案丨从依赖经验到数据驱动:AR套件重构特种装备装配与质检全流程

在高压电气装备、军工装备、石油测井仪器装备、计算存储服务器和机柜、核磁医疗装备、大型发动机组等特种装备生产型企业&#xff0c;其产品具有“小批量、多品种、人工装配、价值高”的特点。 生产管理中存在传统SOP文件内容缺失、SOP更新不及、装配严重依赖个人经验、产品装…...