• centos7.5 连接存储配置iscsi


    linux 安装iscsi包

    [root@localhost ~]# yum  list | grep iscs
    iscsi-initiator-utils.x86_64            6.2.0.874-7.el7                cr       
    iscsi-initiator-utils-iscsiuio.x86_64   6.2.0.874-7.el7                cr       
    libiscsi.x86_64                         1.9.0-7.el7                    cr       
    libvirt-daemon-driver-storage-iscsi.x86_64
    [root@localhost ~]# yum install iscsi-initiator-utils
    已加载插件:fastestmirror
    Loading mirror speeds from cached hostfile
    正在解决依赖关系
    --> 正在检查事务
    ---> 软件包 iscsi-initiator-utils.x86_64.0.6.2.0.874-7.el7 将被 安装
    --> 正在处理依赖关系 iscsi-initiator-utils-iscsiuio >= 6.2.0.874-7.el7,它被软件包 iscsi-initiator-utils-6.2.0.874-7.el7.x86_64 需要
    --> 正在检查事务
    ---> 软件包 iscsi-initiator-utils-iscsiuio.x86_64.0.6.2.0.874-7.el7 将被 安装
    --> 解决依赖关系完成
    
    依赖关系解决
    
    =======================================================================================================================================================================
     Package                                                 架构                            版本                                        源                           大小
    =======================================================================================================================================================================
    正在安装:
     iscsi-initiator-utils                                   x86_64                          6.2.0.874-7.el7                             cr                          422 k
    为依赖而安装:
     iscsi-initiator-utils-iscsiuio                          x86_64                          6.2.0.874-7.el7                             cr                           90 k
    
    事务概要
    =======================================================================================================================================================================
    安装  1 软件包 (+1 依赖软件包)
    
    总下载量:512 k
    安装大小:2.6 M
    Is this ok [y/d/N]: y
    Downloading packages:
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    总计                                                                                                                                    17 MB/s | 512 kB  00:00:00     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    警告:RPM 数据库已被非 yum 程序修改。
      正在安装    : iscsi-initiator-utils-6.2.0.874-7.el7.x86_64                                                                                                       1/2 
      正在安装    : iscsi-initiator-utils-iscsiuio-6.2.0.874-7.el7.x86_64                                                                                              2/2 
      验证中      : iscsi-initiator-utils-iscsiuio-6.2.0.874-7.el7.x86_64                                                                                              1/2 
      验证中      : iscsi-initiator-utils-6.2.0.874-7.el7.x86_64                                                                                                       2/2 
    
    已安装:
      iscsi-initiator-utils.x86_64 0:6.2.0.874-7.el7                                                                                                                       
    
    作为依赖被安装:
      iscsi-initiator-utils-iscsiuio.x86_64 0:6.2.0.874-7.el7                                                                                                              
    
    完毕!
    [root@localhost ~]# systemctl enable iscsi
    [root@localhost ~]# cat /etc/iscsi/initiatorname.iscsi
    InitiatorName=iqn.1994-05.com.redhat:b5f8f023e12e

    查看linux iqn存储上面配置映射

    存储划分50t

    发现存储映射,

    [root@localhost ~]# iscsiadm -m discovery -t sendtargets -p 192.168.130.101:3260
    192.168.130.101:3260,1 iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4
    [fe80:0000:0000:0000:d239:eaff:fe1c:f4d5]:3260,1 iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4
    192.168.131.101:3260,1 iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4
    192.168.130.102:3260,2 iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4
    192.168.131.102:3260,2 iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4

    连接存储

    [root@localhost ~]# iscsiadm -m node -T iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4 -p 192.168.130.101 -l                       
    Logging in to [iface: default, target: iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4, portal: 192.168.130.101,3260] (multiple)
    Login to [iface: default, target: iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4, portal: 192.168.130.101,3260] successful.
    [root@localhost ~]# fdisk -l
    WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
    
    磁盘 /dev/sda:3998.0 GB, 3997997989888 字节,7808589824 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):65536 字节 / 131072 字节
    磁盘标签类型:gpt
    Disk identifier: DAAB1D88-0795-4EC3-89D7-2171BDD4AB12
    
    
    #         Start          End    Size  Type            Name
     1         2048      1026047    500M  EFI System      EFI System Partition
     2      1026048      2050047    500M  Microsoft basic 
     3      2050048   7808587775    3.7T  Linux LVM       
    
    磁盘 /dev/mapper/centos-root:214.7 GB, 214748364800 字节,419430400 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):65536 字节 / 131072 字节
    
    
    磁盘 /dev/mapper/centos-swap:17.2 GB, 17179869184 字节,33554432 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):65536 字节 / 131072 字节
    
    
    磁盘 /dev/mapper/centos-ava_app:3765.0 GB, 3765016985600 字节,7353548800 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):65536 字节 / 131072 字节
    
    
    磁盘 /dev/sdb:8095 MB, 8095006720 字节,15810560 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    磁盘标签类型:dos
    磁盘标识符:0xcad4ebea
    
       设备 Boot      Start         End      Blocks   Id  System
    /dev/sdb4   *         256    15810559     7905152    b  W95 FAT32
    WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
    
    磁盘 /dev/sdc:54975.6 GB, 54975581388800 字节,107374182400 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 4096 字节
    I/O 大小(最小/最佳):4096 字节 / 4096 字节
    磁盘标签类型:gpt
    Disk identifier: E8286D05-FA93-4CE0-82F2-573F930EB840
    
    
    #         Start          End    Size  Type            Name
     1           34 107374180447     50T  Microsoft basic primary
    Partition 1 does not start on physical sector boundary.
    
    磁盘 /dev/sdd:20 MB, 20971520 字节,40960 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    
    [root@localhost ~]#

    存储空间上次分过区了,这里显示有一个主分区。

    如果是没分区的话,可以使用parted进行分区(设立不介绍分区步骤了,参考parted 命令)

    挂载分区,设置开机自动挂载

    [root@localhost ~]# mkdir /DATA
    [root@localhost ~]# mount /dev/sdc
    sdc   sdc1  
    [root@localhost ~]# mount /dev/sdc1 /DATA
    [root@localhost ~]# vi /etc/fstab 
    [root@localhost ~]# cat /etc/fstab 
    
    #
    # /etc/fstab
    # Created by anaconda on Mon Apr 26 10:27:26 2021
    #
    # 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
    #
    /dev/mapper/centos-root /                       xfs     defaults        0 0
    /dev/sdc1 /DATA                       xfs     defaults        0 0
    /dev/mapper/centos-ava_app /ava_app                xfs     defaults        0 0
    UUID=c6488b46-0004-4511-9fa1-3fbe2bcdfe40 /boot                   xfs     defaults        0 0
    UUID=50D8-7F59          /boot/efi               vfat    umask=0077,shortname=winnt 0 0
    /dev/mapper/centos-swap swap                    swap    defaults        0 0
    [root@localhost ~]# 

    重启后会失败提示如下:

    参考博客:https://blog.csdn.net/jiyiyun/article/details/103798730

    解决方法,删掉fstab里面的新增内容后,重新注册iscsi,重新配置开机自动挂载iscsi磁盘,操作步骤如下:

    [root@localhost ~]# iscsiadm -m node -T iqn.2002-09.com.lenovo:thinksystem.6d039ea00017d07900000000607eb8a4 -p 192.168.130.101:3260 --op update -n node.startup -v automatic                       
    [root@localhost ~]# lsblk
    NAME               MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda                  8:0    0  3.7T  0 disk 
    ├─sda1               8:1    0  500M  0 part /boot/efi
    ├─sda2               8:2    0  500M  0 part /boot
    └─sda3               8:3    0  3.7T  0 part 
      ├─centos-root    253:0    0  200G  0 lvm  /
      ├─centos-swap    253:1    0   16G  0 lvm  [SWAP]
      └─centos-ava_app 253:2    0  3.4T  0 lvm  /ava_app
    sdb                  8:16   0   50T  0 disk 
    └─sdb1               8:17   0   50T  0 part 
    sdc                  8:32   0   20M  0 disk 
    [root@localhost ~]# 
    [root@localhost ~]# mount /dev/sdb1 /DATA/       
    [root@localhost ~]# cat /etc/fstab

    #
    # /etc/fstab
    # Created by anaconda on Mon Apr 26 10:27:26 2021
    #
    # 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
    #
    /dev/mapper/centos-root /                       xfs     defaults        0 0
    /root/CentOS-7-x86_64-DVD-1804.iso /usbiso                       iso9660     defaults,ro,loop        0 0
    UUID=16d940dc-0d29-4dd1-a652-f40efc83a492 /DATA                       ext4    defaults,_netdev        0 0
    /dev/mapper/centos-ava_app /ava_app                xfs     defaults        0 0
    UUID=c6488b46-0004-4511-9fa1-3fbe2bcdfe40 /boot                   xfs     defaults        0 0
    UUID=50D8-7F59          /boot/efi               vfat    umask=0077,shortname=winnt 0 0
    /dev/mapper/centos-swap swap                    swap    defaults        0 0
    [root@localhost ~]#
    [root@localhost ~]# df -T 
    文件系统                   类型           1K-块    已用        可用 已用% 挂载点
    /dev/mapper/centos-root    xfs        209611776 5435500   204176276    3% /
    devtmpfs                   devtmpfs    32627156       0    32627156    0% /dev
    tmpfs                      tmpfs       32639532       0    32639532    0% /dev/shm
    tmpfs                      tmpfs       32639532   10596    32628936    1% /run
    tmpfs                      tmpfs       32639532       0    32639532    0% /sys/fs/cgroup
    /dev/sda2                  xfs           508416  130148      378268   26% /boot
    /dev/sda1                  vfat          511720   10008      501712    2% /boot/efi
    /dev/loop0                 iso9660      4364408 4364408           0  100% /usbiso
    /dev/mapper/centos-ava_app xfs       3674977024   33840  3674943184    1% /ava_app
    /dev/sdb1                  ext4     53473275824      20 50788904912    1% /DATA
    tmpfs                      tmpfs        6527908       0     6527908    0% /run/user/0
    [root@localhost ~]# 

    这里重启后我拔出了系统安装u盘,iscsi分区变成了sdb1,防止重启后分区盘符漂移,这里使用uuid挂载

    [root@localhost ~]# blkid
    /dev/mapper/centos-root: UUID="1c857009-cf25-43dd-9e28-903bb8586b64" TYPE="xfs" 
    /dev/sdb3: UUID="IHCc3d-1MO0-dAzB-ekoZ-pxrp-eR0Q-Bgd1qu" TYPE="LVM2_member" PARTUUID="192f9fb9-542a-4599-8e49-f6d2559bc678" 
    /dev/sdb1: SEC_TYPE="msdos" UUID="D5FD-26B6" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="bad4e1f5-6923-471c-bc54-5b4c91abd22f" 
    /dev/sdb2: UUID="af2a8d27-9f3a-4f83-8952-937ee1f03536" TYPE="xfs" PARTUUID="a880b557-e31a-4fa0-808b-6fd432c8ded6" 
    /dev/sda1: UUID="9679951a-cc96-4c21-93ca-ee29f4aab2e7" TYPE="ext4" PARTLABEL="primary" PARTUUID="80c2e28f-9e2e-4079-a169-1e3fd7288ffc" 
    /dev/mapper/centos-swap: UUID="84cd5ac5-9a99-4430-86fd-be41cd38af2a" TYPE="swap" 
    /dev/sdc4: LABEL="CentOS 7 x8" UUID="B4FE-5315" TYPE="vfat" 
    /dev/sdd1: UUID="34583c79-2cda-46bf-b885-91e88b111d83" TYPE="ext4" 
    [root@localhost ~]# 
  • 相关阅读:
    SourceInsight工具增强——AStyle(代码格式化)、PC-Lint(静态检查)
    读《Top benefits of continuous integration》有感
    授人以鱼不如授人以渔——和女儿学一起学成语
    Linux内存使用情况以及内存泄露分析之工具与方法
    常用gcc选项
    KVM内核文档阅读笔记
    关于Linux虚拟化技术KVM的科普 科普五(From 世民谈云计算)
    关于Linux虚拟化技术KVM的科普 科普四(From humjb_1983)
    关于Linux虚拟化技术KVM的科普 科普三(From OenHan)
    关于Linux虚拟化技术KVM的科普 科普二(KVM虚拟机代码揭秘)
  • 原文地址:https://www.cnblogs.com/wenxiao1-2-3-4/p/14704025.html
Copyright © 2020-2023  润新知