Linux 2 unit7 挂载网络共享

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux 2 unit7 挂载网络共享相关的知识,希望对你有一定的参考价值。

##挂载网络共享###

###文件的共享(samba)###

[[email protected] mnt]# yum install samba-client.x86_64 -y   ##

Loaded plugins: langpacks

Resolving Dependencies

--> Running transaction check

---> Package samba-client.x86_64 0:4.2.3-10.el7 will be installed

--> Processing Dependency: samba-common = 4.2.3-10.el7 for package: samba-client-4.2.3-10.el7.x86_64

--> Processing Dependency: samba-common = 4.2.3-10.el7 for package: samba-client-4.2.3-10.el7.x86_64

 

Installed:

  samba-client.x86_64 0:4.2.3-10.el7               

 

Dependency Installed:

  samba-client-libs.x86_64 0:4.2.3-10.el7          

  samba-common-libs.x86_64 0:4.2.3-10.el7          

  samba-common-tools.x86_64 0:4.2.3-10.el7                      

 

Complete!

[[email protected] mnt]# smbclient -L //172.25.254.250    ##共享此ip下的文件

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

---------            -------

[[email protected] mnt]# smbclient //172.25.254.250/westos1  ##进入到westos1

Enter root‘s password:

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

smb: \> ls

  .                                   D        0  Sun Apr 30 01:32:45 2017

  ..                                  D        0  Wed Dec  2 20:43:01 2015

 

100221120 blocks of size 1024. 21820400 blocks available

smb: \> !ls    ##查看本机有什么

creat_user.sh  passwd  userfile

file.sh        rule    westos

smb: \> put file.sh

putting file file.sh as \file.sh (32.7 kb/s) (average 32.7 kb/s)

smb: \> exit

[[email protected] ~]# mount //172.25.254.250/westos1 /mnt -o username=guest

[[email protected] ~]# touch xiao

[[email protected] ~]# cd mnt/

[[email protected] mnt]# touch xiao

[[email protected] mnt]# rm -f  xiao

[[email protected] mnt]# df

Filesystem               1K-blocks     Used Available Use% Mounted on

/dev/vda1                 10473900  4230560   6243340  41% /

devtmpfs                    922268        0    922268   0% /dev

tmpfs                       942660       84    942576   1% /dev/shm

tmpfs                       942660    17028    925632   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 78405328  21815792  79% /mnt

[[email protected] mnt]# touch file1

[[email protected] mnt]# touch file2

[[email protected] mnt]# exit

 

###开机自动挂载###

[[email protected] ~]# vim /etc/fstab

技术分享

[[email protected] ~]# df

Filesystem               1K-blocks     Used Available Use% Mounted on

/dev/vda1                 10473900  4230600   6243300  41% /

devtmpfs                    922268        0    922268   0% /dev

tmpfs                       942660       84    942576   1% /dev/shm

tmpfs                       942660    17028    925632   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

[[email protected] ~]# mount -a

[[email protected] ~]# df

Filesystem               1K-blocks     Used Available Use% Mounted on

/dev/vda1                 10473900  4230600   6243300  41% /

devtmpfs                    922268        0    922268   0% /dev

tmpfs                       942660       84    942576   1% /dev/shm

tmpfs                       942660    17028    925632   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

 

 

做下次实验室时保证实验环境干净##

[[email protected] ~]# vim /etc/fstab

[[email protected] ~]# mount -a

[[email protected] ~]# umount /mnt/

[[email protected] ~]# df

Filesystem     1K-blocks    Used Available Use% Mounted on

/dev/vda1       10473900 4230584   6243316  41% /

devtmpfs          922268       0    922268   0% /dev

tmpfs             942660      84    942576   1% /dev/shm

tmpfs             942660   17028    925632   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

 

 

###nfs-utils共享软件

[[email protected] ~]# yum install nfs-utils.x86_64 -y    ##安装nfs共享软件

Loaded plugins: langpacks

Resolving Dependencies

--> Running transaction check

---> Package nfs-utils.x86_64 1:1.3.0-0.el7 will be updated

---> Package nfs-utils.x86_64 1:1.3.0-0.21.el7 will be an update

--> Processing Dependency: gssproxy >= 0.3.0-0 for package: 1:nfs-utils-1.3.0-0.21.el7.x86_64

 

Dependencies Resolved

 

===================================================

 Package       Arch   Version       Repository

                                              Size

===================================================

Updating:

 nfs-utils     x86_64 1:1.3.0-0.21.el7

                                    rhel_dvd 370 k

Installing for dependencies:

 gssproxy      x86_64 0.4.1-7.el7   rhel_dvd  84 k

 libbasicobjects

               x86_64 0.1.1-25.el7  rhel_dvd  25 k

 libcollection x86_64 0.6.2-25.el7  rhel_dvd  40 k

 libini_config x86_64 1.2.0-25.el7  rhel_dvd  59 k

 libpath_utils x86_64 0.2.1-25.el7  rhel_dvd  27 k

 libref_array  x86_64 0.1.5-25.el7  rhel_dvd  26 k

 libverto-tevent

               x86_64 0.2.5-4.el7   rhel_dvd 9.0 k

Updating for dependencies:

 krb5-libs     x86_64 1.13.2-10.el7 rhel_dvd 837 k

 

Transaction Summary

===================================================

Install             ( 7 Dependent packages)

Upgrade  1 Package  (+1 Dependent package)

 

Total size: 1.4 M

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction            

 

Updated:

  nfs-utils.x86_64 1:1.3.0-0.21.el7                

 

Dependency Updated:

  krb5-libs.x86_64 0:1.13.2-10.el7                 

 

Complete!

