CentOS 7下NFS服務作為Web站點的根目錄配置

CentOS Sync HTML 腳本語言 AnyTopOne 2017-04-11

CentOS 7下NFS服務作為Web站點的根目錄配置

NFS客戶端IP:172.16.0.3

NFS服務端IP:172.16.0.5

一、NFS服務端配置

1、編輯/etc/sysconfig/nfs文件,內容如下

#

# Note: For new values to take effect the nfs-config service

# has to be restarted with the following command:

# systemctl restart nfs-config

#

# Optional arguments passed to in-kernel lockd

#LOCKDARG=

# TCP port rpc.lockd should listen on.

LOCKD_TCPPORT=32803

# UDP port rpc.lockd should listen on.

LOCKD_UDPPORT=32769

#

# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)

RPCNFSDARGS=""

# Number of nfs server processes to be started.

# The default is 8.

#RPCNFSDCOUNT=16

#

# Set V4 grace period in seconds

#NFSD_V4_GRACE=90

#

# Set V4 lease period in seconds

#NFSD_V4_LEASE=90

#

# Optional arguments passed to rpc.mountd. See rpc.mountd(8)

RPCMOUNTDOPTS=""

# Port rpc.mountd should listen on.

MOUNTD_PORT=892

#

# Optional arguments passed to rpc.statd. See rpc.statd(8)

STATDARG=""

# Port rpc.statd should listen on.

STATD_PORT=662

# Outgoing port statd should used. The default is port

# is random

#STATD_OUTGOING_PORT=2020

# Specify callout program

#STATD_HA_CALLOUT="/usr/local/bin/foo"

#

#

# Optional arguments passed to sm-notify. See sm-notify(8)

SMNOTIFYARGS=""

#

# Optional arguments passed to rpc.idmapd. See rpc.idmapd(8)

RPCIDMAPDARGS=""

#

# Optional arguments passed to rpc.gssd. See rpc.gssd(8)

RPCGSSDARGS=""

#

# Enable usage of gssproxy. See gssproxy-mech(8).

GSS_USE_PROXY="yes"

#

# Optional arguments passed to rpc.svcgssd. See rpc.svcgssd(8)

RPCSVCGSSDARGS=""

#

# Optional arguments passed to blkmapd. See blkmapd(8)

BLKMAPDARGS=""

2、編輯/etc/exports文件,內容如下

/www 172.16.0.3(rw,sync,all_squash,anonuid=48,anongid=48)

3、配置NFS通信端口通過iptables,腳本文件內容如下

#!/bin/bash

iptables -F

iptables -X

iptables -Z

iptables -P INPUT DROP

iptables -P OUTPUT ACCEPT

iptables -P FORWARD DROP

iptables -A INPUT -i lo -j ACCEPT

iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT

iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT

iptables -A INPUT -p tcp -s 172.16.0.3 -m multiport --dport 111,662,892,2049,32769,32803 -j ACCEPT

iptables -A INPUT -p udp -s 172.16.0.3 -m multiport --dport 111,662,892,2049,32769,32803 -j ACCEPT

iptables -A INPUT -j DROP

/usr/sbin/iptables-save > /etc/sysconfig/iptables

4、啟動NFS服務

systemctl enable rpcbind

systemctl enable nfs-server

systemctl start nfs-server

5、重啟iptables

systemctl restart iptables

二、配置NFS客戶端

1、編輯/etc/fstab文件,追加內容如下

172.16.0.5:/www /var/www/html nfs tcp,nosuid,nodev,nouser,exec,rw,auto,bg,hard 0 0

2、重新掛載所有掛載點

mount -a

相關推薦

推薦中...