个人工具

UbuntuHelp:AutofsLDAP/zh

来自Ubuntu中文

Kmeng讨论 | 贡献2010年2月4日 (四) 05:20的版本 服务器(server)端

跳转至: 导航, 搜索

介绍

自动挂载是通过网络挂载目录的先进方法,并且非常容易管理非常节省带宽。在这个指南里,autofs将通过LDAP目录来配置。这样,我们将拥有一个集中的配置,并且可以最大化的利用已经配置起来的LDAP。很不错吧?

安装

首先,automount 由内核模块和用户界面工具这两部分组成。比较新的GNU/Linux发布版已经把automount编译进内核。你只要安装用户界面工具就可以了。需要安装的用户工具包括:autofs-ldap ldap-utils (参照 InstallingSoftware). 如果你只希望使用普通的配置文件,就不需要安装 autofs-ldap Autofs 介绍了安装过程.

配置

LDAP 自动挂载的配置有下面几部分组成:

  • 配置 openldap 服务器,从而加载 autofs-ldap 模式
  • 进入 LDAP 目录来定义挂载点
  • 进入 LDAP 记录来定义目录
  • 定义客户端使用 LDAP 的配置进行自动挂载

服务器(server)端

打开并修改 slapd 配置文件,让 slapd 后台程序加载ldap模式:/etc/ldap/schema/autofs-ldap.schema:

sudo nano /etc/ldap/slapd.conf

core.schemacosine.schema 之后加入下面2行:

#Schema and objectClass definitions
include /etc/ldap/schema/autofs.schema

最后重启 slapd 服务:

sudo /etc/init.d/slapd restart

Populating LDAP

In the LDAP directory, you have to enter two kinds of entries:

  • entry that defines the mountpoint
  • entry that defines the directory under a mountpoint

Here is an example of LDAP entries based on the OpenLDAPServer installation.

dn: ou=admin,dc=example,dc=com
ou: admin
objectClass: top
objectClass: organizationalUnit

dn: ou=automount,ou=admin,dc=example,dc=com
ou: automount
objectClass: top
objectClass: organizationalUnit

dn: ou=auto.master,ou=automount,ou=admin,dc=example,dc=com
ou: auto.master
objectClass: top
objectClass: automountMap
  
dn: cn=/home,ou=auto.master,ou=automount,ou=admin,dc=example,dc=com
cn: /home
objectClass: top
objectClass: automount
automountInformation: ldap:ou=auto.home,ou=automount,ou=admin,dc=example,dc=com --timeout=60 --ghost

dn: cn=lionel,ou=auto.home,ou=automount,ou=admin,dc=example,dc=com
cn: lionel
objectClass: top
objectClass: automount
automountInformation: -fstype=nfs,rw,hard,intr,nodev,exec,nosuid,rsize=8192,wsize=8192 nfs.example.com:/export/home/lionel

On the client

On the client, you only have to add the LDAP map to the automount entry of /etc/nsswitch.conf. Edit your /etc/nsswitch.conf and add the line:

automount:      files ldap

The package ldap-utils has to be configured. Edit /etc/ldap/ldap.conf:

BASE    dc=example,dc=com
URI     ldap://ldap.example.com

Launch

autofs looks in the LDAP directory for the automountMap. You just have to launch autofs:

sudo /etc/init.d/autofs start

Test

Just check with a mount that automount has been started correctly:

mount | grep automount
automount(pid5058) on /home type autofs (rw,fd=4,pgrp=5058,minproto=2,maxproto=4)