ISCSI

一、ISCSI服务

二、ISCSI服务设置

 1.安装并开启服务
[root@localhost ~]# yum install targetcli -y
[root@localhost ~]# systemctl start target
[root@localhost ~]# systemctl status target

 2.新建分区  ##同步分区表
[root@localhost ~]# fdisk /dev/vdb
 Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048     1026047      512000   8e  Linux LVM
/dev/vdb2         1026048     3123199     1048576   83  Linux

 3.配置ISCFIS
[root@localhost ~]# targetcli
/> ls   ##蓝色是目录,紫色是文件
/> /backstores/block create westos:storagel /dev/vdb2    ##命名并关联设备
Created block storage object westos:storagel using /dev/vdb2.
/> /iscsi create iqn.2018-05.com.westos:storagel   ##设定IQN
Created target iqn.2018-05.com.westos:storagel.
Created TPG 1.
/> /iscsi/iqn.2018-05.com.westos:storagel/tpg1/acls create iqn.2018-05.com.westos:westoskey  ##设置密码
Created Node ACL for iqn.2018-05.com.westos:westoskey
/> /iscsi/iqn.2018-05.com.westos:storagel/tpg1/luns create /backstores/block/westos:storagel   ##关联westos:storagel
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2018-05.com.westos:westoskey
/> /iscsi/iqn.2018-05.com.westos:storagel/tpg1/portals create 172.25.254.108
Using default IP port 3260   ##打开接口
Created network portal 172.25.254.108:3260.
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

客户端配置
 1.安装iscsi-initiator-utils
 
 2.开启iscsid服务

 3.查看108主机的共享硬盘
[root@localhost ~]# iscsiadm -m discovery -t st -p 172.25.254.108
172.25.254.108:3260,1 iqn.2018-05.com.westos:storagel

 4.链接108主机的硬盘  ##链接失败,没有key
[root@localhost ~]# iscsiadm -m node -T iqn.2018-05.com.westos:storagel -p 172.25.254.108 -l
Logging in to [iface: default, target: iqn.2018-05.com.westos:storagel, portal: 172.25.254.108,3260] (multiple)
iscsiadm: Could not login to [iface: default, target: iqn.2018-05.com.westos:storagel, portal: 172.25.254.108,3260].
iscsiadm: initiator reported error (24 - iSCSI login failed due to authorization failure)
iscsiadm: Could not log into all portals
 
 5.修改key(服务端的加密key)
[root@localhost ~]# vim /etc/iscsi/initiatorname.iscsi

  重启服务再次获得硬盘
[root@localhost ~]# systemctl restart iscsid.service
[root@localhost ~]# iscsiadm -m node -T iqn.2018-05.com.westos:storagel -p 172.25.254.108 -l
Logging in to [iface: default, target: iqn.2018-05.com.westos:storagel, portal: 172.25.254.108,3260] (multiple)
Login to [iface: default, target: iqn.2018-05.com.westos:storagel, portal: 172.25.254.108,3260] successful.

  客户端可看到添加1个硬盘
[root@localhost ~]# fdisk -l
Disk /dev/sda: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes

  对/dev/sda硬盘分区、格式化、挂载
[root@localhost ~]# fdisk /dev/sda
[root@localhost ~]# mkfs.xfs /dev/sda1
[root@localhost ~]# mount /dev/sda1 /mnt
[root@localhost ~]# df
Filesystem         1K-blocks    Used Available Use% Mounted on
/dev/vda1           10473900 3193680   7280220  31% /
devtmpfs              469344       0    469344   0% /dev
tmpfs                 484932      80    484852   1% /dev/shm
tmpfs                 484932   12832    472100   3% /run
tmpfs                 484932       0    484932   0% /sys/fs/cgroup
/dev/mapper/vg0-vo    483670    2368    451811   1% /home
/dev/sda1            1041068   33056   1008012   4% /mnt

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值