0272-0274.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 408 行

HTML
408
字号


<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:TCP/IP Network Management</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311739 //-->

<!-- TITLE=RED HAT LINUX 2ND EDITION //-->

<!-- AUTHOR=DAVID PITTS ET AL //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS PUBLISHING //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=13 //-->

<!-- PAGES=0243-0298 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="0269-0271.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0275-0277.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-272"><P>Page 272</P></A>













<P>Most of these entries can remain the same. The few that you will want to change are

GROUP, PASSWD, SHADOW, ALIASES, and possibly HOSTS.

</P>









<P>The GROUP line shows that the file for controlling group information is at

/etc/group. You might want to keep your local group file on the server separate from your NIS group file because

your local group file could contain server-specific groups that you don't want to share across

NIS, such as the www group for your Web server.

</P>









<P>The same holds true for the other lines as well, especially the

PASSWD line. A simple convention you might want to use to indicate that the file is being shared across NIS is to suffix it with

a .yp. The resulting line looks something like the following:

</P>





<!-- CODE SNIP //-->

<PRE>

PASSWD        = $(YPPWDDIR)/passwd.yp

</PRE>

<!-- END CODE SNIP //-->











<P>With the filenames you want set, you can now determine which files to distribute. Scroll

down the Makefile past the following block:

</P>





<!-- CODE //-->

<PRE>

# If you don't want some of these maps built, feel free to comment

# them out of this list.

# Note that we don't build the eithers or bootparams maps by default

# since /etc/ethers and /etc/bootparams are not likely to be present

# on all systems

#

</PRE>

<!-- END CODE //-->











<P>Your cursor should be at the following line:</P>





<!-- CODE SNIP //-->

<PRE>

all: passwd hosts group netid networks protocols rpc services netgrp

&Acirc;mail shadow ypservers publickey ethers # amd.home bootparams

</PRE>

<!-- END CODE SNIP //-->











<P>This line specifies which maps will be made available via NIS. The

# symbol after ethers is the comment symbol. The

amd.home and bootparams maps are commented out at the moment.

</P>









<P>Before making any changes to this line, you should make a copy of it and comment the

copy out. The result looks something like the following:

</P>





<!-- CODE //-->

<PRE>

#all: passwd hosts group netid networks protocols rpc services netgrp

#mail shadow ypservers publickey ethers # amd.home bootparams



all: passwd hosts group netid networks protocols rpc services netgrp

&Acirc;mail shadow ypservers publickey ethers # amd.home bootparams

</PRE>

<!-- END CODE //-->











<P>By commenting out the line, you can retain a copy of it just in case something goes

wrong. You can always look back to it and see how it looked before things were changed. With

the copy in place, go ahead and begin your changes.

</P>









<P>The only files you need to distribute for your network are the

passwd, hosts, group, netid, protocols, rpc,

services, mail, and ypservers. To indicate this change, edit the

uncommented version of the line to read:

</P>





<!-- CODE SNIP //-->

<PRE>

all: passwd hosts group netid protocols rpc services mail ypservers

</PRE>

<!-- END CODE SNIP //-->











<P>Unless you are comfortable with Makefiles, you should leave the remainder of the file

alone. Save the Makefile and quit the editor.

</P>



<A NAME="PAGENUM-273"><P>Page 273</P></A>













<P>You are now ready to initialize your NIS database. This is done with the

/usr/lib/yp/ypinit command. When invoked, it will prompt for the name of any NIS slave servers you want to

set up. For this example, select denon to be the slave NIS server.

</P>









<P>Remember that you do not have to set up a slave NIS server. Setting up a slave server is

only useful if you have a large number of NIS clients and need to distribute the load they generate.

</P>









<P>To initialize the master server, use the following:</P>





<!-- CODE //-->

<PRE>

[root@vestax /root]# /usr/lib/yp/ypinit -m

At this point, we have to construct a list of the hosts which will run NIS

servers. vestax 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 &lt;control D&gt;.

    next host to add:  vestax

    next host to add:  denon

    next host to add: &lt;CTRL-D&gt;

The current list of NIS servers looks like this:



vestax

denon



Is this correct?  [y/n: y]  y

