您好,登錄后才能下訂單哦!
iSCSI (Internet Small Computer System Interface),這種將scsi節(jié)后與以太網(wǎng)技術(shù)相結(jié)合的新型存儲(chǔ)技術(shù),可以用來(lái)在網(wǎng)絡(luò)中傳輸scsi節(jié)后的命令和數(shù)據(jù),使得用戶可以通過互聯(lián)網(wǎng)方便地訪問遠(yuǎn)程機(jī)提供的共享存儲(chǔ)資源。
使用raid,可以保證服務(wù)器端提供存儲(chǔ)資源的穩(wěn)定性和可用性,這里使用raid5。
# 創(chuàng)建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狀態(tài)
[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
主機(jī) | 系統(tǒng) | ip |
---|---|---|
服務(wù)端 | rhel 7 | 192.168.137.10 |
# 安裝
[root@localhost Desktop]# yum install targetd targetcli -y
# 啟動(dòng),設(shè)置開機(jī)自啟動(dòng)
[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的配置,它提供了一個(gè)交互式的配置界面,類似fdisk命令
# 執(zhí)行targetcli進(jìn)入配置界面
[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]
/>
#進(jìn)入到 /backstores/block 目錄,將創(chuàng)建的md0添加到共享設(shè)備的“資源池”中,將文件重新命名為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名稱是由系統(tǒng)自動(dòng)生成的,這是一串用于描述共享資源的唯一字符串,用戶在掃描iscsi服務(wù)端時(shí)會(huì)顯示這個(gè)target名稱。
# 進(jìn)入到/iscsi目錄下,生成target名稱,同時(shí)會(huì)創(chuàng)建一個(gè)同名的“目錄”,來(lái)存放共享資源
/> 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>
# 進(jìn)入到新創(chuàng)建的目錄中,將disk0添加到這個(gè)新目錄
/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協(xié)議是通過客戶端名稱進(jìn)行驗(yàn)證的,用戶在訪問存儲(chǔ)共享資源是不需要輸入密碼,只要iscsi客戶端的名稱與服務(wù)端中設(shè)置的訪問控制列表中某一名稱條目一致即可。acls參數(shù)目錄用于存放能夠訪問iscsi服務(wù)端共享存儲(chǔ)資源的客戶端名稱。
# 在iscsi服務(wù)端的配置文件中寫入一串能夠驗(yàn)證用戶信息的名稱,這里使用target名稱,加上:client,這個(gè)是自己定義的字符串,具有唯一性即可
/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服務(wù)器端配置完成。
[root@localhost Desktop]# yum install iscsi-initiator-utils -y
編輯客戶端中的initiator名稱文件,把服務(wù)器端的訪問控制列表名稱填寫進(jìn)來(lái)(服務(wù)器端acls目錄中自定義的名稱),重啟服務(wù)。
[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
口訣“先發(fā)現(xiàn),在登陸,最后掛載并使用”。
iscsiadm 用于管理、查詢、插入、更新或刪除iscsi數(shù)據(jù)庫(kù)配置文件的工具。
[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
登錄成功后,會(huì)在客戶端多出一塊存儲(chǔ)設(shè)備/dev/sdb(設(shè)備名可能不同),現(xiàn)在就可以對(duì)新設(shè)備進(jìn)行分區(qū),掛載使用了。
使用iscsiadm -u 將設(shè)備卸載
[root@localhost Desktop]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.b7056110e01d -p 192.168.137.10 -u
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。