정보공유

Setup to autofs(automount) on Centos7

CheekyKite 2017. 1. 6.

안녕하세요.

다산데이타 입니다.


CentOS 에서 autofs (automount) 를 이용하여 

nas 에서 공유된 nfs 볼륨 과 연결한 한 스크립트 입니다.



 

[kite@centos7:/]$ sudo vi /etc/hosts

[kite@centos7:/]$ cat /etc/hosts

<생략>

192.168.x.x nas


[kite@centos7:/]$

[kite@centos7:/]$

[kite@centos7:/]$

[kite@centos7:/]$ sudo yum install autofs

Loaded plugins: fastestmirror, langpacks, priorities

Loading mirror speeds from cached hostfile

* base: ftp.daumkakao.com

* epel: ftp.jaist.ac.jp

* extras: ftp.daumkakao.com

* updates: ftp.daumkakao.com

Package 1:autofs-5.0.7-56.el7.x86_64 already installed and latest version

Nothing to do

[kite@centos7:/]$ sudo vi /etc/auto

autofs.conf            auto.master.d/         auto.smb

autofs_ldap_auth.conf  auto.misc              

auto.master            auto.net          


[kite@centos7:/]$

[kite@centos7:/]$

[kite@centos7:/]$ sudo vi /etc/auto.master

[kite@centos7:/]$

[kite@centos7:/]$ cat /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

/nfs    /etc/auto.nfs  --timeout=60  --ghost  

# timeout : 60초간 사용이 없으면 연결 끊김 (네트워크 사용량 과 시스템 부하를 줄일 수 있음)

# ghost : 네트워크에 문제가 있어도 폴더를 표시함


#

# 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

# The included files must conform to the format of this file.

#

+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


[kite@centos7:/]$ sudo vi /etc/auto.nfs

[kite@centos7:/]$

[kite@centos7:/]$ cat /etc/auto.nfs

nas    nas:/volume1/file 

[kite@centos7:/]$

[kite@centos7:/]$

[kite@centos7:/]$ sudo systemctl status autofs.service

● autofs.service - Automounts filesystems on demand

  Loaded: loaded (/usr/lib/systemd/system/autofs.service; disabled; vendor preset: disabled)

  Active: inactive (dead)

[kite@centos7:/]$

[kite@centos7:/]$ sudo systemctl start autofs.service

[kite@centos7:/]$

[kite@centos7:/]$ sudo systemctl enable autofs.service

[kite@centos7:/]$

[kite@centos7:/]$ sudo systemctl status autofs.service

autofs.service - Automounts filesystems on demand

  Loaded: loaded (/usr/lib/systemd/system/autofs.service; enabled; vendor preset: disabled)

  Active: active (running) since Sat 2016-12-31 03:46:11 EST; 6s ago

 Process: 1305 ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid (code=exited, status=0/SUCCESS)

Main PID: 1307 (automount)

  CGroup: /system.slice/autofs.service

          └─1307 /usr/sbin/automount --pid-file /run/autofs.pid


Dec 31 03:46:11 centos7 systemd[1]: Starting Automounts filesystems on demand...

Dec 31 03:46:11 centos7 systemd[1]: Started Automounts filesystems on demand.

[kite@centos7:/]$

[kite@centos7:/]$ sudo systemctl enable  autofs.service

Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.

[kite@centos7:/]$

[kite@centos7:/]$ cd /nfs

[kite@centos7:nfs]$ cd nas

[kite@centos7:nas]$ ls

1_OS      ........


[kite@centos7:nas]$

[kite@centos7:nas]$ cd /

[kite@centos7:/]$ mount

<생략>

nas:/volume1/file on /nfs/nas type nfs (rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.x.x,mountvers=3,mountport=892,mountproto=udp,local_lock=none,addr=192.168.x.x)

[kite@centos7:/]$

[kite@centos7:/]$

[kite@centos7:/]$ df -h

<생략>

nas:/volume1/file        3.6T  2.0T  1.7T  54% /nfs/nas

[kite@centos7:/]$

[kite@centos7:/]$ sudo ln -s /nfs/nas /nas

[kite@centos7:/]$

[kite@centos7:/]$ ll

drwxr-xr-x    3 root root    0 Dec 31 03:46 nfs

lrwxrwxrwx    1 root root    8 Dec 31 03:49 nas -> /nfs/nas


[kite@centos7:/]$ cd nas

[kite@centos7:nas]$ pwd

/nas

[kite@centos7:nas]$

[kite@centos7:nas]$






감사합니다.!!

댓글