Wednesday, March 04, 2009

解决Sendmail和NIS配置出failed to send 'clear' to local ypserv: RPC:的问题

这两件东西得一起说,前一段时间解决了sendmail开机胡慢的问题,因为改了/etc/sysconfig/network 里面的hostname,开机的时候sendmail需要很长时间来处理,解决的办法是更改/etc/hosts 里面
127.0.0.1 localhost.localdomain localhost

127.0.0.1 yourhostname.localdomain yourhostname
但现在发现这样改在建立nis数据库的时候总是会出这样的错误:

failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating passwd.byuid...
failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating group.byname...
failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating group.bygid...
failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating hosts.byname...
failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating hosts.byaddr...
failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating rpc.byname...
failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating rpc.bynumber...
failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating services.byname...
failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating services.byservicename...
failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating netid.byname...
failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating protocols.bynumber...
failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating protocols.byname...
failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating mail.aliases...
failed to send 'clear' to local ypserv: RPC: Unknown hostgmake[1]: Leaving directory `/var/yp/test'

这个问题我找了很久都没有解决,自己试验了n多次才搞定。解决方法:
更改hosts文件的时候必须保留以前的
127.0.0.1 localhost.localdomain localhost
位置前后没有关系。

下面给出配置的步骤,很简单:

一、查看包安装情况

# rpm -qa grep portmap
portmap-4.0-65.2.2.1


# rpm -qa grep ^yp (这个^是转义字符,什么意思做下试验去掉看看不同就知道了)
ypbind-1.19-8.el5
yp-tools-2.9-0.1

发现没有安装ypserv

二、安装ypserv

# yum -y install ypserv
三、配置NISDOMAIN

# vim /etc/sysconfig/network
加入一行
NISDOMAIN=test (这个名字可以随便起)

四、启动服务以及建立数据库

# service ypserv start
Stopping YP server services: [ OK ]
Starting YP server services: [ OK ]

检查一下nisdomain配置好了没

# ypdomainname
test

OK,这里提一句,如果更改了NIASDOAMIN的内容需要使用

# ypdomainname -y NewNISdomainname
才能生效

生成数据库:

# /usr/lib/yp/ypinit -m
At this point, we have to construct a list of the hosts which will run NIS
servers. cp2.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 .
next host to add: cp2.localdomain
next host to add:

按下control+D

The current list of NIS servers looks like this:

cp2.localdomain

Is this correct? [y/n: y]

按下y回车

正常的话会显示:

We need a few minutes to build the databases...
Building /var/yp/test/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/test'
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/test'

cp2.localdomain has been set up as a NIS master server.

Now you can run ypinit -s cp2.localdomain on all slave server.

如果出现上面的错误就得检查一下你的hosts文件了

客户端连接的时候打开setup 选择里面的Authentication configuration 选择Use NIS 输入相关配置就好了。

希望这篇文章对您有帮助,如果遇到问题请留言或和我联系。
Copyright © 2006 - 2009 iCNPunk.BlogSpot.COM All rights reserved By ZerOnenOreZ & Blogger
Template Designed By iCNPunk Fixed for IE7