NIS服务
      RHEL4系统中NIS服务器软件的名称是ypserv,该软件包没有被系统默认安装,需要手动安装系统中的ypbind软件包是NIS客户
  端需要使用的软件包,yp-tools软件包中提供了对NIS服务器的查询和管理工具软件,这两个包是RHEL4系统中默认安装的。
      RHEL4安装光盘中提供了NIS服务器的RPM安装包,包文件名称是ypserv-2.13-5.i386.rpm.。位于第一张光盘中,管理员要使用
  rpm命令将该软件包安装到系统中。
*****************************************************************************************************
   服务端:
 
     1. 安装NIS服务器软件包
       
        NIS服务器软件包的名称是ypserv,系统默认是没有安装的,位于第1张光盘中。
 
               mount  /media/cdrom
               rpm -q portmap 
               cd /media/cdrom/RedHat/RPMS
               rpm -ivh ypserv-2.13-5.i386.rpm
                          
          warning: ypserv-2.13-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
          Preparing...                ########################################### [100%]
          1:ypserv                 ########################################### [100%]
——————————————————————————————————
      2.创建域名
                 nisdomainname kaitian     创建一个名为“kaitian”的域名
————————————————————————————————————
      3.启动nis服务
        
                 /etc/rc.d/init.d/ypserv start
                 /etc/rc.d/init.d/yppasswdd start   (作用是可以使客户端自己修改密码)
————————————————————————————————————
      4.创建新用户
        
                adduser Dennis     建用户
                passwd  Dennis
 
                Changing password for user qun.
                New UNIX password:   设密码
                Retype new UNIX password:   重复密码
                passwd: all authentication tokens updated successfully.
————————————————————————————————————
      5.将用户映射到数据库里
   
            /usr/lib/yp/ypinit -m  将用户映射到数据库,(每次新加用户都要重写数据库,将用户映射到数据库。)
 
                  At this point, we have to construct a list of the hosts which will run NIS
            servers.  rhel4.benet.com is in the list of NIS server hosts.  Please continue to add
            the names for the other hosts, one per line.  When you are done with the
            list, type a <control D>.
                    next host to add:  rhel4.benet.com
                    next host to add:   (在此处按ctrl+D键)
            The current list of NIS servers looks like this:
            rhel4.benet.com
            Is this correct?  [y/n: y]  y   (在此处回答为“y”)
            We need a few minutes to build the databases...
            Building /var/yp/aa/ypservers...
            Running /var/yp/Makefile...
            gmake[1]: Entering directory `/var/yp/aa'
            Updating passwd.byname...
            Updating passwd.byuid...
            gmake[1]: Leaving directory `/var/yp/aa'
            rhel4.benet.com has been set up as a NIS master server.
            Now you can run ypinit -s rhel4.benet.com on all slave server.
    ypinint命令将根据NIS服务器主机中的本地系统文件信息创建数据库文件,
    建立的数据库文件保存在“var/yp”中与NIS域名同名的子目录中
————————————————————————————————————
  
######################################################################################################
 
   客户端

*****************************************************************************************************
       1.修改主机名(服务端和客户端的主机名不能相同!!)
            hostname    web.benet.com
     
            vi /etc/hosts   在NIS客户机中的Hosts中添加NIS服务器的主机名解析记录,以便NIS客户机能够只用主机名访问NIS服务器
  
            # Do not remove the following line, or various programs
            # that require network functionality will fail.         
            127.0.0.1               web.benet.com web localhost.localdomain localhost
            172.16.3.68             rhel4.benet.com    加上服务器IP与名字
    
            vi /etc/sysconfig/network     修改主机名
            NETWORKING=yes
            HOSTNAME=web.benet.com
            ~
————————————————————————————————————
        2.将服务器上的/home目录挂载到客户机本地
            mount   rhel4.benet.com:/home     /home
         
            vi /etc/fstab    启动自动加载项
  
           # This file is edited by fstab-sync - see 'man fstab-sync' for details
            LABEL=/                 /                     ext3    defaults        1 1
            LABEL=/boot             /boot                 ext3    defaults        1 2
            none                    /dev/pts              devpts  gid=5,mode=620  0 0
            none                    /dev/shm              tmpfs   defaults        0 0
            none                    /proc                 proc    defaults        0 0
            none                    /sys                  sysfs   defaults        0 0
            LABEL=SWAP-hda2         swap                  swap    defaults        0 0
            /dev/hdc                /media/cdrom          auto    pamconsole,exec,noauto,managed 0 0
            /dev/fd0                /media/floppy         auto    pamconsole,exec,noauto,managed 0 0
            rhel4.benet.com:/home   /home                 nfs     defaults        0 0 (添加此行内容)
————————————————————————————————————--  
        3.
            输入:setup 命令
   
            接下来选择第一项 Authentication configuration
            接下来选中 Use NIS
 
            在弹出的对话框中domain和server中添入相应的域名和服务器名
#####################################################################################################

   测试命令:
 
     yptest
           是基本的NIS服务器测试命令,该命令会对NIS服务器的域名、主机、数据库及其内容进行自动测试,并显示结果。
     ypwhich
           可以显示NIS客户机所使用的NIS服务器的主机名称,当ypwhich使用“-x”选项时显示使用的数据库和映射文件的名称。
     ypcat
          ypcat -x 命令会与 ypwhich -x 命令显示相同的查询信息,当使用数据库名作为ypcat命令的参数时,将会显示指定数据库的内容。管理员可以从ypcat命令结果中看到NIS服务器数据库中非常有用的信息。
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    NIS服务的应用
          通过前面NIS服务器与客户机的设置,已经实现了用户账户的集中管理,但是在NIS客户机的本地文件系统中没有建立用户的本地账号,因此不存在用户的宿主目录,下面通过NFS服务和NIS服务的综合运用,实现用户登录任何一个NIS客户机后都使用同一个属主目录。
————————————————————————————————————

      1.在NIS服务器中输出nis共享目录
 
       NIS服务器主机中具有所有用户的本地账号,因此NIS服务器的文件系统中也为每个用户建有宿主目录,所有普通用户的宿主目录都在“/home”目录中,因此可以将“/home”作为NFS共享目录输出给所有的NIS客户。
 
             vi /etc/exports
      
            /home             *(async,rw,no_root_squash)
            
            ~
————————————————————————————————————     
      2.启动服务
 
            /etc/rc.d/init.d/nfs start
————————————————————————————————————
      3. 输出目录
                 
            exportfs
        
            /home         <world> 
————————————————————————————————————