没有未分配空间的centos7上如何模拟出sdb

Posted 鸟瞰的鸟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了没有未分配空间的centos7上如何模拟出sdb相关的知识,希望对你有一定的参考价值。

1。起因

有两台服务器分别安装部署了openstack的管理节点和计算节点,现在想给win7实例额外挂载E盘。

两台服务器安装系统时都是在配置完boot、swap和root后,将所有剩余磁盘空间分配给了home。因此没有剩余空间创建sdb。

2。解决方案

控制节点上部署cinder,并部署iscsi target,模拟出sdb;

计算节点上安装LVM作为存储节点给cinder用,计算节点挂载控制节点上模拟出的sdb;

这样dashboard上就能创建卷创建云盘,给win7实例当作E盘使用了。

cinder和LVM的安装部署见另一个随笔。本次只描述控制节点上如何部署iscsi target。

3。详细过程

a)安装:[[email protected] ~]# yum install targetcli

b)新建文件夹:[[email protected] ~]# mkdir /home/targetdisk

c)运行targetcli,依次执行如下命令创建iSCSI块设备:

  [[email protected] ~]# targetcli

  /> cd backstores/fileio/

  /backstores/fileio> create disk01 /home/targetdisk/disk01 40G

  /backstores/fileio> create disk02 /home/targetdisk/disk02 40G

此时进入/home/targetdisk,就能看到两个大小都是40G的文件,disk01和disk02

(补充说明:如果如前面所述安装系统时有未分配的磁盘空间作为sdb,那么本步骤就不是进入fileio,而是进入block,然后用这个命令来创建块:create block01 /dev/sdb

d)创建LIO iSCSI目标:

  /> cd iscsi 

  /iscsi> create
  Created target iqn.2003-01.org.linux-iscsi.controller.x8664:sn.f9144284c7ca.
  Created TPG 1.
  Global pref auto_add_default_portal=true
  Created default portal listening on all IPs (0.0.0.0), port 3260.
  /iscsi>

e)创建逻辑单元:

  /iscsi> cd iqn.2003-01.org.linux-iscsi.controller.x8664:sn.f9144284c7ca/

  /iscsi/iqn.20....f9144284c7ca> cd tpg1/luns

  /iscsi/iqn.20...7ca/tpg1/luns> create /backstores/fileio/disk01

  Created LUN 0.

  /iscsi/iqn.20...7ca/tpg1/luns> create /backstores/fileio/disk02

  Created LUN 1.

f)创建网络入口:

  /iscsi/iqn.20.../tpg1/portals> create 10.47.181.26

  Using default IP port 3260
  Could not create NetworkPortal in configFS
  /iscsi/iqn.20.../tpg1/portals> ls
  o- portals ............................................................................................................ [Portals: 1]
  o- 0.0.0.0:3260 ............................................................................................................. [OK]

  /iscsi/iqn.20.../tpg1/portals> delete 0.0.0.0 3260
  Deleted network portal 0.0.0.0:3260
  /iscsi/iqn.20.../tpg1/portals> create 10.47.181.26
  Using default IP port 3260
  Created network portal 10.47.181.26:3260.

g)创建访问控制列表:

  /iscsi/iqn.20.../tpg1/portals> cd ../acls
  /iscsi/iqn.20...7ca/tpg1/acls> ls
  o- acls .................................................................................................................. [ACLs: 0]
  /iscsi/iqn.20...7ca/tpg1/acls> create iqn.1994-05.com.redhat:91a579c4e39 (create后面的内容为何是这样的还不清楚,后面再研究)
  Created Node ACL for iqn.1994-05.com.redhat:91a579c4e39
  Created mapped LUN 1.
  Created mapped LUN 0.

h)完成目标创建:

  /> ls
  o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 0]
  | o- fileio ................................................................................................. [Storage Objects: 2]
  | | o- disk01 ........................................................... [/home/targetdisk/disk01 (40.0GiB) write-back  activated]
  | | | o- alua ................................................................................................... [ALUA Groups: 1]
  | | | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
  | | o- disk02 ........................................................... [/home/targetdisk/disk02 (40.0GiB) write-back activated]
  | | o- alua ................................................................................................... [ALUA Groups: 1]
  | | o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
  | o- pscsi .................................................................................................. [Storage Objects: 0]
  | o- ramdisk ................................................................................................ [Storage Objects: 0]
  o- iscsi ............................................................................................................ [Targets: 1]
  | o- iqn.2003-01.org.linux-iscsi.controller.x8664:sn.f9144284c7ca ...................................................... [TPGs: 1]
  | o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
  | o- acls .......................................................................................................... [ACLs: 1]
  | | o- iqn.1994-05.com.redhat:91a579c4e39 ................................................................... [Mapped  LUNs: 2]
  | | o- mapped_lun0 ............................................................................... [lun0 fileio/disk01 (rw)]
  | | o- mapped_lun1 ............................................................................... [lun1 fileio/disk02 (rw)]
  | o- luns .......................................................................................................... [LUNs: 2]
  | | o- lun0 ..................................................... [fileio/disk01 (/home/targetdisk/disk01) (default_tg_pt_gp)]
  | | o- lun1 ..................................................... [fileio/disk02 (/home/targetdisk/disk02) (default_tg_pt_gp)]
  | o- portals .................................................................................................... [Portals: 1]
  | o- 10.47.181.26:3260 ................................................................................................ [OK]
  o- loopback ......................................................................................................... [Targets: 0]

i)设置认证凭证:

  /> cd iscsi/
  /iscsi> cd iqn.2003-01.org.linux-iscsi.controller.x8664:sn.f9144284c7ca/
  /iscsi/iqn.20....f9144284c7ca> cd tpg1/
  /iscsi/iqn.20...4284c7ca/tpg1> cd acls/iqn.1994-05.com.redhat:91a579c4e39/
  /iscsi/iqn.20...t:91a579c4e39> set auth userid=IncomingUser
  Parameter userid is now ‘IncomingUser‘.
  /iscsi/iqn.20...t:91a579c4e39> set auth password=SomePassword
  Parameter password is now ‘SomePassword‘.
  /iscsi/iqn.20...t:91a579c4e39> set auth mutual_userid=OutgoingUser
  Parameter mutual_userid is now ‘OutgoingUser‘.
  /iscsi/iqn.20...t:91a579c4e39> set auth mutual_password=AnotherPassword
  Parameter mutual_password is now ‘AnotherPassword‘.

下面开始配置计算节点(即合一的存储节点)

a)配置:[[email protected] ~]# vi /etc/iscsi/iscsid.conf

  node.session.auth.authmethod = CHAP
  node.session.auth.username = IncomingUser
  node.session.auth.password = SomePassword
  node.session.auth.username_in = OutgoingUser
  node.session.auth.password_in = AnotherPassword

 






























































以上是关于没有未分配空间的centos7上如何模拟出sdb的主要内容,如果未能解决你的问题,请参考以下文章

Docker镜像分层存储与镜像精简

请教wpf中的用户控件,如何模拟出它的close事件

Linux环境搭建-在虚拟机中安装Centos7.0

ubuntu12.04如何给未分配空间创建新分区并且挂载上呢?

磁盘上没有足够的空间完成此操作

CentOS7扩展根目录