最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux實(shí)現(xiàn)自動(dòng)掛載autofs的方法詳解

 更新時(shí)間:2022年10月10日 11:21:39   作者:wei_shuo  
這篇文章主要介紹了Linux實(shí)現(xiàn)自動(dòng)掛載autofs的相關(guān)資料。autofs 服務(wù)將實(shí)現(xiàn)自動(dòng)掛載外圍設(shè)備,NFS共享目錄等,并在空閑5分鐘后后自動(dòng)卸載,需要的可以參考一下

實(shí)現(xiàn)自動(dòng)掛載-autofs

autofs 服務(wù)實(shí)現(xiàn)自動(dòng)掛載外圍設(shè)備,NFS共享目錄等,并在空閑5分鐘后后自動(dòng)卸載

相關(guān)包和文件 :

軟件包:autofs

服務(wù)文件:/usr/lib/systemd/system/autofs.service

配置文件:/etc/auto.master

autofs工具簡單使用

#安裝autofs工具
[root@rhel82 ~]# yum install -y autofs

#啟動(dòng)autofs服務(wù)
[root@rhel82 ~]# systemctl start autofs
 
#autofs服務(wù)啟動(dòng)后會(huì)有/misc/cd目錄,設(shè)置虛擬機(jī)連接光盤,實(shí)現(xiàn)自動(dòng)掛載系統(tǒng)光盤
[root@rhel82 ~]# ll /misc/
總用量 0

[root@rhel82 ~]# cd /misc/cd
[root@rhel82 cd]# df -h
文件系統(tǒng)        容量  已用  可用 已用% 掛載點(diǎn)
devtmpfs        1.9G     0  1.9G    0% /dev
tmpfs           2.0G     0  2.0G    0% /dev/shm
tmpfs           2.0G   10M  2.0G    1% /run
tmpfs           2.0G     0  2.0G    0% /sys/fs/cgroup
/dev/nvme0n1p5   25G  4.4G   21G   18% /
/dev/nvme0n1p2 1014M  208M  807M   21% /boot
tmpfs           392M  1.2M  391M    1% /run/user/42
tmpfs           392M  4.6M  387M    2% /run/user/0
/dev/sr0        7.9G  7.9G     0  100% /misc/cd

[root@rhel82 ~]# rpm -ql autofs
[root@rhel82 ~]# rpm -qc autofs

autofs配置詳細(xì)說明

參看幫助:man 5 autofs

自動(dòng)掛載資源有兩種格式

相對(duì)路徑掛載法

將mount point 掛載點(diǎn)路徑分成 dirname 和 basename 分別配置,可能會(huì)影響現(xiàn)有的目錄結(jié)構(gòu)

# 比如掛載掛載光盤: mount /dec/sr0 /mnt/sr0 , 其中 /mnt目錄為dirname, /mnt/sr0為basename 等價(jià)于 /mnt/sr0 = /dirname/basename

autofs主配置文件/etc/atuo.master格式

掛載點(diǎn)的dirname     指定目錄的配置文件路徑,如:/etc/test.auto

指定子配置文件格式/etc/test.auto

掛載點(diǎn)的basename     掛載選項(xiàng)     選項(xiàng)設(shè)備

注意:autofs配置的dirname目錄和basename目錄不需要手動(dòng)創(chuàng)建,會(huì)覆蓋已存在掛載點(diǎn)的dirname目錄下原數(shù)據(jù)

autof默認(rèn)提供掛載光盤范例

[root@centos8 ~ ]# cat /etc/auto.master
/misc   /etc/auto.misc

[root@centos8 ~ ]# cat /etc/auto.misc
cd     -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

#特殊寫法:  掛載點(diǎn)dataname和掛載目錄dataname相同,即: mount 10.0.0.18:/data/www /misc/www
*	-fstype=nfg		10.0.0.18:/data/&

范例:利用autofs自動(dòng)掛載nfs

#服務(wù)端和客戶端安裝nfs-utils工具包
[root@server ~]# yum install -y nfs-utils
[root@client ~]# yum install -y nfs-utils
[root@server ~]# mkdir /nfs
[root@server ~]# cp /etc/passwd /nfs/

