linux-NIS

PUTTY 软件操作
login as: root
Sent username "root"
[email protected]'s password:
Last login: Fri Apr  4 16:11:12 2008
安装 winscp403setupintl 软件 , ypserv-2.13-5.i386.rpm 托入到 LINUX 中的 /ROOT 目录中
 [root@localhost ~]# cd /root                                  进入 /ROOT 目录
[root@localhost ~]# ls                                      查看软件包
anaconda-ks.cfg  install.log         ypserv-2.13-5.i386.rpm
Desktop          install.log.syslog
[root@localhost ~]# rpm -ivh ypserv-2.13-5.i386.rpm              安装软件包 , 很快 , 一般只要几秒钟
warning: ypserv-2.13-5.i386.rpm: V3 DSA signature: NOKEY, key ID 4f2a6fd2
Preparing...                ########################################### [100%]
   1:ypserv                 ########################################### [100%]
[root@localhost ~]# nisdomainname nis.benet.com     设置 NIS 域名       
[root@localhost ~]# adduser st01                             新建用户                     
[root@localhost ~]# passwd st01                              设置密码
Changing password for user st01.
New UNIX password:
BAD PASSWORD: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]#
[root@localhost ~]# vi /etc/ypserv.conf                            可以不修改配置文件 , 我没有修改
[root@localhost ~]# service portmap start                 NIS 服务需要 PORTMAP 服务的支持
Starting portmap:                                          [  OK  ]
[root@localhost ~]# service ypserv start                    NIS 服务需要启动这个服务
Starting YP server services:                               [  OK  ]
[root@localhost ~]# service yppasswdd start                    NIS 服务需要启动这个服务
Starting YP passwd service:                                [  OK  ]
[root@localhost ~]# /usr/lib/yp/ypinit �Cm                   初使化数据库
 
At this point, we have to construct a list of the hosts which will run NIS
servers.  localhost.localdomain 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>.        CTRL D
        next host to add:  localhost.localdomain
        next host to add:
The current list of NIS servers looks like this:
 
localhost.localdomain
 
Is this correct?  [y/n: y]  y        Y
We need a few minutes to build the databases...
Building /var/yp/nis.benet.com/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/nis.benet.com'
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
Updating hosts.byname...
Updating hosts.byaddr...
Updating rpc.byname...
Updating rpc.bynumber...
Updating services.byname...
Updating services.byservicename...
Updating netid.byname...
Updating protocols.bynumber...
Updating protocols.byname...
Updating mail.aliases...
gmake[1]: Leaving directory `/var/yp/nis.benet.com'
 
localhost.localdomain has been set up as a NIS master server.
 
Now you can run ypinit -s localhost.localdomain on all slave server.
 
 
 
在客户机上的配置
[root@localhost ~]# rpm �Cqa |grep ypbind 查看客户机上有无安装客户端软件 , 这里已经安装了
ypbind-1.17.2-3    这条命令运行的时间较才 , 大概有 2 分钟
[root@localhost ~]# nisdomainname nis.benet.com     设置域名              
[root@localhost ~]#hostname nis.benet.com                     主机名要和 NIS 域名一致
[root@localhost ~]#setup 用这个软件修改配置文件 , 我改了域名 , 服务器 IP
或直接修改配置文件用这条命令 vi //etc/yp.conf , 这两种可以任选一种
[root@localhost ~]# service portmap start          NIS 服务需要这个服务的支持
Starting portmap:                                          [  OK  ]
[root@localhost ~]# service ypbind restart                 NIS 要启动这个服务    
Shutting down NIS services:                                [  OK  ]
Binding to the NIS domain:                                 [  OK  ]
[root@localhost ~]# service yppasswdd restart          NIS 要启动这个服务
Stopping YP passwd service:                                [  OK  ]
Starting YP passwd service:                                [  OK  ]
 [root@localhost ~]# chkconfig --level 35 ypbind on         启动 ypbind 35
 [root@localhost ~]# su - st01
su: warning: cannot change directory to /home/st01: No such file or directory
-bash-3.00$ 因为本地没有服务器上的 /HOME 目录 , 所以有这样的反应
 
 
在服务器上配置文件共享
[root@localhost ~]# rpm -qa |grep nfs         查看有无 NFS 目录
nfs-utils-1.0.6-65.EL4  
[root@localhost ~]# chkconfig --level 35 nfs on
[root@localhost ~]# service portmap start          NFS 需要先启动这个服务
Starting portmap:                                          [  OK  ]
[root@localhost ~]# service nfs start           启动 NFS 服务
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
[root@localhost ~]# vi /etc/exports  写出要共享的条目
/home       *(rw,sync)
~
 
 
[root@localhost ~]# exportfs �Crv                导出目录
exporting *:/home
[root@localhost ~]# showmount �Ce            查看导出的目录
Export list for localhost.localdomain:
/home *
 
[root@localhost ~]# vi /etc/fstab
 
# This file is edited by fstab-sync - see 'man fstab-sync' for deta:
192.168.9.150 :/home     /home                      nfs     defaults        0 0
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-sda2         swap                    swap    defaults        0 0
/dev/hdc                /media/cdrom            auto    pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0
/dev/fd0                /media/floppy           auto    pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0
~
~
其中的 192.4168.150 为服务器名称紧跟在后的 :/HOME 为共享目录 ,/HOME 为本地挂载点 ,NFS 为文件格式 , 其中的 0 0 表示开机不做磁盘检查 , 如果是 0 1 则表示开机做磁盘检查 ,
0 0 只能用上面一排的键盘搞 , 不能用右边的数字搞
 
 
[root@localhost ~]# service portmap start                 在客户机上启动这个服务支持 NFS
Starting portmap:                                          [  OK  ]
[root@localhost ~]# service nfs start                      只有启动 NFS 服务 , 才能挂载目录
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
 
[root@localhost ~]# mount /home                      这条命令也很快 , 一般也只有 2 3 秒钟
[root@localhost ~]# su - st01
[st01@nis ~]$                                                   现在用户登录的显示是正常的
 
 
修改密码则需要 TIME TIME-UDP 这两个服务的支持 , 启动后要重启 XINETD 服务
CHKCONFIG TIME ON
CHKCONFIG YPSERV START
SERVICE XINETD START
VI /ETC/HOSTS 中添加一条记录
 

你可能感兴趣的:(linux,服务器,职场,休闲,NIS)