沒有未分配空間的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