iscsi磁盘共享
来源:互联网 发布:和平电视直播软件 编辑:程序博客网 时间:2024/06/05 10:22
iscsi磁盘共享
1.服务端安装以及部署
[root@server ~]# fdisk /dev/vdb ##建立一个新分区
[root@server ~]# partprobe ##同步磁盘分区表
[root@server ~]# yum install targetcli ##安装软件
[root@server ~]# systemctl start target ##开启服务
[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 ##建立钥匙
/> /iscsi/iqn.2017-12.com.example:storage1/tpg1/luns create /backstores/block/westos:storage1 ##把钥匙给设备
/> iscsi/iqn.2017-12.com.example:storage1/tpg1/portals create 172.25.254.118 ##开启端口
/> exit
[root@server ~]# firewall-cmd --permanent --add-port=3260/tcp ##防火墙开启服务的端口
success
[root@server ~]# firewall-cmd --reload ##加载防火墙
[root@server ~]# partprobe ##同步磁盘分区表
[root@server ~]# yum install targetcli ##安装软件
[root@server ~]# systemctl start target ##开启服务
[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 ##建立钥匙
/> /iscsi/iqn.2017-12.com.example:storage1/tpg1/luns create /backstores/block/westos:storage1 ##把钥匙给设备
/> iscsi/iqn.2017-12.com.example:storage1/tpg1/portals create 172.25.254.118 ##开启端口
/> exit
[root@server ~]# firewall-cmd --permanent --add-port=3260/tcp ##防火墙开启服务的端口
success
[root@server ~]# firewall-cmd --reload ##加载防火墙
【示例】
2.客户端的使用:
[root@client ~]# hostnamectl set-hostname client.example.com
[root@client ~]# yum install iscsi-initiator-utils.x86_64 ##安装软件
[root@client ~]# systemctl start iscsi ##开启服务
[root@client ~]# vim /etc/iscsi/initiatorname.iscsi ##此文件编辑服务端的钥匙
InitiatorName=iqn.2017-12.com.example:westoskey
[root@client ~]# systemctl restart iscsi
[root@client ~]# iscsiadm -m discovery -t st -p 172.25.254.118 ##发现服务端的共享磁盘名称
[root@client ~]# iscsiadm -m node -T iqn.2017-12.com.example:storage1 -P 172.25.254.118 -l ##登录服务端的共享磁盘
[root@client ~]# fdisk -l ##查看磁盘
Disk /dev/sda: ##发现多出一个设备
[root@client ~]# fdisk /dev/sda ##以下就可以使用此磁盘
[root@client ~]# partprobe
[root@client ~]# mkfs.xfs /dev/sda1
[root@client ~]# mount /dev/sda1 /mnt ##设备挂载上就可以使用
[root@client ~]# df
[root@client ~]# cd /mnt,
[root@client mnt]# ls
【示例】
自动挂载
[root@client ~]# umount /mnt/ ##先卸载
[root@client ~]# blkid ##查看分区磁盘的id
[root@client ~]# vim /etc/fstab ##编辑自动挂载文件
UUID="a280c240-f167-47ee-a398-cd07f366978b" /mnt xfs defaults,_netdev 0 0 ##使用设备的UID挂载,_netdev开机时先启动网络配置再开启设备配置
[root@client ~]# mount -a ##刷新
[root@client ~]# df
测试时再次开机必须强制断电一次再开机
2.客户端的使用:
[root@client ~]# hostnamectl set-hostname client.example.com
[root@client ~]# yum install iscsi-initiator-utils.x86_64 ##安装软件
[root@client ~]# systemctl start iscsi ##开启服务
[root@client ~]# vim /etc/iscsi/initiatorname.iscsi ##此文件编辑服务端的钥匙
InitiatorName=iqn.2017-12.com.example:westoskey
[root@client ~]# systemctl restart iscsi
[root@client ~]# iscsiadm -m discovery -t st -p 172.25.254.118 ##发现服务端的共享磁盘名称
[root@client ~]# iscsiadm -m node -T iqn.2017-12.com.example:storage1 -P 172.25.254.118 -l ##登录服务端的共享磁盘
[root@client ~]# fdisk -l ##查看磁盘
Disk /dev/sda: ##发现多出一个设备
[root@client ~]# fdisk /dev/sda ##以下就可以使用此磁盘
[root@client ~]# partprobe
[root@client ~]# mkfs.xfs /dev/sda1
[root@client ~]# mount /dev/sda1 /mnt ##设备挂载上就可以使用
[root@client ~]# df
[root@client ~]# cd /mnt,
[root@client mnt]# ls
【示例】
自动挂载
[root@client ~]# umount /mnt/ ##先卸载
[root@client ~]# blkid ##查看分区磁盘的id
[root@client ~]# vim /etc/fstab ##编辑自动挂载文件
UUID="a280c240-f167-47ee-a398-cd07f366978b" /mnt xfs defaults,_netdev 0 0 ##使用设备的UID挂载,_netdev开机时先启动网络配置再开启设备配置
[root@client ~]# mount -a ##刷新
[root@client ~]# df
测试时再次开机必须强制断电一次再开机
【示例】
3.客户端退出
[root@client ~]# vim /etc/fstab ##把开机启动的设置删除
[root@client ~]# umount /mnt ##卸载
[root@client ~]# tree /var/lib/iscsi/ ##查看连接的共享设备的名称
[root@client ~]# iscsiadm -m node -T iqn.2017-12.com.example:storage1 -p 172.25.254.118 -u ##退出登陆
[root@client ~]# iscsiadm -m node -T iqn.2017-12.com.example:storage1 -p 172.25.254.118 -o delete
##删除
[root@client ~]# rm -fr /var/lib/iscsi/nodes/* ##有缓存文件需要手动删除
[root@client ~]# rm -fr /var/lib/iscsi/send_targets/*
[root@client ~]# rm -fr /var/lib/iscsi/send_targets/*
[root@client ~]# systemctl restart iscsi
【示例】
4.服务端删除共享
[root@server ~]# targetcli ##进入服务
/> clearconfig confirm=true ##输入命令
5.共享LVM可扩充磁盘分区
72 fdisk /dev/vdb ##建立分区
73 pvcreate /dev/vdb1 ##服务端配置共享分区
74 vgcreate iscisi_vg /dev/vdb1
75 lvcreate man
76 lvcreate
77 lvcreate -l 255 -n iscisi_lv0 iscisi_vg
[root@server ~]# targetcli ##以下操作跟上面第一节一样
/> /backstores/block create westos:storage1 /dev/iscisi_vg/iscisi_lv0
/> /iscsi create iqn.2017-12.com.example:storage1
/> /iscsi/iqn.2017-12.com.example:storage1/tpg1/acls create iqn.2017-12.com.example:key1
>/iscsi/iqn.2017-12.com.example:storage1/tpg1/luns create /backstores/block/westos:storage1
/> /iscsi/iqn.2017-12.com.example:storage1/tpg1/portals create 172.25.254.118
/> exit
[root@server ~]# pvcreate /dev/vdb2 ##扩充
[root@server ~]# vgextend iscisi_vg /dev/vdb2
[root@server ~]# lvextend -L 900M /dev/iscisi_vg/iscisi_lv0
[root@client ~]# vim /etc/iscsi/initiatorname.iscsi ##服务端的钥匙名称改变客户端同样更改
[root@client ~]# rm -fr /var/lib/iscsi/nodes/*
[root@client ~]# rm -fr /var/lib/iscsi/send_targets/*
[root@client ~]# systemctl restart iscsi.service
[root@client ~]# systemctl restart iscsi
[root@client ~]# systemctl restart iscsid ##服务端改变后,客户端需要退出再次登录
[root@client ~]# iscsiadm -m discovery -t st -p 172.25.254.118
172.25.254.118:3260,1 iqn.2017-12.com.example:storage1
[root@client ~]# iscsiadm -m node -T iqn.2017-12.com.example:storage1 -p 172.25.254.118 -l
【示例】
4.服务端删除共享
[root@server ~]# targetcli ##进入服务
/> clearconfig confirm=true ##输入命令
5.共享LVM可扩充磁盘分区
72 fdisk /dev/vdb ##建立分区
73 pvcreate /dev/vdb1 ##服务端配置共享分区
74 vgcreate iscisi_vg /dev/vdb1
75 lvcreate man
76 lvcreate
77 lvcreate -l 255 -n iscisi_lv0 iscisi_vg
[root@server ~]# targetcli ##以下操作跟上面第一节一样
/> /backstores/block create westos:storage1 /dev/iscisi_vg/iscisi_lv0
/> /iscsi create iqn.2017-12.com.example:storage1
/> /iscsi/iqn.2017-12.com.example:storage1/tpg1/acls create iqn.2017-12.com.example:key1
>/iscsi/iqn.2017-12.com.example:storage1/tpg1/luns create /backstores/block/westos:storage1
/> /iscsi/iqn.2017-12.com.example:storage1/tpg1/portals create 172.25.254.118
/> exit
[root@server ~]# pvcreate /dev/vdb2 ##扩充
[root@server ~]# vgextend iscisi_vg /dev/vdb2
[root@server ~]# lvextend -L 900M /dev/iscisi_vg/iscisi_lv0
[root@client ~]# vim /etc/iscsi/initiatorname.iscsi ##服务端的钥匙名称改变客户端同样更改
[root@client ~]# rm -fr /var/lib/iscsi/nodes/*
[root@client ~]# rm -fr /var/lib/iscsi/send_targets/*
[root@client ~]# systemctl restart iscsi.service
[root@client ~]# systemctl restart iscsi
[root@client ~]# systemctl restart iscsid ##服务端改变后,客户端需要退出再次登录
[root@client ~]# iscsiadm -m discovery -t st -p 172.25.254.118
172.25.254.118:3260,1 iqn.2017-12.com.example:storage1
[root@client ~]# iscsiadm -m node -T iqn.2017-12.com.example:storage1 -p 172.25.254.118 -l
【示例】
阅读全文
0 0
- iSCSI 网络磁盘共享
- iscsi(共享磁盘)
- iscsi磁盘共享服务
- ISCSI(磁盘共享)
- iscsi磁盘共享扩展
- iscsi网络磁盘共享
- 磁盘共享之ISCSI
- iscsi磁盘共享
- iscsi磁盘共享
- 磁盘共享-ISCSI
- iscsi磁盘共享
- iscsi用gfs2文件系统实现磁盘共享
- SMB服务器和ISCSI磁盘共享
- Windows Server 2012 iSCSI共享磁盘搭建
- Linux中的磁盘共享---NFS与ISCSI
- linux磁盘共享nfs及iscsi
- ISCSI实现磁盘网络共享以及LVM方式共享拓展
- iscsi target 如何设置对多个磁盘的共享
- 由 官场微小说:两个县长的命运 所想
- CentOS6.4 Ftp服务器远程主机关闭连接问题
- TensorFlow笔记:数据导出
- 正则表达式知识
- QTCpSocket文件传输
- iscsi磁盘共享
- Comparator 升序降序
- matlab基础——LinePlots and Subplots
- IT的道德与伦理
- MySQL的auto_increment功能
- leetcode题解-25. Reverse Nodes in k-Group
- 用HTML前端技术做一个登入了界面+一些小技巧
- 测试工作---手动测试
- 工厂模式