[[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/nfs1 /mnt/  

[[email protected] ~]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4231560   6242340  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   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:/nfsshare/nfs1 100221952 78403584  21818368  79% /mnt

[[email protected] ~]# cd /mnt/

[[email protected] mnt]# ls

[[email protected] mnt]# touch xiaoxiaoxiao

[[email protected] mnt]# ls

 xiaoxiaoxiao

[[email protected] mnt]# rm -fr xiaoxiaoxiao

[[email protected] mnt]# cd

[[email protected] ~]# umount /mnt

[[email protected] ~]# vim /etc/fstab

技术分享

[[email protected] ~]# mount -a

[[email protected] ~]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4231600   6242300  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   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:/nfsshare/nfs1 100221952 78411776  21810176  79% /mnt

[[email protected] ~]# cat /etc/fstab

 

#

# /etc/fstab

# Created by anaconda on Wed May  7 01:22:57 2014

#

# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

UUID=9bf6b9f7-92ad-441b-848e-0257cbb883d1 /                       xfs     defaults        1 1

172.25.254.250:/nfsshare/nfs1 /mnt nfs defaults 0 0    ##自动挂载脚本

 

 

[[email protected] ~]# yum install autofs.x86_64 -y

Loaded plugins: langpacks

Resolving Dependencies

--> Running transaction check

---> Package autofs.x86_64 1:5.0.7-54.el7 will be installed

--> Processing Dependency: libhesiod.so.0()(64bit) for package: 1:autofs-5.0.7-54.el7.x86_64

--> Running transaction check

---> Package hesiod.x86_64 0:3.2.1-3.el7 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

===================================================

 Package Arch    Version           Repository

                                              Size

===================================================

Installing:

 autofs  x86_64  1:5.0.7-54.el7    rhel_dvd  793 k

Installing for dependencies:

 hesiod  x86_64  3.2.1-3.el7       rhel_dvd   30 k

 

Transaction Summary

===================================================

Install  1 Package (+1 Dependent package)

 

Total download size: 823 k

Installed size: 5.1 M

Downloading packages:

(1/2): hesiod-3.2.1-3.el7.x86 |  30 kB   00:00     

(2/2): autofs-5.0.7-54.el7.x8 | 793 kB   00:00     

---------------------------------------------------

Total                 3.0 MB/s | 823 kB  00:00     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : hesiod-3.2.1-3.el7.x86_64       1/2

  Installing : 1:autofs-5.0.7-54.el7.x86_64    2/2

  Verifying  : 1:autofs-5.0.7-54.el7.x86_64    1/2

  Verifying  : hesiod-3.2.1-3.el7.x86_64       2/2

 

Installed:

  autofs.x86_64 1:5.0.7-54.el7                     

 

Dependency Installed:

  hesiod.x86_64 0:3.2.1-3.el7                      

 

Complete!

[[email protected] ~]# systemctl start autofs

[[email protected] ~]# cd /net

[[email protected] net]# ls

[[email protected] net]# cd 172.25.254.250

[[email protected] 172.25.254.250]# ls

content  nfsshare

[[email protected] 172.25.254.250]# pwd

/net/172.25.254.250

[[email protected] 172.25.254.250]# cd nfsshare/

[[email protected] nfsshare]# ls

nfs1  nfs2  nfs3  nfs4  nfs5

[[email protected] nfsshare]# cd nfs3

[[email protected] nfs3]# ls

[[email protected] nfs3]# touch xiao

[[email protected] nfs3]# rm -fr xiao

[[email protected] nfs3]# ls

[[email protected] nfs3]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4237048   6236852  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17044    925616   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 78411776  21810176  79% /mnt

172.25.254.250:/nfsshare/nfs3 100221952 78411776  21810176  79% /net/172.25.254.250/nfsshare/nfs3

[[email protected] nfs3]# vim /etc/sysconfig/autofs   ##在配置文件中更改自动挂载不使用卸载时间

[[email protected] nfs3]# umount /mnt

[[email protected] nfs3]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4237068   6236832  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17044    925616   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

 

[[email protected] ~]# mkdir /westos

[[email protected] ~]# vim /etc/auto.master

[[email protected] ~]# vim /etc/auto.westos

[[email protected] ~]# head -10 /etc/auto.master

#

# Sample auto.master file

# This is a ‘master‘ automounter map and it has the following format:

# mount-point [map-type[,format]:]map [options]

# For details of the format look at auto.master(5).

#

/misc/etc/auto.misc

/westos /etc/auto.westos

#

# NOTE: mounts done from a hosts map will be mounted with the

[[email protected] ~]# cat /etc/auto.westos

* 172.25.254.250:/nfsshare/&    ##将任意挂载到/nfsshare/下面

[[email protected] ~]# systemctl restart autofs.service

[[email protected] ~]# cd /westos

[[email protected] westos]# ls

[[email protected] westos]# cd nfs1

[[email protected] nfs1]# pwd

/westos/nfs1

[[email protected] nfs1]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4237068   6236832  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17048    925612   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 78409728  21812224  79% /westos/nfs1

[[email protected] nfs1]# cd

[[email protected] ~]# cd /westos/nfs2

[[email protected] nfs2]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4237068   6236832  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17048    925612   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/nfs2 100221952 78413824  21808128  79% /westos/nfs2


本文出自 “AELY木” 博客,请务必保留此出处http://12768057.blog.51cto.com/12758057/1921095

以上是关于Linux 2 unit7 挂载网络共享的主要内容,如果未能解决你的问题,请参考以下文章

第二本书unit 7 网络共享文件访问

第二课unit7 访问网络文件共享服务

linux必备高级技能——linux挂载共享文件,自动挂载

2-7.访问网络文件共享服务

unit7 & unit9cifs网络文件系统访问;vsftp服务

linux配置autofsNFS共享(linux系统之间的文件共享)