Online Book Reader

Home Category

Managing NFS and NIS, 2nd Edition - Mike Eisler [72]

By Root 334 0
on each server in the replicated filesystem have to be the same in content. For example, if on an NFS client we have done:

# mount -o ro serverX,serverY:/export /mnt

then /export on both servers needs to be an exact copy. One way to generate such a copy would be:

# rlogin serverY

serverY # cd /export

serverY # rm -rf ../export

serverY # mount serverX:/export /mnt

serverY # cd /mnt

serverY # find . -print | cpio -dmp /export

serverY # umount /mnt

serverY # exit

#

The third command invoked here, rm -rf ../export is somewhat curious. What we want to do is remove the contents of /export in a manner that is as fast and secure as possible. We could do rm -rf /exportbut that has the side of effect of removing /export as well as its contents. Since /export is exported, any NFS client that is currently mounting serverY:/export will experience stale filehandles (see Section 18.8). Recreating /export immediately with the mkdir command does not suffice because of the way NFS servers generate filehandles for clients. The filehandle contains among other things the inode number (a file's or directory's unique identification number) and this is almost guaranteed to be different. So we want to remove just what is under /export. A commonly used method for doing that is:

# cd /export ; find . -print | xargs rm -rf

but the problem there is that if someone has placed a filename like foo /etc/passwd (i.e., a file with an embedded space character) in /export, then the xargs rm -rf command will remove a file called foo and a file called /etc/passwd, which on Solaris may prevent one from logging into the system. Doing rm -rf ../export will prevent /export from being removed because rm will not remove the current working directory. Note that this behavior may vary with other systems, so test it on something unimportant to be sure.

At any rate, the aforementioned sequence of commands will create a replica that has the following properties:

Each regular file, directory, named pipe, symbolic link, socket, and device node in the original has a corresponding object with the same name in the copy.

The file type of each regular file, directory, named pipe, symbolic link, socket, and device node in the original is the same in the corresponding object with same name in the copy.

The contents of each regular file, directory, symbolic link and device node in the original are the equal to the contents of each corresponding object with same name in the copy.

The user identifier, group identifier, and file permissions of each regular file, directory, name pipe, symbolic link, socket, and device node in the original are to equal the user identifier, group identifier, and file permissions of each corresponding object with the same name in the copy. Strictly speaking this last property is not mandatory for client-side failover to work, but if after a failover, the user on the NFS client no longer has access to the file his application was reading, then the user's application will stop working.

Rules for mounting replicas

In order to use client-side failover, the filesystem must be mounted with the sub-options ro (read-only) and hard.

The reason why it has to be mounted read-only is that if NFS clients could write to the replica filesystem, then the replicas would be no longer synchronized, producing the following undesirable effects:

If another NFS client failed over from one server to the server with the modified file, it would encounter an unexpected inconsistency.

Likewise, if the NFS client or application that modified the file failed over to another server, it would find that its changes were no longer present.

The filesystem has to be mounted hard because it is not clear what it would mean to mount a replicated filesystem soft. When a filesystem is mounted soft, it is supposed to return an error from a timed-out remote procedure call. When a replicated filesystem is mounted, after a remote procedure call times out, the NFS filesystem is supposed to try the next server in the list associated with the mount point. These two

Return Main Page Previous Page Next Page

®Online Book Reader