linux之访问网络文件共享服务 |
您所在的位置:网站首页 › linux和linux共享文件 › linux之访问网络文件共享服务 |
################################################################################## • 网络文件系统是由网络附加存储服务器通过网络向多个主机提供的一种文件系统 , 而不是由块设备 ( 例如硬盘驱动器 ) 提供的。客户端通过特殊的文件系统协议和格式访问远程存储 linux 中有两种主要协议可用访问网络文件系统 : NFS 和CIFS 。 NFS ( Network File System ) 可看作是 Linux 、UNIX 及其它类似操作系统的标准文件系统。 CIFS( Comon Internet File System ) 则是针对 Microsoft Windows 系统的标准网络文件系统 • 访问网络共享的三个基本步骤 – 1. 识别要访问的远程共享 – 2. 确定挂载点 ( 应该将共享挂载到的位置 ), 并创建挂载点的空目录 – 3. 通过相应的命令或配置更改挂载网络文件系统 ######################3################ CIFS: 通用网络文件系统 CIFS 是针对 Microsoft Windows 操作系统的本地网络文件系统。Linux 系统可以挂载和访问 CIFS 文件共享 , 如同常见的网络文件系统一样。然而 , 由于 CIFS 是基于 NTFS 文件系统权限模型及其自身的身份验证系统来构建的 , 因而 CIFS 协议中的所有内容并不能很好地映射到 Linux 中 • samba-client RPM 软件包所包含的 smbclient 实用程序可用来识别由 Windows 或 Samba 文件服务器提供的 CIFS 共享。该实用程序工作起来犹如在 Microsoft Windows 中单击网上邻居。然后 mount 命令可用于挂载共享。访问 CIFS 共享的命令 – . 识别 :# smbclient -L instructor.example.com – 2. 确定挂载点 :# mkdir /remote2 – 3. 挂载 :# mount //instructor.example.com/ftp /remote2 ####手动的挂载访问
1)yum install samba-client 2)smbclient -L //ip 3)smbclient //ip/sharename####自动挂载 mount //ip/sharename /mountpoint -o username=guest vim /etc/fstab //ip/sharename /mountpoint cifs defaults,username=guest 0 0 mount -a
#################################################################################### nfs NFS : 网络文件系统( Network File System ) 是由 Linux、UNIX 及其他类似操作系统使用的互联网标准协议,可作为它们的本地网络文件系统。它是一种活动扩展之下的开放标准 , 可支持本地 Linux 权限和文件系统功能。 [[email protected] /]# yum search nfs ###搜索nfs安装包 [[email protected] /]# yum install nfs-utils.x86_64 ###安装nfs [[email protected] /]# 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 [[email protected] /]# mount 172.25.254.250:/nfsshare/nfs3 /mnt ###将共享的文件挂载到本地目录 [[email protected] /]# cd /mnt/ [[email protected] mnt]# touch file{1..10} [[email protected] mnt]# ls file1 file10 file2 file3 file4 file5 file6 file7 file8 file9 [[email protected] mnt]# cd .. [[email protected] /]# umount /mnt ####卸载挂载 #####自动挂载 [[email protected] /]# echo 172.25.254.250:/nfsshare/nfs1 /mnt nfs defaults 0 0 >> /etc/fstab [[email protected] /]# mount -a ####刷新文件中没有挂载的 [[email protected] /]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/vda1 10473900 3365628 7108272 33% / devtmpfs 922268 0 922268 0% /dev tmpfs 942660 80 942580 1% /dev/shm tmpfs 942660 17048 925612 2% /run tmpfs 942660 0 942660 0% /sys/fs/cgroup 172.25.254.250:/nfsshare/nfs1 100221952 78411776 21810176 79% /mnt
########################################### ###多个文件的自动挂载 [[email protected] ~]# cat /etc/auto.master ####将挂载点的上层目录写到auto.master文件中 /misc /etc/auto.misc /westos /etc/auto.westos [[email protected] westos]# cat /etc/auto.westos ###在/etc/auto.westos中写入相应的规则 * 172.25.254.250:/nfsshare/& [[email protected] westos]# systemctl restart autofs.service ####重启服务 [[email protected] westos]# cd nfs1 [[email protected] nfs1]# ls [[email protected] nfs1]# touch file{1..10} [[email protected] nfs1]# rm -fr * [[email protected] nfs1]# cd .. [[email protected] westos]# cd .. [[email protected] /]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/vda1 10473900 3369724 7104176 33% / devtmpfs 922268 0 922268 0% /dev tmpfs 942660 80 942580 1% /dev/shm tmpfs 942660 17056 925604 2% /run tmpfs 942660 0 942660 0% /sys/fs/cgroup [[email protected] /]# cd /westos/nfs4 [[email protected] nfs4]# ls [[email protected] nfs4]# touch file2 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |