日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux——ISCSI 网络磁盘共享

發布時間:2025/3/19 linux 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux——ISCSI 网络磁盘共享 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ISCSI

ISCSI技術實現了物理硬盤設備與TCP/TP網絡傳輸協議的相互結合,使得用戶可以通過互聯網方便的獲取到遠程機房提供的共享存儲資源

  • ISCSI target:就是儲存設備端,存放磁盤或 RAID 的設備,目前也能夠將 Linux 主機仿真成 iSCSI target 了!目的在提供其他主機使用的『磁盤』
  • ISCSI initiator:就是能夠使用 target 的客戶端,通常是服務器。 也就是說,想要連接到 iSCSI target 的服務器,也必須要安裝 iSCSI initiator 的相關功能后才能夠使用 iSCSI target 提供的磁盤就是了

一、軟件安裝(客戶端、服務端)

  • yum install targetcli -y——服務端軟件安裝
  • yum install iscsi-initiator-utils -y——客戶端軟件安裝

二、服務端配置

  • 劃分出一塊2G的磁盤

[root@server ~]# systemctl start target [root@server ~]# systemctl enable target [root@server ~]#
  • 建立一個塊存儲
    westos:storage1(名稱westos:storage1可自定義),/dev/sdb1為上面新建的分區名稱
/backstores/block create westos:storage1 /dev/vdb1
  • 配置ISCSITarget命名
    命名在同一子網內確保是唯一的,命名格式為:iqn.yyyy-mm.<主機名反寫>:自定義名稱(自定義名稱內不能有下劃線)
/iscsi create iqn.2018-06.com.example:storage1
  • 創建ACL允許ISCSI客戶機連接
    iqn.2018-06.com.example:storage1為客戶機ISCSI名稱
/iscsi/iqn.2018-06.com.example:storage1/tpg1/acls create iqn.2018-06.com.example:westoskey
  • 創建lun(target塊設備的邏輯單元)
/iscsi/iqn.2018-06.com.example:storage1/tpg1/luns create /backstores/block/westos:storage1
  • 創建ip與端口
/iscsi/iqn.2018-06.com.example:storage1/tpg1/portals create 172.25.254.227


  • 查看配置信息,并退出
ls exit

三、客戶端配置

  • 查看硬盤信息

  • 啟動服務

[root@client ~]# systemctl start iscsi
  • 配置客戶端名稱
[root@client ~]# vim /etc/iscsi/initiatorname.iscsi [root@client ~]# cat /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.2018-06.com.example:westoskey
  • 發現設備以及登陸設備
[root@client ~]# iscsiadm -m discovery -t st -p 172.25.254.227 [root@client ~]# iscsiadm -m node -T iqn.2018-06.com.example:storage1 -p 172.25.254.227 -l ##登入節點,其中iqn.2018-06.com.example:storage1是目標名


注意:第一次登陸失敗后,修改后需先重啟主服務再啟子服務

[root@client ~]# systemctl restart iscsid [root@client ~]# systemctl restart iscsi
  • 查看硬盤信息
    硬盤 /dev/sda ——網絡共享的磁盤
  • 分區劃分

  • 系統文件掛載之手動掛載

[root@client ~]# mkfs.xfs /dev/sda1 [root@client ~]# df [root@client ~]# mount /dev/sda1 /mnt/ [root@client ~]# df [root@client ~]# umount /mnt



  • 系統文件掛載之開機自動掛載
  • 方法一

defaults,_netdev ,這是為了在啟動時讓網絡在分區前啟動,否則會啟動不起來

[root@client ~]# vim /etc/fstab [root@client ~]# cat /etc/fstab | tail -n 1 /dev/sda1 /mnt xfs defaults,_netdev 0 0 [root@client ~]# reboot [root@client ~]# df

  • 方法二
    將 defaults,_netdev 改為 defaults 后,啟動不起來的挽救方法
[root@client ~]# vim /etc/fstab [root@client ~]# cat /etc/fstab | tail -n 1 /dev/sda1 /mnt xfs defaults 0 0 [root@client ~]# reboot Connection to 172.25.254.127 closed by remote host. Connection to 172.25.254.127 closed. [kiosk@foundation50 Desktop]$ rht-vmctl view desktop

[kiosk@foundation50 Desktop]$ rht-vmctl poweroff desktop Powering off desktop.. [kiosk@foundation50 Desktop]$ rht-vmctl start desktop Starting desktop. [kiosk@foundation50 Desktop]$ rht-vmctl view desktop


出現上界面時,按 e 鍵 —> 如下圖修改(倒數第5行:rw rd.break) —> ctrl + x

啟動后,進入下面的模式,執行 chroot /sysroot/ —> vim /etc/fstab(進入后,編輯如圖) —> exit —> exit


[root@client ~]# df

  • 系統文件卸載
[root@client ~]# umount /mnt/ [root@client ~]# vim /etc/fstab ##刪除最后一行 [root@client ~]# yum install tree -y ##安裝樹形工具 [root@client ~]# tree /var/lib/iscsi/

查看目錄樹結構

[root@client ~]# fdisk -l

[root@client ~]# iscsiadm -m node -T iqn.2018-06.com.example:storage1 -p 172.25.254.227 -u ##退出節點, [root@client ~]# fdisk -l ##/dev/sda 不存在了

[root@client ~]# tree /var/lib/iscsi/

查看目錄樹結構,關于共享磁盤的信息還存在

[root@client ~]# systemctl restart iscsi [root@client ~]# fdisk -l ##因為只是退出登陸,沒有將相關文件刪除,所以重啟服務后,/dev/sda仍然存在

[root@client ~]# iscsiadm -m node -T iqn.2018-06.com.example:storage1 -p 172.25.254.227 -u [root@client ~]# iscsiadm -m node -T iqn.2018-06.com.example:storage1 -p 172.25.254.227 -o delete ##退出登陸后,刪除相關文件 [root@client ~]# tree /var/lib/iscsi/

[root@client ~]# systemctl restart iscsi [root@client ~]# fdisk -l ##退出登陸后,已經將相關文件刪除,所以重啟服務后,/dev/sda不會存在了

總結

以上是生活随笔為你收集整理的linux——ISCSI 网络磁盘共享的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。