基于linux下的iscsi远程块存储

iscsi

虚拟磁盘就是在本地电脑里面虚拟出一个远程电脑里面的磁盘。感觉像是在本机上的硬盘一样。其实他没在本机上。网络虚拟磁盘iSISC可以加大网吧客户机硬盘容量,高速安全稳定.iSCSI Cake主要用于网吧共享硬盘服务。 客户端可以通过局域网连接服务器上的iSCSI Cake服务器,在本地虚拟出一块硬盘,以达到通过网络共享服务器硬盘的效果。网吧业主只需要在服务器上的iSCSI Cake里添加目录和安装游戏软件,客户端的本地虚拟硬盘里就有了相应的游戏软件,不需要到每台机器进行安装。

服务端:

  111  yum install targetcli  -y
  112  systemctl start target
  113  targetcli
  115  fdisk /dev/vdb   (+2G)
  116  partprobe
  117  targetcli
[root@server ~]# targetcli
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/> ls
o- / ............................................................. [...]
  o- backstores .................................................. [...]
  | o- block ...................................... [Storage Objects: 0]
  | o- fileio ..................................... [Storage Objects: 0]
  | o- pscsi ...................................... [Storage Objects: 0]
  | o- ramdisk .................................... [Storage Objects: 0]
  o- iscsi ................................................ [Targets: 0]
  o- loopback ............................................. [Targets: 0]
/> /backstores/block create  westos:storage1  /dev/vdb1
Created block storage object westos:storage1 using /dev/vdb1.
/> /iscsi  create iqn.2018-06.com.example:storage1
Created target iqn.2018-06.com.example:storage1.
Created TPG 1.
/> ls
o- / ............................................................. [...]
  o- backstores .................................................. [...]
  | o- block ...................................... [Storage Objects: 1]
  | | o- westos:storage1 ... [/dev/vdb1 (2.0GiB) write-thru deactivated]
  | o- fileio ..................................... [Storage Objects: 0]
  | o- pscsi ...................................... [Storage Objects: 0]
  | o- ramdisk .................................... [Storage Objects: 0]
  o- iscsi ................................................ [Targets: 1]
  | o- iqn.2018-06.com.example:storage1 ...................... [TPGs: 1]
  |   o- tpg1 ................................... [no-gen-acls, no-auth]
  |     o- acls .............................................. [ACLs: 0]
/> /iscsi/iqn.2018-06.com.example:storage1/tpg1/acls  create iqn.2018-06.com.example:westoskey
Created Node ACL for iqn.2018-06.com.example:westoskey
/> /iscsi/iqn.2018-06.com.example:storage1/tpg1/luns create /backstores/block/westos:storage1
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2018-06.com.example:westoskey
/> /iscsi/iqn.2018-06.com.example:storage1/tpg1/portals  create 172.25.254.200
Using default IP port 3260
Created network portal 172.25.254.213:3260.
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.

Configuration saved to /etc/target/saveconfig.json



客户端:
    2  fdisk -l
    3  yum install iscsi-initiator-utils.x86_64  -y
    4  cd /etc/iscsi/
    5  ls
    6  vim initiatorname.iscsi
        InitiatorName=iqn.2018-06.com.example:westoskey
    7  systemctl restart iscsid.service
    8  iscsiadm  -m(执行的动作) discovery -t(类型) st -p(端口) 172.25.254.200   发现端口
    9  iscsiadm  -m node -T(目标) iqn.2018-06.com.example:storage1 -p 172.25.254.200  -l (连接进入login)   
   10  fdisk -l(多了一块设备)
     Disk /dev/sda: 2147 MB, 2147483648 bytes, 4194304 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


四、开及自动挂载
客户端;
  246  fdisk /dev/sda
  247  partprobe
  248  mkfs.xfs /dev/sda1
  249  mount /dev/sda1  /mnt
  250  df
  251  vim /etc/fstab
     /dev/sda1       /mnt      xfs     defaults,_netdev        0    0
  252  reboot(第一次重启须使用真机将其poweroff在start才可以重启开)
  255  vim /etc/rc.d/rc.local
     #mount //172.25.254.213/student /mnt/ -o username=student,password=student
  256  reboot

状况:
  251  vim /etc/fstab
     /dev/sda1       /mnt      xfs     defaults       0    0
    reboot不能开启
  进入选择页面按e
  选择linux16这行从末尾开始删除到ro改为rw rd.break
   ctrl+x
   chroot /sysroot
   vim /etc/fstab
  /dev/sda1       /mnt      xfs     defaults,_netdev        0    0
   exit
   exit

五、iscsi的删除
客户端:
  262  yum install tree -y
  263  tree /var/lib/iscsi
  264  df
  265  umount /mnt  
  266  vim /etc/fstab
删除     /dev/sda1       /mnt      xfs     defaults,_netdev        0    0
  267  fdisk -l
  268  iscsiadm  -m node -T iqn.2018-06.com.example:storage1 -p 172.25.254.213 -u
  269  iscsiadm  -m node -T iqn.2018-06.com.example:storage1 -p 172.25.254.213 -o delete
  270  tree /var/lib/iscsi/
  271  systemctl restart iscsi

  272  fdisk -l  (此时再重启服务设备也不会回来了)



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值