加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

centos nfs配置--转载

发布时间:2020-12-13 14:03:31 所属栏目:Linux 来源:网络整理
导读:h2 class="title"http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-nfs-client-config.html h2 class="title"18.6.?NFS Server Configuration There are three ways to configure an NFS server under Red Hat Enterprise Linux: using the ( )

<h2 class="title">http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-nfs-client-config.html
<h2 class="title">18.6.?NFS Server Configuration

There are three ways to configure an NFS server under Red Hat Enterprise Linux: using the (),manually editing its configuration file (),or using the command.

To use the NFS Server Configuration Tool,you must be running X Windows,have root privileges,and have the system-config-nfs RPM package installed. To start the application,click on => => => . You can also type the command in a terminal. The NFS Server Configuration tool window is illustrated below.

NFS Server Configuration Tool

Figure?18.1.?NFS Server Configuration Tool

Based on certain firewall settings,you may need to configure the NFS daemon processes to use specific networking ports. The NFS server settings allows you to specify the ports for each process instead of using the random ports assigned by the portmapper. You can set the NFS Server settings by clicking on the button. The figure below illustrates the NFS Server Settings window.

NFS Server Settings

Figure?18.2.?NFS Server Settings

Sharing or serving files from an NFS server is known as exporting the directories. The can be used to configure a system as an NFS server.

To add an NFS share,click the button. The dialog box shown in appears.

The tab requires the following information:

  • — Specify the directory to share,such as .

  • — Specify the host(s) with which to share the directory. Refer to for an explanation of possible formats.

  • — Specify whether the directory should have read-only or read/write permissions.

  • Add Share

    Figure?18.3.?Add Share

    The tab allows the following options to be configured:

    NFS General Options

    Figure?18.4.?NFS General Options

  • — Services started on port numbers less than 1024 must be started as root. Select this option to allow the NFS service to be started by a user other than root. This option corresponds to .

  • — Do not require a lock request. This option corresponds to .

  • — If a subdirectory of a file system is exported,but the entire file system is not exported,the server checks to see if the requested file is in the subdirectory exported. This check is called . Select this option to disable subtree checking. If the entire file system is exported,selecting to disable subtree checking can increase the transfer rate. This option corresponds to .

  • — Enabled by default,this option does not allow the server to reply to requests before the changes made by the request are written to the disk. This option corresponds to . If this is not selected,the option is used.

  • — Do not delay writing to disk. This option corresponds to .

  • turns the option on or off. When the option is off,nested directories are revealed. The clients can therefore navigate through a filesystem from the parent without noticing any changes.

  • sets the option which allows a directory to be exported only if it has been mounted.

  • specifies the path to an optional mount point. Click on the to navigate to the preferred mount point or type the path if known.

  • sets the option. This is mainly used in a clustered setup. Using a consistent filesystem ID in all clusters avoids having stale NFS filehandles.

  • NFS User Access

    Figure?18.5.?NFS User Access

    The tab allows the following options to be configured:

  • — By default,the user and group IDs of the root user are both 0. Root squashing maps the user ID 0 and the group ID 0 to the user and group IDs of anonymous so that root on the client does not have root privileges on the NFS server. If this option is selected,root is not mapped to anonymous,and root on a client has root privileges to exported directories. Selecting this option can greatly decrease the security of the system. Do not select it unless it is absolutely necessary. This option corresponds to .

  • — If this option is selected,all user and group IDs are mapped to the anonymous user. This option corresponds to .

  • — If is selected,this option lets you specify a user ID for the anonymous user. This option corresponds to .

  • — If is selected,this option lets you specify a group ID for the anonymous user. This option corresponds to .

  • To edit an existing NFS share,select the share from the list,and click the button. To delete an existing NFS share,and click the button.

    After clicking to add,edit,or delete an NFS share from the list,the changes take place immediately — the server daemon is restarted and the old configuration file is saved as . The new configuration is written to .

    The reads and writes directly to the configuration file. Thus,the file can be modified manually after using the tool,and the tool can be used after modifying the file manually (provided the file was modified with correct syntax).

    The next this section discusses manually editing and using the command to export NFS file systems.

    If you prefer editing configuration files using a text editor or if you do not have the X Window System installed,you can modify the configuration file directly.

    The file controls what directories the NFS server exports. Its format is as follows:

    directory hostname(options)
    

    The only option that needs to be specified is one of or ( is recommended). If is specified,the server does not reply to requests before the changes made by the request are written to the disk.

    For example,

         speedy.example.com(sync)
    

    would allow users from to mount with the default read-only permissions,but,

         speedy.example.com(rw,sync)
    

    would allow users from to mount with read/write privileges.

    Refer to for an explanation of possible hostname formats.

    Caution

    Be careful with spaces in the file. If there are no spaces between the hostname and the options in parentheses,the options apply only to the hostname. If there is a space between the hostname and the options,the options apply to the rest of the world. For example,examine the following lines:

    
    

    The first line grants users from read-write access and denies all other users. The second line grants users from read-only access (the default) and allows the rest of the world read-write access.

    Each time you change ,you must inform the NFS daemon of the change,or reload the configuration file with the following command:

    
    
    

    The host(s) can be in the following forms:

  • Single machine — A fully qualified domain name (that can be resolved by the server),hostname (that can be resolved by the server),or an IP address.

  • Series of machines specified with wildcards — Use the * or ? character to specify a string match. Wildcards are not to be used with IP addresses; however,they may accidentally work if reverse DNS lookups fail. When specifying wildcards in fully qualified domain names,dots (.) are not included in the wildcard. For example, includes one.example.com but does not include one.two.example.com.

  • IP networks — Use a.b.c.d/z,where a.b.c.d is the network and z is the number of bits in the netmask (for example 192.168.0.0/24). Another acceptable format is a.b.c.d/netmask,where a.b.c.d is the network and netmask is the netmask (for example,192.168.100.8/255.255.255.0).

  • Netgroups — In the format @group-name,where group-name is the NIS netgroup name.

  • NFS shares are mounted on the client side using the command. The format of the command is as follows:

     -o  : 
    

    Replace with either for NFSv2 or NFSv3 servers,or for NFSv4 servers. Replace with a comma separated list of options for the NFS file system (refer to for details). Replace with the remote host, with the remote directory being mounted,and with the local directory where the remote file system is to be mounted.

    Refer to the man page for more details.

    If accessing an NFS share by manually issuing the command,the file system must be remounted manually after the system is rebooted. Red Hat Enterprise Linux offers two methods for mounting remote file systems automatically at boot time: the file or the service.

    An alternate way to mount an NFS share from another machine is to add a line to the file. The line must state the hostname of the NFS server,the directory on the server being exported,and the directory on the local machine where the NFS share is to be mounted. You must be root to modify the file.

    The general syntax for the line in is as follows:

    
    

    The mount point must exist on the client machine before this command can be executed. After adding this line to on the client system,type the command at a shell prompt,and the mount point is mounted from the server.

    The file is referenced by the service at boot time,so lines referencing NFS shares have the same effect as manually typing the command during the boot process.

    A sample line to mount an NFS export looks like the following example:

    :    0 0
    

    Replace with the hostname,IP address,or fully qualified domain name of the server exporting the file system.

    Replace with the path to the exported directory.

    Replace with the local file system on which the exported directory is mounted. This mount point must exist before is read or the mount fails.

    Replace with either for NFSv2 or NFSv3 servers,or for NFSv4 servers.

    Replace with a comma separated list of options for the NFS file system (refer to for details). Refer to the man page for additional information.

    (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

      推荐文章
        热点阅读