ISCSI:
(iSCSI:InternetSmallComputerSystemInterface) Internet小型計算機系統接口
iscsi 是一個供硬件設備使用的可以在IP協議的上層運行的SCSI指令集,這種指令集合可以實現在IP網絡上運行SCSI協議,使其能夠在諸如高速千兆以太網上進行路由選擇。iSCSI技術是一種新儲存技術,該技術是將現有SCSI接口與以太網絡(Ethernet)技術結合,使服務器可與使用IP網絡的儲存裝置互相交換資料。
配置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 ~]# vim /etc/fstab
*刪除
[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 ~]# systemctl restart 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
[root@client ~]# systemctl restart iscsi
再次登陸
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
[root@client ~]# fdisk -l