Configuration Installation under Linux NFS

1.1 NFS Overview

NFS (Network File System) is a distributed file system that allows file sharing between computers and peripherals, networks with different operating systems, so the design is independent of the host operating system and its protocol. It is composed of SUN Company launched in 1984, making it possible to use the local machine as another networked computer files and peripherals. NFS file transfer or information transfer process depends on the RPC protocol. The current version of NFS is V4 (RFC3010)

RPC, RPC (remote procedure call) is a mechanism that enables customers to other system programs end execute. Since the program using RPC does not have to understand the situation Network protocol communication, RPC helps with interoperability program. Commonly used in distributed client / server model, the requesting program is a client program, and the program is providing services server. RFC1831

1.2 NFS installation

NFS installation is very simple, requiring only two packages can be, and under normal circumstances, as the default package systems installed before configuring NFS use need to check whether the required packages are installed.

# rpm -q nfs-utils portmap

nfs-utils-1.0.6-70.EL4
portmap-4.0-63

// If packets appear, there is a nfs-utils portmap two packages are installed

1.3 NFS installation package file

The current system used in the package is not required to NFS mount, it requires manual installation. nfs-utils portmap two packages and installed file system will have a CD-ROM.

nfs-utils-1.0.6-70.EL4.i386.rpm

portmap-4.0-63.i386.rpm

1.4 Portmap package

portmap portmap package of services to support PRC services for the NFS and NIS, etc., so when you first install portmap NFS installation package.

rpm -ql portmap
/etc/rc.d/init.d/portmap
/sbin/portmap

1.5 nfs-utils package
nfs-utils package provides NFS server program and corresponding management tools.

rpm -ql nfs-utils

PS: The above said installation method might be like red hat for this OS, like Ubuntu not so trouble, just use apt-get install nfs-server, the command is as follows:

     sudo apt-get install nfs-kernel-server

1.6 NFS server configuration

NFS server configuration is relatively simple, only needs to be set in the appropriate configuration file, and then start the NFS server.

1.7 NFS server configuration file ------------------- exports

exports files in the directory "/ etc", shared configuration directory for the NFS server to offer. exports night is set to null, no output of any shared directory, and this is for security reasons, so that even if you start NFS service does not provide any sharing.

1.8 exports file format

exports per line in a shared directory, the formatting of the line is as follows:

Address of the client host shared directory to be output (set the first item)

/www/chinafu *(sync,ro)

/home   *(async,rw,no_root_squash)

In the shared settings file, directory and sharing between host addresses separated by a space, followed by setting options after the host address, set the options placed in parentheses, across multiple setting options are separated by commas.

1.8.1 shared directory

Shared directory set as required in the system shared directory path.

1.8.2 Client host address

In the exports file on the client, specify the client host is very flexible, as shown below

The client host address Description

Specifies the host 192.168.0.28 ip address

www.chinafu.net specify the domain name of the host

192.168.0.10/31 designated segment of all hosts

* .Chinafu.com all hosts in the specified domain

* Specify all hosts

1.8.3 Setting Options

Set more choices exports file, but often not much

Option Description

NFS server synchronization sync settings write to disk, so that will not easily lose data, NFS server This option is recommended

Ro set the output shared directory read-only, and can be used simultaneously picking rw

Rw output set shared directory writable, and can not be used in common ro

1.8.4 exports file configuration examples

In the exports file, the same output shared directory can have different setting options for different hosts, each separated by a space is provided between the host

#more /etc/exports

/www/chinafu *(sync,ro) 192.168.0.19(sync,rw)

/home/ftp 192.168.0.31(sync,ro)

1.9 NFS server to start and stop

After exports files in the correct configuration, you can start the NFS server.

19.1 Start the NFS server

In order for NFS server to work properly, you need to start portmap and nfs two services, and portmap must first launched in nfs

[root @ localhost ~] # Service portmap Start
Starting portmap: [the OK]
// first start for nfs portmap

[root@localhost ~]# service nfs start
Starting NFS services:                                     [ OK ]
Starting NFS quotas:                                       [ OK ]
Starting NFS daemon:                                     [ OK ]
Starting NFS mountd:                                      [ OK ]

19.2 NFS server status query

#service portmap status

#service nfs status

19.3 Stop the NFS server

To stop running NFS, you need to stop the service before stopping nfs portmap service for the system when there are other services (such as NIS) requires the use, do not need to stop the portmap service

#service nfs stop

#service portmap stop

19.4 NFS server set up automatic start state

For practical applications, each time you start LINUX after the systems are manually start the nfs server is not realistic, we need to set the system to start portmap and nfs service run automatically at a specified level.

[root@localhost ~]# chkconfig --list portmap
portmap         0:off   1:off   2:off   3:off    4:off 5:off    6:off

[root@localhost ~]# chkconfig --list nfs
nfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off

// set portmap and nfs service starts in run level 3 and 5 automatic.

[root@localhost ~]# chkconfig --level 35 portmap on

[root@localhost ~]# chkconfig --level 35 nfs on
[root@localhost ~]# chkconfig --list portmap
nfs             0:off   1:off   2:off   3:on    4:off 5:on    6:off

[root@localhost ~]# chkconfig --list nfs
nfs             0:off   1:off   2:off   3:on    4:off 5:on    6:off

20.1 showmount command

After starting the NFS server correctly and properly set up after the NFS shared directory, you can use the showmount command to query the status of the NFS share.

20.1.1 display showmount command help

showmount -h

20.1.2 NFS server to display information about the host

Information showmount NFS server host address // is not designated as the current host of the NFS server

20.1.3 Display Output list NFS server

showmount -e NFS server host address

20.1.4 display NFS server to be mounted directory

showmount -d NFS server host address

20.1.5 NFS server to display the customer with the mounted directory

showmount -a

21.1exportfs command

21.1.1 re-export the shared directory

exportfs -rv

exportfs -rv command to set the NFS server to reread the exports file after using this command can change file settings exports, set to take effect in the current server without the need to restart the NFS server

21.1.2 Stop all output directory

exportfs -auv

All output is used to stop the current directory in the NFS server host

21.1.3 All output directory

exportfs -of

All output for the current host shared directory of the NFS server

22.1 NFS Client Configuration

22.1.1 shows the output shared directory of the NFS server

Before using the shared directory mount to mount the NFS server, the NFS server is best to query whether to allow connecting the respective native directory common
share

showmount -e server address

23.1 Mounting an NFS server shared directory

Command Format

mount NFS Server Address: shared directory local mount point directory

example:

mount 192.168.0.130:/www/chinafu /mnt/chinafu

Details Note: mount point directory is an empty directory has been established, but also use other empty directory.

24.1 displays the current host NFS mounted directory

#mount |grep nfs

25.1 unload the mounted NFS shared directory

#unmount /mnt/chinafu

// directory / mnt / chinafu mount point for the NFS shared directory

Reproduced in: https: //www.cnblogs.com/licheng/archive/2008/02/17/1071275.html

Guess you like

Origin blog.csdn.net/weixin_34302561/article/details/92631092