#centos6系統(tǒng)nfs服務(wù)叫做nfs.service
#centos7系統(tǒng)上nfs.service 和 nfs-server.service同一個(gè)服務(wù)
#centos8只有nfs-server.service服務(wù)

[root@server ~]# systemctl start nfs

#centos7系統(tǒng)可以解決服務(wù)之間依賴關(guān)系,并且nfs服務(wù)啟動(dòng)會(huì)自動(dòng)啟動(dòng)rpcbind.service
[root@server ~]# systemctl status rpcbind

[root@server ~]# vim /etc/exports
/nfs  *(rw)

[root@server ~]# exportfs -r
[root@server ~]# exportfs -v
/nfs          	<world>(sync,wdelay,hide,no_subtree_check,sec=sys,rw,root_squash,no_all_squash)

[root@server ~]# systemctl restart nfs
[root@server ~]# showmount -e 192.168.192.128
Export list for 192.168.192.128:
/nfs *

[root@client ~]# showmount -e 192.168.192.128
Export list for 192.168.192.128:
/nfs *

[root@client ~]# mkdir /opt/nfs
[root@client ~]# mount 192.168.192.128:/nfs /opt/nfs/
[root@client ~]# df -h | grep nfs
192.168.192.128:/nfs   62G  1.7G   61G    3% /opt/nfs

#編寫autofs主配置文件
[root@client ~]# vim /etc/auto.master
/opt /etc/auto.master.d/auto.nfs

#編寫子配置文件
[root@client ~]# vim /etc/auto.master.d/auto.nfs
nfs     -fstype=nfs       192.168.192.128:/nfs

#掛載點(diǎn)/dirname是/目錄,查看autofs配置未生效,/目錄數(shù)據(jù)
[root@client ~]# cp /root/anaconda-ks.cfg  /opt/
[root@client ~]# ll /opt/
總用量 4
-rw-------. 1 root root 1453 12月  5 04:03 anaconda-ks.cfg

#如果修改主配置文件需要重啟服務(wù)
[root@client ~]# systemctl restart autofs

#一旦重啟atuofs服務(wù),掛載dirname目錄屬于autofs服務(wù)管理,源數(shù)據(jù)不存在
[root@centos8 ~ ]# ll /opt/
total 0

#cd進(jìn)入指定掛載點(diǎn),autofs就會(huì)自動(dòng)掛載
[root@client ~]# ls /opt/
[root@client ~]# cd /opt/nfs
[root@client nfs]# ls
passwd

[root@client nfs]# df -h | grep nfs
192.168.192.128:/nfs   62G  1.7G   61G    3% /opt/nfs

絕對(duì)路徑掛載法

直接匹配全部的絕對(duì)路徑名稱,都寫入到指定的配置文件里,不會(huì)影響本地目錄結(jié)構(gòu)

autofs主配置文件/etc/atuo.master格式

/-    指定目錄的配置文件路徑(使用 /- 表示使用絕對(duì)目錄)

指定子配置文件格式/etc/test.auto

掛載點(diǎn)絕對(duì)路徑   掛載選項(xiàng)     選項(xiàng)設(shè)備

范例

[root@client ~]# vim /etc/auto.master
/-     /etc/auto.master.d/auto.nfs

[root@client ~]# vim /etc/auto.master.d/auto.nfs
/opt/nfs     -fstype=nfs       192.168.192.128:/nfs

#autofs服務(wù)使用絕對(duì)路徑自動(dòng)掛載,不會(huì)覆蓋原數(shù)據(jù)
[root@client ~]# systemctl start autofs
[root@client ~]# ll /opt/
總用量 4
-rw-------. 1 root root 1453 12月  5 04:03 anaconda-ks.cfg
drwxr-xr-x. 2 root root   20 12月  4 19:39 nfs

[root@client ~]# cd /opt/nfs/
[root@client nfs]# ls
passwd

優(yōu)化 Linux 系統(tǒng)性能

