您好,登錄后才能下訂單哦!
iSCSI (Internet Small Computer System Interface),這種將scsi節后與以太網技術相結合的新型存儲技術,可以用來在網絡中傳輸scsi節后的命令和數據,使得用戶可以通過互聯網方便地訪問遠程機提供的共享存儲資源。
使用raid,可以保證服務器端提供存儲資源的穩定性和可用性,這里使用raid5。
# 創建md0
[root@localhost Desktop]# mdadm -Cv /dev/md0 -n 3 -l 5 -x 1 /dev/sd[b-e]
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 512K
mdadm: size set to 5238272K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
# 查看md0狀態
[root@localhost Desktop]# mdadm -D /dev/md0
......
Layout : left-symmetric
Chunk Size : 512K
Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : 9e7dc640:37bde867:d3926c0f:0565156e
Events : 20
Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 8 32 1 active sync /dev/sdc
4 8 48 2 active sync /dev/sdd
3 8 64 - spare /dev/sde
主機 | 系統 | ip |
---|---|---|
服務端 | rhel 7 | 192.168.137.10 |
# 安裝
[root@localhost Desktop]# yum install targetd targetcli -y
# 啟動,設置開機自啟動
[root@localhost Desktop]# systemctl restart targetd
[root@localhost Desktop]# systemctl enable targetd
ln -s '/usr/lib/systemd/system/targetd.service' '/etc/systemd/system/multi-user.target.wants/targetd.service'
使用targetcli命令管理iscsi的配置,它提供了一個交互式的配置界面,類似fdisk命令
# 執行targetcli進入配置界面
[root@localhost Desktop]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
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 目錄,將創建的md0添加到共享設備的“資源池”中,將文件重新命名為disk0
/> cd /backstores/block
/backstores/block> create disk0 /dev/md0
Created block storage object disk0 using /dev/md0.
/backstores/block> cd /
/> ls
o- / ..................................................................... [...]
o- backstores .......................................................... [...]
| o- block .............................................. [Storage Objects: 1]
| | o- disk0 ..................... [/dev/md0 (10.0GiB) write-thru deactivated]
| o- fileio ............................................. [Storage Objects: 0]
| o- pscsi .............................................. [Storage Objects: 0]
| o- ramdisk ............................................ [Storage Objects: 0]
o- iscsi ........................................................ [Targets: 0]
o- loopback ..................................................... [Targets: 0]
/>
iscsi target名稱是由系統自動生成的,這是一串用于描述共享資源的唯一字符串,用戶在掃描iscsi服務端時會顯示這個target名稱。
# 進入到/iscsi目錄下,生成target名稱,同時會創建一個同名的“目錄”,來存放共享資源
/> cd iscsi
/iscsi> create
Created target iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.b7056110e01d.
Created TPG 1.
/iscsi> ls
o- iscsi ................................................ [Targets: 1]
o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.b7056110e01d [TPGs: 1]
o- tpg1 ................................... [no-gen-acls, no-auth]
o- acls .............................................. [ACLs: 0]
o- luns .............................................. [LUNs: 0]
o- portals ........................................ [Portals: 0]
/iscsi>
# 進入到新創建的目錄中,將disk0添加到這個新目錄
/iscsi> cd iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.b7056110e01d/tpg1/luns
/iscsi/iqn.20...01d/tpg1/luns> create /backstores/block/disk0
Created LUN 0.
iscsi協議是通過客戶端名稱進行驗證的,用戶在訪問存儲共享資源是不需要輸入密碼,只要iscsi客戶端的名稱與服務端中設置的訪問控制列表中某一名稱條目一致即可。acls參數目錄用于存放能夠訪問iscsi服務端共享存儲資源的客戶端名稱。
# 在iscsi服務端的配置文件中寫入一串能夠驗證用戶信息的名稱,這里使用target名稱,加上:client,這個是自己定義的字符串,具有唯一性即可
/iscsi/iqn.20...01d/tpg1/luns> cd ..
/iscsi/iqn.20...6110e01d/tpg1> cd acls
/iscsi/iqn.20...01d/tpg1/acls> create iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.b7056110e01d:client
Created Node ACL for iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.b7056110e01d:client
Created mapped LUN 0.
/iscsi/iqn.20...01d/tpg1/acls>
/iscsi/iqn.20...01d/tpg1/acls> cd ..
/iscsi/iqn.20...6110e01d/tpg1> cd portals
/iscsi/iqn.20.../tpg1/portals> create 192.168.137.10
Using default IP port 3260
Created network portal 192.168.137.10:3260.
/iscsi/iqn.20.../tpg1/portals> ls /
o- / ........................................................... [...]
o- backstores ................................................ [...]
| o- block .................................... [Storage Objects: 1]
| | o- disk0 ............. [/dev/md0 (10.0GiB) write-thru activated]
| o- fileio ................................... [Storage Objects: 0]
| o- pscsi .................................... [Storage Objects: 0]
| o- ramdisk .................................. [Storage Objects: 0]
o- iscsi .............................................. [Targets: 1]
| o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.b7056110e01d [TPGs: 1]
| o- tpg1 ................................. [no-gen-acls, no-auth]
| o- acls ............................................ [ACLs: 1]
| | o- iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.b7056110e01d:client [Mapped LUNs: 1]
| | o- mapped_lun0 ................... [lun0 block/disk0 (rw)]
| o- luns ............................................ [LUNs: 1]
| | o- lun0 ........................... [block/disk0 (/dev/md0)]
| o- portals ...................................... [Portals: 1]
| o- 192.168.137.10:3260 ................................ [OK]
o- loopback ........................................... [Targets: 0]
/iscsi/iqn.20.../tpg1/portals> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
[root@localhost Desktop]# systemctl restart targetd
[root@localhost Desktop]# firewall-cmd --permanent --add-port=3260/tcp
success
[root@localhost Desktop]# firewall-cmd --reload
success
iscsi服務器端配置完成。
[root@localhost Desktop]# yum install iscsi-initiator-utils -y
編輯客戶端中的initiator名稱文件,把服務器端的訪問控制列表名稱填寫進來(服務器端acls目錄中自定義的名稱),重啟服務。
[root@localhost Desktop]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName= iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.b7056110e01d:client
[root@localhost Desktop]# systemctl restart iscsid
[root@localhost Desktop]# systemctl enable iscsid
口訣“先發現,在登陸,最后掛載并使用”。
iscsiadm 用于管理、查詢、插入、更新或刪除iscsi數據庫配置文件的工具。
[root@localhost Desktop]# iscsiadm -m discovery -t st -p 192.168.137.10
192.168.137.10:3260,1 iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.b7056110e01d
使用iscsiadm命令
[root@localhost Desktop]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.b7056110e01d -p 192.168.137.10 --login
......
successful
登錄成功后,會在客戶端多出一塊存儲設備/dev/sdb(設備名可能不同),現在就可以對新設備進行分區,掛載使用了。
使用iscsiadm -u 將設備卸載
[root@localhost Desktop]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.b7056110e01d -p 192.168.137.10 -u
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。