- 論壇徽章:
- 0
|
版權聲明:原創(chuàng)作品,允許轉載,轉載時請務必以超鏈接形式標明文章 原始出處 、作者信息和本聲明。否則將追究法律責任.
http://U16.cublog.cn
我們經常會去下載別的服務器上的東西..或者掛載本地的目錄到一另一個目錄主要為了訪問起來方便路徑容易記住.這個服務主要有兩個配置文件一個是/etc/auto.master.這個文件定義了掛載的掛載點后面緊跟著mount動作...另一個是/etc/auto.misc,這個文件定義掛載的地方以及被掛在的目錄.此目錄可以是遠程服務器上的目錄也可以是本地目錄.....我們可以間接來進行映射遠程機器上的目錄到本機,也可直接映射本地的目錄...
下面我來給大家詳細講解間接映射遠程機器目錄到本地的目錄.......先看看看/etc/auto.master的配置文件
#
# $Id: auto.master,v 1.4 2005/01/04 14:36:54 raven Exp $
#
# 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).
#
#/misc /etc/auto.misc
/myfiles /etc/auto.home # /myfiles定義了mount的掛載點.而/etc/auto.home定義了mount的動作./etc/auto.home本身不存在可以自己創(chuàng)建..
/myftp /etc/auto.misc # 同理/myftp定義了mount的掛載點而/etc/auto.misc定義了mount的動作..
# 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 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.
我們在來看一下/etc/auto.misc的配置文件...
#
# $Id: auto.misc,v 1.2 2003/09/29 08:22:35 raven Exp $
#
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage
cd -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
# the following entries are samples to pique your imagination
#linux -ro,soft,intr
ftp.example.org:/pub/linux
boot -fstype=ext2 :/dev/hda1 #將本地磁盤/dev/hda1自動掛載到/myftp/boot上..
#floppy -fstype=auto :/dev/fd0
#floppy -fstype=ext2 :/dev/fd0
#e2floppy -fstype=ext2 :/dev/fd0
#jaz -fstype=ext2 :/dev/sdc1
#removable -fstype=ext2 :/dev/hdd
pub -ro,intr,soft 192.168.0.254:/var/ftp/pub #這兒定義的掛載點將遠程目錄掛載到本地myftp/pub目錄...然后執(zhí)行此命令重啟服務..啟動完成進入myftp目錄..
[root@station18 pub]#service autofs restart
[root@station18 pub]#cd /myftp/;ls -l
total 0
我們會看見返回的結果是total 0...并沒有發(fā)現目錄...這時你要看第二個配置文件中掛載點是pub...所以執(zhí)行
[root@station18 pub]#cd /myftp/pub;ls -l
drwxrwxr-x+ 2 root root 4096 Feb 6 17:20 books
dr-xr-xr-x 3 root root 4096 Jan 23 22:49 Cluster
dr-xr-xr-x 3 root root 4096 Jan 23 22:49 ClusterStorage
-rw-r--r-- 1 2021 2021 51200 Jan 25 02:17 course.ppt
drwxr-xr-x 2 root root 4096 Jan 23 22:44 docs
dr-xr-xr-x 3 root root 4096 Jan 23 22:49 errata
-rw-r--r-- 2 root root 1220 Jan 23 22:48 EXAMPLE-CA-CERT
-rw-r--r-- 2 root root 1220 Jan 23 22:48 example-ca.crt
drwxrwxr-x+ 2 root root 4096 Feb 6 02:23 Files
-rw-r--r-- 1 root root 28 Jul 31 2009 getme
drwxr-xr-x 5 root root 4096 Jan 23 22:48 gls
drwxr-xr-x 4 root root 4096 Feb 5 08:00 homework
dr-xr-xr-x 4 root root 4096 Aug 19 14:02 images
drwx------ 2 root root 16384 Jan 23 22:30 lost+found
drwxr-xr-x 2 root root 4096 Jan 23 22:48 namedfiles
drwxr-xr-x 2 root root 4096 Jan 23 22:48 RPMS
dr-xr-xr-x 3 root root 147456 Jan 23 22:51 Server
drwxrwxr-x 2 2021 2021 4096 Feb 7 07:57 Sources
drwxrwxr-x+ 2 root root 4096 Jan 26 19:06 test
drwxrwxr-x+ 4 root root 4096 Feb 5 10:09 Tools
dr-xr-xr-x 3 root root 4096 Jan 23 22:49 VT
在返回到myftp目錄執(zhí)行下面命令
[root@station18 myftp]# ls -l
total 8
drwxrwxr-x+ 21 root root 4096 Feb 4 07:56 pub
看到pub目錄顯示出啦,當我們第一次訪問這個目錄時只有進去這個目錄它才會被顯示出來...這地方列的都是我FTP服務器上的東西....這樣就把遠程主機上的資料掛載到本地的目錄中,訪問起來很方便....強調一點的是過幾分鐘這個目錄也就是/pub會自動消失...起到保護的作用,要想訪問得輸入準確的路徑才行...這兒我測試過默認也就是五分鐘會消失....而定義這個時間的文件在/etc/sysconfig/autofs中,我們可以用cat查看一下這個文件
第一個配置文件中myftp這個目錄可以自己創(chuàng)建也可不創(chuàng)建,當重啟動autofs服務的時候系統(tǒng)會自動創(chuàng)建......
當在/etc/auto.miscr配置文件中插入一行...寫入
llm -ro,intr,soft 192.168.0.254:/var/ftp/pub
重啟動autofs服務,執(zhí)行
#cd /myftp/llm;ls -l
我們會發(fā)現遠程主機的目錄全被列了出來.....這里強調的是myftp目錄必須得先創(chuàng)建.和上面的不同....
#
# Define default options for autofs.
#
# MASTER_MAP_NAME - default map name for the master map.
#
#MASTER_MAP_NAME="auto.master"
#
# TIMEOUT - set the default mount timeout (default 600).
#
TIMEOUT=300
#
# NEGATIVE_TIMEOUT - set the default negative timeout for
# failed mount attempts (default 60).
#
#NEGATIVE_TIMEOUT=60
#
# UMOUNT_WAIT - time to wait for a response from umount(8).
#
#UMOUNT_WAIT=12
#
# BROWSE_MODE - maps are browsable by default.
#
BROWSE_MODE="no"
#
# APPEND_OPTIONS - append to global options instead of replace.
#
#APPEND_OPTIONS="yes"
#
# LOGGING - set default log level "none", "verbose" or "debug"
#
#LOGGING="none"
#
# Define base dn for map dn lookup.
#
# Define server URIs
#
# LDAP_URI - space seperated list of server uris of the form
# ://[/] where can be ldap
# or ldaps. The option can be given multiple times.
# Map entries that include a server name override
# this option.
#
# This configuration option can also be used to
# request autofs lookup SRV RRs for a domain of
# the form :///[]. Note that a
# trailing "/" is not allowed when using this form.
# If the domain dn is not specified the dns domain
# name (if any) is used to construct the domain dn
# for the SRV RR lookup. The server list returned
# from an SRV RR lookup is refreshed according to
# the minimum ttl found in the SRV RR records or
# after one hour, whichever is less.
#
#LDAP_URI=""
#
# LDAP__TIMEOUT - timeout value for the synchronous API calls
# (default is LDAP library default).
#
#LDAP_TIMEOUT=-1
#
# LDAP_NETWORK_TIMEOUT - set the network response timeout (default 8).
#
#LDAP_NETWORK_TIMEOUT=8
#
# SEARCH_BASE - base dn to use for searching for map search dn.
# Multiple entries can be given and they are checked
# in the order they occur here.
#
#SEARCH_BASE=""
#
# Define the LDAP schema to used for lookups
#
# If no schema is set autofs will check each of the schemas
# below in the order given to try and locate an appropriate
# basdn for lookups. If you want to minimize the number of
# queries to the server set the values here.
#
#MAP_OBJECT_CLASS="nisMap"
#ENTRY_OBJECT_CLASS="nisObject"
#MAP_ATTRIBUTE="nisMapName"
#ENTRY_ATTRIBUTE="cn"
#VALUE_ATTRIBUTE="nisMapEntry"
#
# Other common LDAP nameing
#
#MAP_OBJECT_CLASS="automountMap"
#ENTRY_OBJECT_CLASS="automount"
#MAP_ATTRIBUTE="ou"
#ENTRY_ATTRIBUTE="cn"
#VALUE_ATTRIBUTE="automountInformation"
#
#MAP_OBJECT_CLASS="automountMap"
#ENTRY_OBJECT_CLASS="automount"
#MAP_ATTRIBUTE="automountMapName"
#ENTRY_ATTRIBUTE="automountKey"
#VALUE_ATTRIBUTE="automountInformation"
#
# AUTH_CONF_FILE - set the default location for the SASL
# authentication configuration file.
#
#AUTH_CONF_FILE="/etc/autofs_ldap_auth.conf"
#
# MAP_HASH_TABLE_SIZE - set the map cache hash table size.
# Should be a power of 2 with a ratio roughly
# between 1:10 and 1:20 for each map.
#
#MAP_HASH_TABLE_SIZE=1024
#
# General global options
#
# If the kernel supports using the autofs miscellanous device
# and you wish to use it you must set this configuration option
# to "yes" otherwise it will not be used.
USE_MISC_DEVICE="yes"
#
#OPTIONS=""
#
關于autofs我們就說到這兒....自動掛載本地目錄和遠程的目錄會經常用到.所以喜歡linux的朋友一定要把這個學好了...
本文來自ChinaUnix博客,如果查看原文請點:http://blog.chinaunix.net/u3/111913/showart_2183014.html |
|