使用tuned-adm命令優(yōu)化Linux系統(tǒng)性能。作為系統(tǒng)管理員,能夠通過調(diào)整各種設(shè)置來優(yōu)化Linux系統(tǒng)的性能,以適合當(dāng)前用例工作負(fù)載,幫助優(yōu)化Linux的性能。

可以調(diào)整到的可用配置文件:

  • balanced:非常適合在節(jié)能和性能之間尋求折衷的系統(tǒng)。
  • desktop:源自平衡配置文件,提供交互式應(yīng)用程序的更快響應(yīng)。
  • throughput-performance:調(diào)整系統(tǒng)以獲得最大吞吐量。
  • latency-performance:對(duì)于要求低延遲,以功耗為代價(jià)的服務(wù)器系統(tǒng)的理想選擇。
  • network-latency:源自延遲性能配置文件,它啟用其他網(wǎng)絡(luò)調(diào)整參數(shù)以提供較低的網(wǎng)絡(luò)延遲。
  • network-throughput:從吞吐量性能概要文件得出,附加的網(wǎng)絡(luò)調(diào)整參數(shù)適用于最大的網(wǎng)絡(luò)吞吐量。
  • powersave:調(diào)整系統(tǒng)以最大程度地節(jié)省電力。
  • oracle:基于吞吐量性能概要文件針對(duì)Oracle數(shù)據(jù)庫負(fù)載進(jìn)行了優(yōu)化。
  • virtual-guest:優(yōu)化以在虛擬訪客中運(yùn)行。
  • virtual-host:如果用于運(yùn)行KVM guest虛擬機(jī),請(qǐng)調(diào)整系統(tǒng)以獲得最佳性能。

安裝 Tuned

[root@rhel82 ~]# yum install tuned -y

[root@rhel82 ~]# systemctl status tuned

選擇調(diào)整配置文件

調(diào)整的配置文件包含性能提升配置文件,性能提升配置文件包括側(cè)重于:存儲(chǔ)和網(wǎng)絡(luò)的低延遲、高吞吐量的存儲(chǔ)和網(wǎng)絡(luò)、虛擬主機(jī)性能、虛擬機(jī)性能的配置文件。

我們將使用tuned-adm命令來更改已調(diào)整守護(hù)程序的設(shè)置。

檢查當(dāng)前活動(dòng)的調(diào)優(yōu)配置文件:

[root@rhel82 ~]# tuned-adm active
Current active profile: virtual-guest

可以使用更多配置文件,如下:

[root@rhel82 ~]# tuned-adm list
Available profiles:
- accelerator-performance     - Throughput performance based tuning with disabled higher latency STOP states
- balanced                    - General non-specialized tuned profile
- desktop                     - Optimize for the desktop use-case
- hpc-compute                 - Optimize for HPC compute workloads
- intel-sst                   - Configure for Intel Speed Select Base Frequency
- latency-performance         - Optimize for deterministic performance at the cost of increased power consumption
- network-latency             - Optimize for deterministic performance at the cost of increased power consumption, focused on low latency network performance
- network-throughput          - Optimize for streaming network throughput, generally only necessary on older CPUs or 40G+ networks
- optimize-serial-console     - Optimize for serial console use.
- powersave                   - Optimize for low power consumption
- throughput-performance      - Broadly applicable tuning that provides excellent performance across a variety of common server workloads
- virtual-guest               - Optimize for running inside a virtual guest
- virtual-host                - Optimize for running KVM guests
Current active profile: virtual-guest

tuned-adm配置文件命令用于將活動(dòng)配置文件切換到其他配置文件,此示例將調(diào)整我們的系統(tǒng)以實(shí)現(xiàn)最大吞吐量:

[root@rhel82 ~]# tuned-adm profile throughput-performance

確認(rèn)當(dāng)前配置文件:

[root@rhel82 ~]# tuned-adm active
Current active profile: throughput-performance

檢查系統(tǒng)推薦的調(diào)整配置文件

tuned-adm命令還可以建議系統(tǒng)的調(diào)整配置文件,這基于各種系統(tǒng)特征,包括系統(tǒng)是否為虛擬機(jī)以及在系統(tǒng)安裝期間選擇的其他預(yù)定義類別:

