#
访问网络文件系统
#
cifs网络文件系统访问
1.安装共享访问客户端
yum install samba-client -y
2.识别共享服务器共享目录
smbclient -L //172.25.254.250
[root@localhost ~]# smbclient -L //172.25.254.250/westos1
Enter root’s password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]
Sharename Type Comment
--------- ---- -------
westos1 Disk test share
westos2 Disk test share
westos3 Disk test share
westos4 Disk test share
westos5 Disk test share
westos6 Disk test share
westos7 Disk test share
westos8 Disk test share
westos9 Disk test share
westos10 Disk test share
IPC$ IPC IPC Service (Samba Server Version 4.1.1)
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]
Server Comment
--------- -------
Workgroup Master
--------- -------
3.访问共享
命令访问)
[root@netfsclient mnt]# smbclient //172.25.254.253/westos
Enter root’s password:
Domain=[USER-20161030DE] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
smb: >
挂载访问)
mount //172.25.254.253/westos /mnt -o username=guest
[root@localhost ~]# mount //172.25.254.250/westos1 /mnt/ -o username=guest
[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
4.开机自动挂载cifs
方法1)
vim /etc/fstab
//172.25.254.253/westos /mnt cifs defaults,username=guest 0 0
方法2)
vim /etc/rc.d/rc.local
mount //172.25.254.253/westos /mnt -o username=guest
[root@localhost mnt]# chmod +x /etc/rc.d/rc.local
nfs网络文件系统的访问
1.安装访问共享软件
yum install nfs-utils -y
2.识别共享
showmount -e 172.25.254.250
[root@localhost mnt]# showmount -e 172.25.254.250
Export list for 172.25.254.250:
/nfsshare/nfs5 *
/nfsshare/nfs4 *
/nfsshare/nfs3 *
/nfsshare/nfs2 *
/nfsshare/nfs1 *
/content 172.25.0.0/255.255.0.0
3.使用共享
mount 172.25.254.250:/nfsshare/nfs1 /mnt
[root@localhost mnt]# mount 172.25.254.250:/nfsshare/nfs1 /mnt/
4.自动挂载
方法1)
vim /etc/fstab
172.25.254.250:/nfsshare/nfs1 /mnt nfs defaults 0 0
方法2)
vim /etc/rc.d/rc.local
mount 172.25.25.250:/nfsshare/nfs1 /mnt
chmod 755 /etc/rc.d/rc.local
[root@localhost mnt]# chmod +x /etc/rc.d/rc.local
autofs自动挂载服务
1.服务功能
默认使用mount挂载共享时当不使用共享也会处于挂载状态
浪费共享服务器资源
autofs可以实现当使用时自动挂载,当闲置时自动卸载
2.安装服务
yum install autofs -y
systemctl start autofs
3.访问
cd /net/172.25.254.250/nfsshare/nfs1
root@localhost ~]# systemctl start autofs
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 8709120 4968948 3740172 58% /
devtmpfs 498984 0 498984 0% /dev
tmpfs 508456 0 508456 0% /dev/shm
tmpfs 508456 6744 501712 2% /run
tmpfs 508456 0 508456 0% /sys/fs/cgroup
/dev/sda1 201388 105240 96148 53% /boot
tmpfs 101692 0 101692 0% /run/user/0
//172.25.254.250/westos1 100221952 70270976 29950976 71% /mnt
172.25.254.250:/nfsshare/nfs1 100221952 70270976 29950976 71% /mnt
[root@localhost ~]# cd /net/
[root@localhost net]# ls
[root@localhost net]# cd 172.25.254.250
[root@localhost 172.25.254.250]# ls
content nfsshare
[root@localhost 172.25.254.250]# cd nfsshare/
[root@localhost nfsshare]# ls
nfs1 nfs2 nfs3 nfs4 nfs5
[root@localhost nfsshare]# cd nfs1/
4.设定空闲卸载时间
vim /etc/autofs.conf
15 timeout = 3 ##闲置3秒后系统自动卸载网络设备
5.实现自定义共享挂载点
vim /etc/auto.master
最终自定义挂载点的上层目录 子配置文件
/mnt /etc/auto.westos
vim 子配置文件
最终挂载点 网络共享目录
vim /etc/westos
pub1 172.25.254.250:/nfsshare/nfs1
* 172.25.254.250:/nfsshare/& ##指定任意共享挂载