1
服务端:
# mkdir /data
# exportfs -ar
客户端
# mkdir /date
# mount 192.168.1.3:/data /date/
验证是客户端设置的是只读文件
2
添加一块新硬盘(10G)
装包
[root@localhost ~]# yum install targetd targetcli -y
[root@localhost ~]# systemctl restart target
配置iscsi服务端共享资源
[root@localhost ~]# targetcli
Backstore准备目录通过iscsi共享
/> cd backstores/block
将分区加入共享资源池中,并重新命名(两种方式)
- /backstores/block> create dev=/dev/sdb name=lun0或者
2
图表 1将分区加入共享资源池中,并重新命名
创建iscsi target名称(自动生成)及配置共享资源
/iscsi> cd iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.114bdcd2c613/
/iscsi/iqn.20...65e93cc5/tpg1> set attribute authentication=0 demo_mode_write_protect=0 cache_dynamic_acls=1 generate_node_acls=1
/iscsi/iqn.20...65e93cc5/tpg1> cd luns
将前面创建的字符串同名的存放资源的目录加入新目录
/iscsi/iqn.20...613/tpg1/luns> create /backstores/block/lun0
设置iscsi服务端的监听IP地址和端口号
cd portals
/iscsi/iqn.20.../tpg1/portals> create 192.168.2.3 3260
Exit
重启服务端使配置生效
[root@localhost ~]# systemctl restart target
客户端:
默认已经安装了initiator服务程序
发现,登录
[root@localhost ~]# fdisk -l
挂载使用
[root@localhost ~]# mkdir /iscsi
[root@localhost ~]# mount -a
3
这里先用nfs做了文件共享,即把家目录下的haha和xixixi用户共享给客户机,并用autofs自动挂载,感觉我做复杂了(省略)
Samba的多用户配置就这些
客户端:192.168.2.3
# setenforce 0
# yum install samba\* -y
# cat /etc/samba/smb.conf.bak | grep -v "#" | grep -v ";" | grep -v "^$" > /etc/samba/smb.conf
[root@localhost ~]# vim /etc/samba/smb.conf
添加samba用户
# smbpasswd -a xixixi
# smbpasswd -a haha
为haha设置特殊权限
# setfacl -m u:haha:rwx /devops/
# systemctl restart smb nmb
# vim /devops
客户端:192.168.2.2
# setenforce 0
# yum install cifs* -y
设置开机自动挂载
# mount -a
测试
服务器端