[root@rhel82 ~]# tuned-adm recommend
virtual-guest

然后,可以將個(gè)人資料設(shè)置為推薦值:

[root@rhel82 ~]# tuned-adm profile virtual-guest

查看配置文件詳細(xì)信息,請(qǐng)運(yùn)行:

[root@rhel82 ~]# tuned-adm profile_info virtual-guest
Profile name:
virtual-guest

Profile summary:
Optimize for running inside a virtual guest

Profile description:

關(guān)閉已調(diào)優(yōu)的調(diào)整活動(dòng):

[root@rhel82 ~]# tuned-adm off

[root@rhel82 ~]# tuned-adm active
No current active profile.

到此這篇關(guān)于Linux實(shí)現(xiàn)自動(dòng)掛載autofs的方法詳解的文章就介紹到這了,更多相關(guān)Linux自動(dòng)掛載autofs內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Linux系統(tǒng)開機(jī)無限重啟的解決方案

    Linux系統(tǒng)開機(jī)無限重啟的解決方案

    這篇文章主要介紹了Linux系統(tǒng)開機(jī)無限重啟的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • linux提示未找到命令unzip和zip的解決方案

    linux提示未找到命令unzip和zip的解決方案

    這篇文章主要介紹了linux提示未找到命令unzip和zip的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • 在Linux中安裝Git的詳細(xì)流程

    在Linux中安裝Git的詳細(xì)流程

    本文介紹在Linux操作系統(tǒng)的Ubuntu版本中,配置分布式開源版本控制系統(tǒng)Git,隨后基于Git克隆GitHub中項(xiàng)目的代碼的詳細(xì)方法,需要的朋友可以參考下
    2024-04-04
  • Linux中的緩沖區(qū)和文件系統(tǒng)詳解

    Linux中的緩沖區(qū)和文件系統(tǒng)詳解

    這篇文章主要介紹了Linux中的緩沖區(qū)和文件系統(tǒng)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2025-03-03
  • 深入理解Bash中的尖括號(hào)(適合初學(xué)者)

    深入理解Bash中的尖括號(hào)(適合初學(xué)者)

    這篇文章主要給大家介紹了關(guān)于Bash中尖括號(hào)的相關(guān)資料,本文非常適合初學(xué)者,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-02-02
  • Linux調(diào)整命令歷史方法詳解

    Linux調(diào)整命令歷史方法詳解

    這篇文章主要介紹了Linux調(diào)整命令歷史方法詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-09-09
  • centos中文件與權(quán)限的基本操作教程

    centos中文件與權(quán)限的基本操作教程

    這篇文章主要給大家介紹了關(guān)于centos文件與權(quán)限的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-09-09
  • Linux centOS安裝JDK和Tomcat的教程

    Linux centOS安裝JDK和Tomcat的教程

    今天小編就為大家分享一篇關(guān)于Linux centOS安裝JDK和Tomcat的教程,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
    2019-01-01
  • Linux中如何開啟或關(guān)閉SELinux

    Linux中如何開啟或關(guān)閉SELinux

    這篇文章主要介紹了Linux中如何開啟或關(guān)閉SELinux問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • Centos7搭建主從DNS服務(wù)器的教程

    Centos7搭建主從DNS服務(wù)器的教程

    這篇文章主要介紹了Centos7搭建主從DNS服務(wù)器的教程,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-08-08

最新評(píng)論

许昌市| 封丘县| 榆林市| 新源县| 缙云县| 定结县| 平舆县| 淮南市| 同江市| 邯郸市| 韩城市| 隆子县| 澎湖县| 垫江县| 泰来县| 高台县| 湖州市| 柯坪县| 青铜峡市| 临清市| 英吉沙县| 利津县| 环江| 陆川县| 五莲县| 沭阳县| 平遥县| 茌平县| 怀集县| 丘北县| 富平县| 房山区| 通许县| 精河县| 出国| 启东市| 丰顺县| 安化县| 留坝县| 乌鲁木齐市| 阳西县|