In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to install AutoFs mount service in Linux system, for this problem, this article describes the corresponding analysis and solution in detail, hoping to help more small partners who want to solve this problem find a simpler and easier way.
Whether it is Samba or NFS services, the mount information should be written to/etc/fstab, so that remote shared resources will be automatically mounted when the server is booted. While this is convenient, if too many remote resources are mounted, it places a heavy load on network bandwidth and server hardware resources. If the resource is not used for a long time after mounting, it will also cause waste of server hardware resources.
Some readers may say that you can mount manually by executing the mount command before each use. This is a good choice, but every time you need to mount before use, you do not find it troublesome?
Autofs automount service can help us solve this problem. Unlike the mount command, the autofs service is a Linux system daemon that automatically mounts an unmounted file system when it detects that a user is trying to access it.
In other words, after we fill the mount information into the/etc/fstab file, the system automatically mounts it every time it boots, and the autofs service program dynamically mounts it when the user needs to use the file system, thus saving network resources and server hardware resources.
[root@localhost ~]# yum install autofs Loaded plugins: langpacks, product-id, subscription-manager ...... Running transaction Installing : hesiod-3.2.1-3.el7.x86_64 1/2 Installing : 1:autofs-5.0.7-40.el7.x86_64 2/2 Verifying : hesiod-3.2.1-3.el7.x86_64 1/2 Verifying : 1:autofs-5.0.7-40.el7.x86_64 2/2 Installed: autofs.x86_64 1:5.0.7-40.el7 Dependency Installed: hesiod.x86_64 0:3.2.1-3.el7 Complete!
Linux servers in production environments typically manage the mount of many devices simultaneously. If the mounting information of these devices is written into the main configuration file of autofs service, it will undoubtedly make the main configuration file bloated, which is not conducive to service execution efficiency and modification of configuration contents in the future. Therefore, the main configuration file of autofs service program needs to be filled in according to the format of "mounting directory sub-configuration file." The mount directory is a directory one level above the mount location of the device.
For example, CD devices are usually mounted in the/media/cdrom directory, so the mount directory can be written as/media. The corresponding sub-configuration file further describes the mount device information in the mount directory. Sub-configuration files need to be user-defined, file names are not strictly required, but the suffix must end in.misc. Specific configuration parameters are shown in bold on line 7.
[root@localhost ~]# vim /etc/auto.master # # Sample auto.master file # This is an automounter map and it has the following format # key [ -mount-options-separated-by-comma ] location # For details of the format look at autofs(5). /media /etc/iso.misc /misc /etc/auto.misc # # NOTE: mounts done from a hosts map will be mounted with the # "nosuid" and "nodev" options unless the "suid" and "dev" # options are explicitly given. /net -hosts # # Include /etc/auto.master.d/*.autofs +dir:/etc/auto.master.d # # Include central master map if it can be found using # nsswitch sources. # # Note that if there are entries for /net or /misc (as # above) in the included master map any keys that are the # same will not be seen as the first read key seen takes # precedence. +auto.master
In the sub-configuration file, it should be filled in according to the format of "mount directory mount file type and permissions: device name". For example, to mount a CD device in the/media/iso directory, write the mount directory as iso, -fstype as the file system format parameter, iso9660 as the CD device format, ro, nosuid, and nodev as the specific permission parameters of the CD device, and/dev/cdrom as the name of the device to be mounted. After the configuration is complete, start the autofs service program and add it to the system startup item:
[root@localhost ~]# vim /etc/iso.misc iso -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom [root@localhost ~]# systemctl start autofs [root@localhost ~]# systemctl enable autofs ln -s '/usr/lib/systemd/system/autofs.service' '/etc/systemd/system/multi-user.target.wants/autofs.service'
A very interesting thing is about to happen. Let's check the mounting status of the current CD device and make sure that the CD device is not mounted, and there is no iso subdirectory in the/media directory. However, we can switch to this iso subdirectory using the cd command, and the CD device will be mounted immediately. And we'll be able to see what's on the disc.
[root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 18G 3.0G 15G 17% / devtmpfs 905M 0 905M 0% /dev tmpfs 914M 140K 914M 1% /dev/shm tmpfs 914M 8.9M 905M 1% /run tmpfs 914M 0 914M 0% /sys/fs/cgroup /dev/sda1 497M 119M 379M 24% /boot [root@linuxprobe ~]# cd /media [root@localhost media]# ls [root@localhost media]# cd iso [root@localhost iso]# ls -l total 812 dr-xr-xr-x. 4 root root 2048 May 7 2017 addons dr-xr-xr-x. 3 root root 2048 May 7 2017 EFI -r--r--r--. 1 root root 8266 Apr 4 2017 EULA -r--r--r--. 1 root root 18092 Mar 6 2012 GPL dr-xr-xr-x. 3 root root 2048 May 7 2017 images dr-xr-xr-x. 2 root root 2048 May 7 2017 isolinux dr-xr-xr-x. 2 root root 2048 May 7 2017 LiveOS -r--r--r--. 1 root root 108 May 7 2017 media.repo dr-xr-xr-x. 2 root root 774144 May 7 2017 Packages dr-xr-xr-x. 24 root root 6144 May 7 2017 release-notes dr-xr-xr-x. 2 root root 4096 May 7 2017 repodata -r--r--r--. 1 root root 3375 Apr 1 2017 RPM-GPG-KEY-redhat-beta -r--r--r--. 1 root root 3211 Apr 1 2017 RPM-GPG-KEY-redhat-release -r--r--r--. 1 root root 1568 May 7 2017 TRANS.TBL[root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 18G 3.0G 15G 17% / devtmpfs 905M 0 905M 0% /dev tmpfs 914M 140K 914M 1% /dev/shm tmpfs 914M 8.9M 905M 1% /run tmpfs 914M 0 914M 0% /sys/fs/cgroup /dev/cdrom 3.5G 3.5G 0 100% /media/iso /dev/sda1 497M 119M 379M 24% /boot How to install AutoFs mount service in Linux system The answer to the problem is shared here. I hope the above content can be of some help to everyone. If you still have a lot of doubts, You can pay attention to the industry information channel to learn more about relevant knowledge.
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.