ISCSI:
配置iscsi
[root@server ~]# yum install targetcli -y
[root@server ~]# systemctl start target
[root@server ~]# fdisk /dev/vdb
[root@server ~]# partprobe
[root@server ~]# targetcli
/> /backstores/block create westos:storage1 /dev/vdb1 給裝置一個新的名字
/> /iscsi create iqn.2017-12.com.example:storage1 建立共享名稱
/> /iscsi/iqn.2017-12.com.example:storage1/tpg1/acls create iqn.2017-12.com.example:westoskey 建立key
/> /iscsi/iqn.2017-12.com.example:storage1/tpg1/luns create /backstores/block/westos:storage1 關聯通路(/dev/vdb1)
/> /iscsi/iqn.2017-12.com.example:storage1/tpg1/portals create 172.25.254.117 端口指定提供服務其的IP
設定完成後應為此
/> exit 退出
[root@server ~]# firewall-cmd --permanent --add-port=3260/tcp 火牆中加入此端口
[root@server ~]# systemctl restart target.service
(服務端)
[root@client ~]# yum install iscsi-initiator-utils.x86_64 -y
[root@client ~]# systemctl start iscsi
[root@client ~]# vim /etc/iscsi/initiatorname.iscsi 寫入鑰匙
[root@client ~]# systemctl restart iscsi
登陸(-m (mode)執行動作 node連接配接 -T目标 -p(IP) -l登陸)
[root@client ~]# fdisk -l 檢視硬碟添加成功
[root@client ~]# fdisk /dev/sda 建立分區
[root@client~]#mount /dev/sda 1 /mnt
[root@client ~]# touch /mnt/file
此檔案建立建立在主機server的/dev/vdb1中
(伺服器)
[root@server ~]# mount /dev/vdb1 /mnt/
mount:/dev/vdb1 is already mounted or /mnt busy 已經挂載
*永久挂載
[root@client ~]# vim /etc/fstab
為了避免名稱漂移,可将/dev/sda1改為絕對路徑
[root@client ~]# blkid
*删除
[root@client ~]# yum install tree -y
用來檢視結構的工具
[root@client ~]# umount /mnt/
[root@client ~]# iscsiadm -m node -T iqn.2017-12.com.example:storagel -p 172.25.254.117 -u 退出登陸
[root@client ~]# iscsiadm -m node -T iqn.2017-12.com.example:storagel -p 172.25.254.117 -p delete 删除使用者
[root@client ~]# systemctl restart iscsi
[root@client ~]# fdisk -l 裝置消失
[root@client ~]# tree /var/lib/iscsi
清除服務端的政策
/>clearconfig confirm=ture
LVM
lvm的建立
[root@server ~]# pvcreate /dev/vdb1
[root@server ~]# vgcreate iscsi_vg /dev/vdb1建立iscsi_vg
[root@server ~]# lvcreate -l 255 -n iscsi_lv0 iscsi_vg 建立iscsi_lv0
[root@server ~]# targetcli (和之前的相似)
(用戶端)
[root@client ~]# vim /etc/iscsi/initiatorname.iscsi 寫入鑰匙
[root@client ~]# iscsi -m discovery -t st -p 172.25.254.117
[root@client ~]# iscsiadm -m node -T iqn.2017-12.com.example:storagel -p 172.25.254.117 -l (登陸失敗)
[root@client ~]# tree /var/lib/iscsi/ 檢視是否完全删除
[root@client ~]# systemctl restart iscsid
再次登陸
Lvm的擴充
(服務端)
[root@server ~]# fdisk /dev/vdb 建立lvm分區
[root@server ~]# partprobe
[root@server ~]# pvcreate /dev/vdb2
[root@server ~]# vgextend iscsi_vg /dev/vdb2
[root@server ~]# lvextend -L 1500M /dev/iscsi_vg/iscsi_lv0
[root@client ~]# fdisk -l
(先退出再登陸)
[root@client ~]# iscsiadm -m node -T iqn.2017-12.com.example:storagel -p 172.25.254.117 -u
[root@client ~]# iscsiadm -m node -T iqn.2017-12.com.example:storagel -p 172.25.254.117 -l
本文轉自 無緣 51CTO部落格,原文連結:http://blog.51cto.com/13352594/2051149