In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Unit 7
Access to network file sharing services
Mount the network file system
A network file system is a file system provided by a network attached storage server to multiple hosts over the network, rather than by a block device, such as a hard disk drive. Clients access remote storage through special file system protocols and formats
There are two main protocols available in Linux to access the network file system: NFS and CIFS
1) CIFS: general network file system
CIFS is a local network file system for the Microsoft Windows operating system. The Linux system can mount and access CIFS file shares, just like common network file systems.
The smbclient utility included in the samba-client RPM package can be used to identify CIFS shares provided by Windows or Samba file servers
Client:
1 share via samba-client
Yum install samba-client-y # install samba-client###
Smbclient-L / / 172.25.254.250 login to remote server 172.25.254.250
Smbclient / / 172.25.254.250/westos1 # enter westos1###
Put anaconda-ks.cfg # upload files to westos1 #
Rm anaconda-ks.cfg # Delete files on westo1 #
The process is as follows:
[root@localhost] # smbclient-L / / 172.25.254.250 # Log in to 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 ~] # smbclient / / 172.25.254.250/westos1 # enter westos1###
Enter root's password:
Domain= [MYGROUP] OS= [Unix] Server= [Samba 4.1.1]
Smb:\ > ls # View remote server files #
. D 0 Sun Apr 30 01:36:27 2017
.. D 0 Wed Dec 2 20:43:01 2015
File A 52 Sun Apr 30 01:35:24 2017
Userfile A 19 Sun Apr 30 01:35:25 2017
Anaconda-ks.cfg A 8619 Sun Apr 30 01:36:01 2017
File2 N 0 Sun Apr 30 01:36:32 2017
File3 N 0 Sun Apr 30 01:36:32 2017
File4 N 0 Sun Apr 30 01:36:32 2017
File5 N 0 Sun Apr 30 01:36:32 2017
File6 N 0 Sun Apr 30 01:36:32 2017
File7 N 0 Sun Apr 30 01:36:32 2017
File8 N 0 Sun Apr 30 01:36:32 2017
File9 N 0 Sun Apr 30 01:36:32 2017
File10 N 0 Sun Apr 30 01:36:32 2017
Fileeeeee N 0 Sun Apr 30 01:36:17 2017
100221120 blocks of size 1024. 21816820 blocks available
Smb:\ >! ls # View the local file #
Anaconda-ks.cfg etc file.rej Public
Boot file kernel-3.10.0-123.el7.x86_64.rpm Templates
Desktop file1 lib Videos
Documents file3 Music
Downloads file.path Pictures
Smb:\ > put anaconda-ks.cfg
Putting file anaconda-ks.cfg as\ anaconda-ks.cfg (27.5 kb/s) (average 27.5 kb/s)
Smb:\ > rm anaconda-ks.cfg
NT_STATUS_NO_SUCH_FILE listing\ anaconda-ks.cfg
Smb:\ > quit
2 share by mounting
Mount / / 172.25.254.250/westos1 / mnt/-o username=guest # Mount westos1 to the local / mnt as an anonymous user #
Touch / mnt/file3
The process is as follows:
[root@localhost ~] # mount / / 172.25.254.250/westos1
Mount: can't find / / 172.25.254.250/westos1 in / etc/fstab
[root@localhost ~] # mount / / 172.25.254.250/westos1-o username=guest
Mount: can't find / / 172.25.254.250/westos1 in / etc/fstab
[root@localhost] # mount / / 172.25.254.250/westos1 / mnt/-o username=guest
[root@localhost ~] # touch / mnt/file3
[root@localhost ~] # touch / mnt/filehello
3 automatic mounting when booting
Vim / etc/fstab
Mount-a # effective immediately #
/ what is written under etc/fstab:
/ / 172.25.254.250/westos1 / mnt cifs defaults,username=guest 0 0
The process is as follows:
[root@localhost ~] # umount / mnt/
[root@localhost ~] # vim / etc/fstab
[root@localhost] # mount-a # # effective immediately #
[root@localhost ~] # df
Filesystem 1K-blocks Used Available Use% Mounted on
/ dev/vda1 10473900 4064104 6409796 39% /
Devtmpfs 922268 0 922268 / dev
Tmpfs 942660 84 942576 1 per dev/shm
Tmpfs 942660 17040 925620 2% / run
Tmpfs 942660 0 942660 / sys/fs/cgroup
/ dev/sr0 3654720 3654720 0 / run/media/root/RHEL-7.0 Server.x86_64
/ / 172.25.254.250/westos1 100221120 78407756 21813364 79% / mnt
2) nfs: network file system
NFS (Network File System) is an Internet standard protocol used by Linux, UNIX, and other similar operating systems and can be used as their local network file system.
It is an open standard under the active extension that supports local Linux permissions and file system functions
There are two ways to determine the NFS export, or file sharing, provided by the server. If the server supports NFSv3 or NFSv2, you can use the showmount-e server command to get a list of exported items. If the server supports NFSv4, you can mount / export items to an empty directory and browse the contents of all exported file systems
1 commands for accessing NFS export
Yum install nfs-utils-y # install nfs####
Showmount-e # Login #
Mount # Mount # #
The process is as follows:
[root@localhost ~] # showmount-e 172.25.254.250 #-e refers to connecting to a designated remote host #
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/ # Mount without writing client #
[root@localhost ~] # cd / mnt/
[root@localhost mnt] # touch {1..10}
[root@localhost mnt] # ls
File1 10 3 5 7 9
Haha1 2 4 6 8
[root@localhost mnt] # rm-fr *
2 automatic mounting when booting
Vim / etc/fstab
Mount-a
/ what is written under etc/fstab:
172.25.254.250:/nfsshare/nfs1 / mnt defaults 0 0
[root@localhost mnt] # cd
[root@localhost ~] # umount / mnt/
[root@localhost ~] # vim / etc/fstab
[root@localhost] # mount-a
[root@localhost ~] # df
Filesystem 1K-blocks Used Available Use% Mounted on
/ dev/vda1 10473900 4065080 6408820 39% /
Devtmpfs 922268 0 922268 / dev
Tmpfs 942660 84 942576 1 per dev/shm
Tmpfs 942660 17044 925616 2% / run
Tmpfs 942660 0 942660 / sys/fs/cgroup
/ dev/sr0 3654720 3654720 0 / run/media/root/RHEL-7.0 Server.x86_64
172.25.254.250:/nfsshare/nfs1 100221952 78411776 21810176 79% / mnt
[root@localhost ~] # touch file
[root@localhost ~] # touch file1
[root@localhost ~] # rm-fr file file1
Second, automatically mount network storage
Using the mount command, you need to have root privileges to connect to the network share. Alternatively, we can add entries to / etc/fstab, but the subsequent connection to the network server will always be active. When a program tries to access files in a network share, the automounter (or autofs) service can be configured to mount the network share "on demand". Automounter unmounts the share after it is no longer in use and is inactive for a certain period of time
The interval for inactivity defaults to five minutes, but it can be changed globally in / etc/sysconfig/autofs
1 use / net mapping
/ net, self-mount the mount point, and then manually configure the indirect auto-mount mapping
By default, when the autofs service runs, there is a special directory named / net, but that directory will appear empty, and accessing a directory that does not exist / net/instructor.example.com causes the automounter to create the subdirectory and display all NFS exports on the NFS server. This is sometimes called "browsing" sharing
When all files and directories under / net/instructor.example.com are stopped and the timeout period expires, autofs unmounts the share and deletes the empty / net/instructor.example.com subdirectory
Yum install autofs.x86_64-y # install autofs.x86_64###
Systemctl start autofs # enable service #
Cd / net # enter this directory #
Ls # check if it is empty #
Cd 172.25.254.250 # access a directory that does not exist 172.25.254.250
Ls # # check and find content #
Cd nfsshare/nfs1
The process is as follows:
[root@localhost ~] # systemctl start autofs # enable service #
[root@localhost ~] # cd / net/
[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/nfs1
[root@localhost nfs1] # ls
[root@localhost nfs1] # touch file1
[root@localhost nfs1] # ls
File1 file2
[root@localhost nfs1] # df # check whether to mount #
Filesystem 1K-blocks Used Available Use% Mounted on
/ dev/vda1 10473900 4070616 6403284 39% /
Devtmpfs 922268 0 922268 / dev
Tmpfs 942660 84 942576 1 per dev/shm
Tmpfs 942660 17052 925608 2% / run
Tmpfs 942660 0 942660 / sys/fs/cgroup
/ dev/sr0 3654720 3654720 0 / run/media/root/RHEL-7.0 Server.x86_64
172.25.254.250:/nfsshare/nfs1 100221952 78411776 21810176 79% / net/172.25.254.250/nfsshare/nfs1
[root@localhost nfs1] # cd
[root@localhost ~] # vim / etc/sysconfig/autofs # Edit mount time #
[root@localhost ~] # df
Filesystem 1K-blocks Used Available Use% Mounted on
/ dev/vda1 10473900 4070636 6403264 39% /
Devtmpfs 922268 0 922268 / dev
Tmpfs 942660 84 942576 1 per dev/shm
Tmpfs 942660 17052 925608 2% / run
Tmpfs 942660 0 942660 / sys/fs/cgroup
/ dev/sr0 3654720 3654720 0 / run/media/root/RHEL-7.0 Server.x86_64
172.25.254.250:/nfsshare/nfs1 100221952 78415872 21806080 79% / net/172.25.254.250/nfsshare/nfs1
2 indirect mapping
In addition to using the / net mapping, the system administrator can also manually configure any directory to mount a specific share "on demand" on its subdirectories when accessed
Vim / etc/auto.master
/ what is written under etc/auto.master:
A directory with the final mount point one level above the final mount point (example: / etc/auto.westos)
Vim / etc/auto.westos (the final mount point directory you edited under / etc/auto.master)
Edit content:
Nfs1 172.25.254.250:/nfsshare/nfs1 # # Mount the shared directory of the remote server to nfs1, so that only nfs2### can be mounted
* 172.25.254.250 Drexample nfssharepool & # you can mount any directory #
Systemctl restart autofs.service # restart service #
The process is as follows:
[root@localhost ~] # mkdir / westos
[root@localhost ~] # vim / etc/auto.master
[root@localhost ~] # vim / etc/auto.westos
# at this time, the content under / etc/auto.westos is: nfs1 172.25.254.250:/nfsshare/nfs1####
[root@localhost ~] # systemctl restart autofs.service
[root@localhost ~] # cd / westos/
[root@localhost westos] # ls # # / there is no nfs1 directory under westos #
[root@localhost westos] # cd nfs1
[root@localhost nfs1] # pwd
/ westos/nfs1
[root@localhost nfs1] # df
Filesystem 1K-blocks Used Available Use% Mounted on
/ dev/vda1 10473900 4070672 6403228 39% /
Devtmpfs 922268 0 922268 / dev
Tmpfs 942660 84 942576 1 per dev/shm
Tmpfs 942660 17052 925608 2% / run
Tmpfs 942660 0 942660 / sys/fs/cgroup
/ dev/sr0 3654720 3654720 0 / run/media/root/RHEL-7.0 Server.x86_64
172.25.254.250:/nfsshare/nfs1 100221952 78409728 21812224 79% / westos/nfs1
[root@localhost nfs1] # cd nfs2
-bash: cd: nfs2: No such file or directory
Nfs1 172.25.254.250://nfsshare/nfs1
[root@localhost nfs1] # vim / etc/auto.westos
# at this time, the content under / etc/auto.westos is: * 172.25.254.250:/nfsshare/
[root@localhost nfs1] # systemctl restart autofs.service
[root@localhost nfs1] # cd
[root@localhost ~] # cd / westos/nfs2
[root@localhost nfs2] # pwd
/ westos/nfs2
[root@localhost nfs3] # df
Filesystem 1K-blocks Used Available Use% Mounted on
/ dev/vda1 10473900 4070672 6403228 39% /
Devtmpfs 922268 0 922268 / dev
Tmpfs 942660 84 942576 1 per dev/shm
Tmpfs 942660 17052 925608 2% / run
Tmpfs 942660 0 942660 / sys/fs/cgroup
/ dev/sr0 3654720 3654720 0 / run/media/root/RHEL-7.0 Server.x86_64
172.25.254.250:/nfsshare/nfs2 100221952 78409728 21812224 79% / westos/nfs2
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.