访问网络文件共享服务

来源:互联网 发布:网站源码基地 编辑:程序博客网 时间:2024/05/16 16:11

1.访问网络共享的三个基本步骤

   1)识别要访问的远程共享

   2)确定挂载点 ( 应该将共享挂载到的位置 ), 并创建挂载点的空目录

   3)通过相应的名利或配置更改挂载网络文件系统

2.CIFS( Comon Internet File System ) 协议

   是针对 MicrosoftWindows 系统的标准网络文件系统

   **需要下载服务客户端:yum install samba-client -y

   [root@localhost mnt]# smbclient -L //172.25.254.250                          ##列出已分享的文件系统
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
    ---------            -------
[root@localhost mnt]# smbclient  //172.25.254.250/westos1
Enter root's password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]
smb: \> ls
  .                                   D        0  Sun Apr 30 01:35:25 2017
  ..                                  D        0  Wed Dec  2 20:43:01 2015
  file1                               A        0  Sun Apr 30 01:34:47 2017
  anaconda-ks.cfg                     A     8619  Sun Apr 30 01:35:06 2017
  file                                A       52  Sun Apr 30 01:35:24 2017
  userfile                            A       19  Sun Apr 30 01:35:25 2017

        100221120 blocks of size 1024. 21822928 blocks available
smb: \> [root@localhost mnt]# ls
creat_user.sh  file  userfile
[root@localhost mnt]# cd
[root@localhost ~]# ls
anaconda-ks.cfg  Documents  Music     Public     Videos
Desktop          Downloads  Pictures  Templates

[root@localhost ~]# mount //172.25.254.250/westos1 /mnt -o username=guest
  ##以客户身份(虚拟用户)挂载已分享的文件系统
[root@localhost ~]# cd /mnt
[root@localhost mnt]# touch file{1..5}

[root@localhost ~]# vim /etc/fstab                                                                       ##设置开机自动挂载
   //172.25.254.250/westos1    /mnt    cifs    defaults,username=guest    0 0
[root@localhost ~]# mount -a
[root@localhost ~]# df
Filesystem               1K-blocks     Used Available Use% Mounted on
/dev/vda1                 10473900  3809252   6664648  37% /
devtmpfs                    927072        0    927072   0% /dev
tmpfs                       942660      140    942520   1% /dev/shm
tmpfs                       942660    17032    925628   2% /run
tmpfs                       942660        0    942660   0% /sys/fs/cgroup
/dev/sr0                   3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64
//172.25.254.250/westos1 100221120 78407756  21813364  79% /mnt

3.NFS ( Network File System )  协议

   可看作是 Linux 、UNIX 及其它类似操作系统的标准文件系统

   **需要下载服务客户端:yum install nfs-utils -y
[root@localhost ~]# 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
[root@localhost ~]# mount 172.25.254.250:/nfsshare/nfs1 /mnt           ##挂载文件系统
[root@localhost ~]# df
Filesystem                    1K-blocks     Used Available Use% Mounted on
/dev/vda1                      10473900  3810252   6663648  37% /
devtmpfs                         927072        0    927072   0% /dev
tmpfs                            942660      140    942520   1% /dev/shm
tmpfs                            942660    17036    925624   2% /run
tmpfs                            942660        0    942660   0% /sys/fs/cgroup
/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64
172.25.254.250:/nfsshare/nfs1 100221952 78403584  21818368  79% /mnt
[root@localhost ~]# cd /mnt

[root@localhost mnt]# touch file

[root@localhost mnt]# cd
[root@localhost ~]# umount /mnt
[root@localhost ~]# vim /etc/fstab                                             ##设置开机自动挂载
[root@localhost ~]# mount -a
[root@localhost ~]# cd /mnt
[root@localhost mnt]# touch file
[root@localhost mnt]# ls
file

0 0
原创粉丝点击