分类: linux
2007-06-27 16:45:41
you can stop and start most nfs daemons either by using commands or by using smit, which ultimately calls src commands. the exceptions are rpc.rexd, rpc.ruserd, rpc.rwalld, and rpc.rsprayd, which are started by inetd. the following subsystems are part of the nfs group: nfsd, biod, rpc.lockd, rpc.statd, and rpc.mountd.
to start the nfs group, type:
# -g nfs
this starts all of the daemons of the nfs group as well as the appropriate number of each. for nfsd and biod the default number of daemons is eight. to change these defaults, you must do one of the following:
# -n4 -b4
# -s biod -a6
the chnfs command stops currently running nfsds and biods, updates the database to reflect the new defaults (in this case four daemons each), and then restarts the daemons using commands. the chssys command changes the cmdargs descriptor in a subsystem definition, in this case the biod subsystem. therefore anytime you run the following command:
# startsrc -s biod
the value of the -a parameter is used to determine the number of biods to start, in this case six. you can start any subsystem with the startsrc -s command or stop one with the -s command. for example:
# startsrc -s rpc.lockd
# stopsrc -s rpc.mountd
the file that controls the nfs (and nis for that matter) daemons on startup is . to disable nfs upon bootup, either remove the line containing that file name from the file or run the smit rmnfs command and select restart in the stop nfs now, system restart or both field. to enable nfs upon bootup it is best to use the command because it is easy to make a syntax error trying to edit /etc/inittab by hand.
note that /etc/rc.nfs controls the startup of both nfs and nis. if you want to disable nis but not nfs you can comment out the appropriate lines in /etc/rc.nfs or run smit rm or . do not remove the rcnfs line in /etc/inittab if you want only to disable nis.
to configure an nfs server in aix, all you do is create an file and then run smit mknfs. you can use a text editor to create /etc/exports or you can do the following:
#
add a directory to exports list
type or select values in entry fields.
press enter after making all desired changes.
[entry fields]
* pathname of directory to export [] /
* mode to export directory read-write
hostname list. if exported read-mostly []
anonymous uid [-2]
hosts allowed root access []
hosts & netgroups allowed client access []
use secure option? no
* export directory now, system restart or both both
pathname of exports file if using ha-nfs []
the required entries are pathname of directory to export, mode to export directory, and export directory now, system restart or both. fill in these parameters and press enter. smit will create or update the file and then run the -a command. the other parameters are optional and can be determined by consulting the exports man page. run the smit chnfs command.
to start the nfs daemons,
#
start nfs
type or select values in entry fields.
press enter after making all desired changes.
[entry fields]
* start nfs now, on system restart or both both
pressing enter at this point starts all the daemons of the nfs group and puts an entry in the file to make the changes permanent.
you can use the same procedure as above, run smit mknfs to start the nfs daemons-and in the case of an nfs client the biods are the only ones you might want-or you can simply start making nfs mounts from a server by doing the following:
#
add a file system for mounting
type or select values in entry fields.
press enter after making all desired changes.
[entry fields]
* pathname of mount point [] /
* pathname of remote directory []
* host where remote directory resides []
mount type name []
* use secure mount option? no
* mount now, add entry to or both? now
* /etc/filesystems entry will mount the directory no
on system restart.
* mode for this nfs file system read-write
* attempt mount in foreground or background background
number of times to attempt mount [] #
buffer size for read [] #
buffer size for writes [] #
nfs timeout. in tenths of a second [] #
internet port number for server [] #
* mount file system soft or hard hard
allow keyboard interrupts on hard mounts? yes
minimum time, in seconds, for holding [3] #
attribute cache after file modification
maximum time, in seconds, for holding [60] #
attribute cache after file modification
minimum time, in seconds, for holding [30] #
attribute cache after directory modification
maximum time, in seconds, for holding [60] #
attribute cache after directory modification
minimum & maximum time, in seconds, for [] #
holding attribute cache after any modification
the maximum number of biod daemons allowed [6] #
to work on this file system
* allow execution of suid and sgid programs yes
in this file system?
* allow device access via this mount? yes
* server supports long device numbers? yes
the required entries are denoted by the asterisk (*), are fairly obvious, and have default values which you will in most cases prefer. however, a couple entries need some additional explanation. for mount now, add entry to or both? the default value is now. if you accept the default, smit will make the mount, but the mount will be in effect only until system restart or until you explicitly unmount the file system with the command. selecting the value of both will not only result in the mount but also an entry in the /etc/filesystems file.
as explained in the chapter on disks and file systems, /etc/filesystems is aix's equivalent to hp-ux's file, which determines which file systems are mounted on bootup. both files will mount networked file systems as well as local ones; the only difference is their format. if, for example, you mounted the file system /doc from the machine elmo and had an entry for that mount in /etc/filesystems, that entry would look something like:
/doc:
dev = "/doc"
vfs = nfs
nodename = elmo
mount = false
options = bg,hard,intr
account = false
this example also illustrates the other entry in the mknfsmnt screen which needs a little explanation: /etc/filesystems entry will mount the directory on system restart. the default value is no, which results in a mount=false line in /etc/filesystems, like in the one above. this means that the remote file system will not be mounted by default upon system restart. if the line reads mount=true, then the system will attempt to make the nfs mount upon system restart. if it cannot because the server is unavailable, then additional mount requests will occur in the background (options=bg denotes this). in some cases it is better to have the mount parameter be false. if, for example, you have several mounts from the same server and it is down, the boot process will not be bogged down by attempting to make remote mounts for each networked file system, in which case it might be better to have an /etc/rc.local file to complete the mounts once everything else is up and running.
for additional information on the options available in making nfs s, see the mount, mknfsmnt, and filesystems man pages.
remove an entry from the file:
#
change an exported file system:
#
remove an nfs mount:
# smit rmnfsmnt
the basic configuration steps are listed below and detailed in the sections that follow.
configure the systems for nfs if you have not already done so.
the master map is usually created as /etc/auto.master and then made into the nis map auto.master. by default, automount tries to get master map information from the nis map auto.master. if a local master map file is specified on the command line, automount reads it before reading the nis auto.master map.
the format of the auto.master file is:
directorypath automountmapname
where:
automount maps are usually named auto.xxx, where xxx is the name of the map. the name does not have to correspond to any mount points, but it is recommended that the map name correspond to the directory contents (for example, auto.man for man pages).
as with all nis maps, names must be 10 characters or less if you have file systems that do not allow file names longer than 14 characters. this is because nis adds four-character suffixes (.dir and .pag) to the map name.
the format of the map entries is:
key [-mount options] server:directory
where:
automount recognizes special characters in direct and indirect maps to be used for substitutions and to escape other characters. they are:
& | can substitute key values into the directory path names |
* | is recognized as a catch all entry (a wildcard). it is the last or only entry in a map. it matches all keys and provides a value for the & substitutions that may exist in the right-hand side of a map. for example: * -ro,intr server:/users/& |
mapname | the contents of another map can be included within the current map. if mapname is a directory with no slashes, automount interprets it as an nis map. if the directory has slashes then automount looks for a local map with that name. |
automount maps can be local files or administered as nis maps. by default, automount tries to read master map information from the nis map auto.master. automount also reads master map information from a local file if you specify one on the command line.
the master map can contain nis map names for the indirect and direct maps instead of file names. to specify an nis map, preface the map name with a plus ( ).
to create an nis map, edit the /var/yp/makefile:
auto.master.time: $(dir)/auto.master
-@if [ -f $(dir)/auto.master ]; then \
$(makedbm) $(dir)/auto.master $(ypdbdir)/$(dom)/auto.master; \
touch auto.master.time; \
if [ ! $(nopush) ]; then \
$(yppush) auto.master; \
echo "pushed auto.master"; \
else \
: ; \
fi \
else \
echo "couldn't find $(dir)/auto.master"; \
fi
# cd /var/yp
# auto.master
the full pathname in aix is /usr/sbin/automount. the options found in the automount man page are the same as those for the hp-ux version. you can also start automount by typing the t command. if you want to start automount on bootup, the best place to put it is at the end of the file, something you will have to do manually since smit doesn't do it for you.
automount is normally started and stopped only when the machine is rebooted. to shut down automount gracefully during system operation, take the following steps:
caution: no other automount daemon should be started until the first has successfully cleaned up and exited. if a second automount daemon is started when the first is in its shutdown process, the second daemon will start its shutdown process. this means that there will now be four automount daemons: the first, the second, and their children. these daemons will not exit until all the mount directories they are serving have been unmounted.
do not send the sigkill signal (kill -9, kill -kill) to the automount daemon. this will cause any processes accessing mount directories served by automount to hang. the file hierarchies mounted by automount under /tmp_mnt will still be accessible.
at the sam main window, highlight networking/communications and activate the open button.
this task lets you allow or deny access to specific rpc services (servers). when you perform this task, you are editing the file. the information you need to complete this task is the remote system names to which you are allowing or denying access.
to perform this task:
you must be superuser to create an nfs server. to create an nfs server, complete the following steps. these steps are described in detail in the sections that follow.
the /etc/netnfsrc file activates the nfs daemons and servers. to define the node as an nfs server, set the nfs_server variable to any digit other than zero. set start_mountd to any digit other than 0. mountd can be started from netnfsrc on inetd. if mountd has an entry in inetd.conf the start_mountd should be 0. if the node is also a client, you may want to set the nfs_client variable to any digit other than zero now. if the node is also a server for pc-nfs requests, set the pcnfs_server variable to any digit other than zero.
client only
|
nfs_client=1
nfs_server=0
|
server only
|
nfs_client=0
nfs_server=1
start_mountd=1
|
both client and server
|
nfs_client=1
nfs_server=1
start_mountd=1
|
neither client nor server
|
nfs_client=0
nfs_server=0
|
pc-nfs server
|
pcnfs_server=1
start_mountd=1
|
you can refer directly to the comments for editing instructions and for descriptions of each activity executed by :
#!/bin/sh
## configured using sam by root on tue jul 18 14:41:23 1995
## @(#)netnfsrc: $revision: 1.51.109.9 $ $date: 92/08/18 13:48:27 $
# netnfsrc -- nfs startup file
##
# depending on the configuration parameters you set within,
# this script sets up some or all of the following:
# nis specific:
# domainname -- the nis domain name
#
# and starts up some or all of the following programs:
# portmap -- rpc (program_#,version) -> port_# mapper
# nfsd -- nfs daemons
# biod -- async bio daemons
# pcnfsd -- pc-nfs daemon
# nis specific:
# ypbind -- nis client process (all nis nodes)
# ypserv -- nis server process (nis server only)
# yppasswdd -- nis password daemon (nis master server only)
##
# nfs_client -- 1 if this node is an nfs client, 0 if not
# nfs_server -- 1 if this node is an nfs server, 0 if not
# note: it is possible for one host to be a client, a server, both
# nfs_server -- 1 if this node is an nfs server, 0 if not
# note: it is possible for one host to be a client, a server, both
# or neither! this system is an nfs client if you will be
# nfs mounting remote file systems; this system is a server
# if you will be exporting file systems to remote hosts.
# see also: nfsd(1m), mount(1m).
##
nfs_client=1
nfs_server=1
##
# start_mountd -- 1 if this script should start rpc.mountd.
# 0 if /etc/inetd.conf has an entry for mountd.
# note: rpc.mountd should be started from netnfsrc. however, it
# can be started from either netnfsrc or inetd, and
# must only be configured in one place.
##
start_mountd=1
##
. . .
##
#pcnfs_server -- 1 if this node is a server for pc-nfs requests.
# this variable controls the startup of the
# pcnfsd(1m) server. see also: pcnfsd(1m).
##
pcnfs_server=0
to activate the rpc services, remove all # comment marks from /etc/inetd.conf lines beginning with #rpc. after editing /etc/inetd.conf, you must reconfigure inetd by entering:
-c
the inetd security facility works only when the inetd executes a server. for the rpc services that do not exit after each service request, inetd provides a security check only for the first request. successive requests bypass the inetd and are subject only to the security checking performed by the individual rpc services. however, you can make the inetd perform a security check for every rpc request by doing both of the following steps:
note: adding the -e option makes the rpc server respond slower since it has to restart for each request.
suppose contains the following:
rpc dgram udp wait root /usr/etc/rpc.mountd 100005 1 rpc.mountd -e
the rpc.mountd program is the server for the command and reads to see what the available directories or files are and to whom they are exported. it also keeps a list of all mounted directories or files. the -e option forces inetd to perform a security check for rpc.mountd on every request.
nfs operates under the assumption you have a friendly network; meaning, you can trust all users attached to your network. since this assumption may not apply to everyone, refer to the following sections to improve your file security.
the configuration file is provided in the arpa services product. it is not solely for nfs access. this file allows you to determine:
on the first line in , enter the maximum number of simultaneous remote services to be started by inetd as shown in the following example:
maxnum number
if you do not specify a maxnum value, the default is 1000.
each entry in has the following format (enter either allow or deny):
service_name allow/deny host_specifier(s)
where:
service_name | name of a valid service (include rpc services) with an entry in /etc/inetd.conf/etc/inetd.conf
for rpc services, service_name is the name of the service that matches its program number in /etc/rpc. this entry must have a corresponding entry in /etc/inetd.conf/etc/inetd.conf which contains the -e option. specify only one service per entry. if an entry in /usr/adm/inetd.conf specifies the service name and nothing else, inetd allows all hosts to attempt access. |
allow/deny | the allow entry instructs inetd to approve the host or network for access to the specified service.
the deny entry instructs inetd to disapprove the host or network for access to the specified service. |
host_specifier(s) | name of a host or a network listed in /etc/hosts/etc/hosts or /etc/networks, or an internet address in the standard internet notation.
you can specify more than one host or network by separating each host_specifier with a blank or tab. you can use the asterisk (*) or dash (-) in any field of a network or host address. you cannot use aliases. |
the /etc/netgroup file enables you to define a specific network-wide group of nodes as a netgroup. you can then limit directory access by exporting directories or files (via and exportfs) to the netgroups defined. the system uses /etc/netgroup to verify host names whenever clients perform remote mounts.
you make the directories or files and their access restrictions, if any, available by your entries in the server's /etc/exports file. when you boot up the nfs server, the file will automatically run the exportfs daemon, which looks up /etc/exports and makes the directories or files available for nfs clients to access. you can export and unexport directories or files after the server is up or change access permissions of the exported directory by using the exportfs command. the exportfs command can be run at any time by the superuser to alter the list or characteristics of exported directories and filenames. for details on constructing the /etc/exports file, see the man page on exports(4). also refer to exportfs(1m).
after you finish the configuration procedure, execute or reboot the system to activate the daemons and servers. the rebooting process does not unmount any of the server's directories or files that were remotely mounted by other network nodes. however, these nodes will not be able to access any of the server's files until the server is operating again.
the basic configuration steps are listed below and detailed in the sections that follow.
configure the systems for nfs if you have not already done so. this task includes adding nfs to the kernel and editing . on the servers, edit .
the master map contains the names of the indirect and direct maps. it also contains the names of common mount directories for indirect maps. you do not need a master map if you pass all the map information to automount in the command line.
the master map is usually created as /etc/auto.master and then made into the nis map auto.master. by default, automount tries to get master map information from the nis map auto.master. if a local master map file is specified on the command line, automount reads it before reading the nis auto.master map.
the format for indirect map entries in the master maps is:
mount directory indirect map [-mount options]
the format for direct map entries in the master map is:
/- direct map [-mount options]
where:
-hosts | indicates the hosts map. the name of the remote host is used as the subdirectory name under the mount directory. |
-password | indicates the password map |
-null | cancels a previous map for the indicated mount directory. for example, if you use this in a local master map, it cancels the entry in the nis auto.master map. |
automount maps are usually named auto.xxx, where xxx is the name of the map. the name does not have to correspond to any mount points, but it is recommended that the map name correspond to the directory contents (for example, auto.man for man pages).
as with all nis maps, names must be 10 characters or less if you have file systems that do not allow file names longer than 14 characters. this is because nis adds four-character suffixes (.dir and .pag) to the map name.
by convention, maps are usually created under or /etc. if you use nis to administer the maps, you should create the source files under the (1m) source directory; the default ypmake source directory is /etc.
each indirect map has a mount directory associated with it that is controlled by automount. the mount directory contains symbolic links to the actual mount points under /tmp_mnt. the mount directory is specified on the automount command line or in the master map.
the format of the indirect map entries is:
key [-mount options] server:directory
where:
automount recognizes special characters in direct and indirect maps to be used for substitutions and to escape other characters. they are:
& | can substitute key values into the directory path names |
* | is recognized as a catch-all entry (a wildcard). it is the last or only entry in a map. it matches all keys and provides a value for the & substitutions that may exist in the right-hand side of a map. for example: * -ro,intr server:/users/& |
mapname | the contents of another map can be included within the current map. if mapname is a directory with no slashes, automount interprets it as an nis map. if the directory has slashes then automount looks for a local map with that name. |
direct maps can contain any number of unrelated mount points. no common mount directory is maintained.
the format of the direct map entries is:
key [-mount options] server:directory
where:
the special characters listed above are also valid for direct maps.
automount maps can be local files or administered as nis maps. by default, automount tries to read master map information from the nis map auto.master. automount also reads master map information from a local file if you specify one on the command line.
the master map can contain nis map names for the indirect and direct maps instead of file names. to specify an nis map, preface the map name with a plus ( ).
to create nis maps, edit the /usr/etc/yp/ shell script as shown below. in the following text, assume that you want to create nis maps for auto.master and a direct map called auto.xxxx. within the scripts, auto_master and auto_direct are used for local variable names to avoid regular expression evaluation, but the map and file names are auto.master and auto.direct.
under the function section, add the following blocks for auto.master and auto.xxxx:
auto_master() {
grep -v "^[ ]*#" $1 | grep -v "^[ ]*$" | \
awk 'begin { ofs="\t"; } { print $1, $2, $3 }' | \
$makedbm - $mapdir/auto.master
}
auto_xxxx() {
grep -v "^[ ]*#" $1 | grep -v "^[ ]*$" | \
awk 'begin { ofs="\t"; } { print $1, $2, $3 }' | \}
$makedbm - $mapdir/auto.xxxx
}
in the block
for arg in $*; do
case "$arg" in
add an entry for auto.master and auto.xxxx before the "*)" in the case statement as follows:
auto_master )
if [ `expr "$maps" : ".* auto.master.*"` -eq 0 ]; then
maps="$maps auto.master"
fi;;
auto_xxxx )
if [ `expr "$maps" : ".* auto.xxxx.*"` -eq 0 ]; then
maps="$maps auto.xxxx"
fi;;
in the definition for
maps=${maps:-'passwd groups hosts ...
add an entry for auto_master and auto_xxxx.
in the block
for map in $maps; do
case $map in
add an entry for auto.master and auto.xxxx as follows:
auto_master) build $dir/auto.master auto.master ;;
auto_xxxx) build $dir/auto.xxxx auto.xxxx;;
you should also modify /usr/etc/yp/ on the master server. add auto.master and auto.xxxx to the list of master_maps.
automount is started by executing /usr/etc/automount at boot time. it is executed by default from the 2 file. you can specify map information on the command line. any map information you specify is read before information in the nis map auto.master and takes precedence over the nis map. see automount(1m) for specific command line options.
automount is normally started and stopped only when the machine is rebooted. to shut down automount gracefully during system operation, take the following steps:
warning: no other automount daemon should be started until the first has successfully cleaned up and exited. if a second automount daemon is started when the first is in its shutdown process, the second daemon will start its shutdown process. this means that there will now be four automount daemons: the first, the second, and their children. these daemons will not exit until all the mount directories they are serving have been unmounted
do not send the sigkill signal (kill -9, kill -kill) to the automount daemon. this will cause any processes accessing mount directories served by automount to hang. the file hierarchies mounted by automount under /tmp_mnt will still be accessible.
nfs, originally a sun product, works mostly the same in both aix and hp-ux. however, some of the details differ, as always. aix controls nfs daemons through the system resource controller () while hp-ux allows for direct commands. both operating systems' system management tools (smit and sam) support nfs configuration, which in most cases is the preferred way to go. automatic nfs mounts on bootup are controlled by (aix) and (hp-ux). though the format of each file differs, the principle in each is the same.
both systems support automount, though you have to configure it manually on each. the biggest difference in the automount area is its integration with nis. otherwise, nfs has the same "look and feel" across aix and hp-ux platforms. both platforms export file systems listed in via the exportfs command. both systems have nfsds, biods, rpc.mountd, rpc.lockd, and rpc.statd. since nfs uses the external data representation (xdr) protocol, there is no problem in data representation across the two systems.