We need some minutes to build the databases...

Building /var/yp/audionet.domain.com/ypservers...

Running /var/yp/Makefile...

NIS Map update started on Mon May  5 22:16:53 PDT 1997

make[1]: Entering directory `/var/yp/audionet.domain.com'

Updating passwd.byname...

Updating passwd.byuid...

Updating hosts.byname...

Updating hosts.byaddy...

Updating group.byname...

Updating group.bygid...

Updating netid.byname...

Updating protocols.bynumber...

Updating protocols.byname...

Updating rpc.byname...

Updating rpc.bynumber...

Updating services.byname...

Updating mail.aliases...

make[1]: Leaving directory `/var/yp/audionet.domain.com'

NIS Map update completed

</PRE>

<!-- END CODE //-->











<P>If anywhere in the middle of the output you received a message

like the following instead

</P>





<!-- CODE SNIP //-->

<PRE>

make[1]:***No rule to make target `/etc/shadow', needed by `shadow.byname'. Stop.

make[1]: Leaving directory `/var/yp/audionet.domain.com'

</PRE>

<!-- END CODE SNIP //-->











<P>it means that you are missing one of the files you listed in the

Makefile. Go back and check that you edited the

Makefile as you intended and then check to make sure that the files

you selected to be shared via NIS actually do exist. After you've made sure of these, you do

not need to rerun ypinit but instead can just rerun

cd /var/yp;make.

</P>









<P>Congratulations! You now have an NIS master server! Time to test the work with an NIS

client.

</P>



<A NAME="PAGENUM-274"><P>Page 274</P></A>













<H4><A NAME="ch13_ 36">

Configuring an NIS client

</A></H4>









<P>Compared to configuring an NIS server, NIS clients are trivial. There are only four files

you need to deal with, one of which is only one line long.

</P>









<P>Begin by creating the /etc/yp.conf file. This file needs only two lines, one to specify the

NIS domain name and the other to specify the NIS server hostname. The format of this file is

</P>





<!-- CODE SNIP //-->

<PRE>

domainname domainname

ypserver nis_server

</PRE>

<!-- END CODE SNIP //-->











<P>where domainname is the name of your NIS domain and

nis_server is the server's hostname. For this example, this file should look like the following:

</P>





<!-- CODE SNIP //-->

<PRE>

domainname audionet.domain.com

ypserver vestax.domain.com

</PRE>

<!-- END CODE SNIP //-->











<P>The next step is to modify the startup scripts so that your

domainname gets set every time you boot. To do this, edit the

/etc/rc.d/rc.local script and add the following lines to it:

</P>





<!-- CODE //-->

<PRE>

#

# Setup NIS domain name

#

if [ -f /etc/domainname ]; then

    domainname `cat /etc/domainname'

    echo &quot;NIS domain: `domainname'&quot;

fi

</PRE>

<!-- END CODE //-->











<P>This modification checks for the file

/etc/domainname. If /etc/domainname is found, the

NIS domain is set to the contents of that file.

</P>









<P>In order to get the modification to

/etc/rc.d/init.d/rc.local to be useful, you need to

create the /etc/domainname file. The content of the file

should be only the NIS domain name on the first line with

no subsequent lines. For the sample network, this looks like the following:

</P>





<!-- CODE SNIP //-->

<PRE>

audionet.domain.com

</PRE>

<!-- END CODE SNIP //-->











<P>The last file that needs to be changed is the

/etc/nsswitch.conf file. This is slightly more involved than the previous files; however, a default file comes as part of the Red Hat

installation. This file is used to configure which services are to be used to determine information such

as hostnames, password files, and group files.

</P>









<P>Begin by opening /etc/nsswitch.conf with your favorite editor. Scroll down past the

comments (those lines beginning with the # symbol). You should see something like this:

</P>





<!-- CODE //-->

<PRE>

passwd:    files nis

shadow:    files nis

group:    files nis



hosts:    files nis dns



services:     files [NOTFOUND=return] nis

etc...

</PRE>

<!-- END CODE //-->





<P><CENTER>

<a href="0269-0271.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0275-0277.html">Next</A>

</CENTER></P>









</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?