1
2
3
4
5
|
[root@nginx-01 ~]
# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
[root@nginx-01 ~]
# uname -r
2.6.32-431.el6.x86_64
|
1
2
3
4
|
[root@nginx-01 ~]
# yum -y install nfs-utils rpcbind
[root@nginx-01 ~]
# service rpcbind start
[root@nginx-01 ~]
# service nfs start
[root@nginx-01 ~]
# chkconfig nfs on
|
1
2
|
[root@nginx-01 ~]
# vim /etc/exports
/home/tomcat/img/
192.168.207.128(insecure,rw,
sync
,anonuid=500,anongid=500)
|
1
2
3
4
5
6
7
|
[root@nginx-01 ~]
# ss -tnlp | grep mountd
LISTEN 0 128 *:50288 *:*
users
:((
"rpc.mountd"
,5354,8))
LISTEN 0 128 *:33842 *:*
users
:((
"rpc.mountd"
,5354,16))
LISTEN 0 128 :::54325 :::*
users
:((
"rpc.mountd"
,5354,14))
LISTEN 0 128 *:43992 *:*
users
:((
"rpc.mountd"
,5354,12))
LISTEN 0 128 :::50657 :::*
users
:((
"rpc.mountd"
,5354,10))
LISTEN 0 128 :::33795 :::*
users
:((
"rpc.mountd"
,5354,18))
|
1
|
[root@nginx-01 ~]
# exportfs -r
|
1
2
3
|
[root@nginx-01 ~]
# showmount -e localhost
Export list
for
localhost:
/home/tomcat/img
192.168.207.128
|
1
2
3
4
|
root@rabbit-0:~
# cat /etc/issue
Debian GNU
/Linux
8 \n \l
root@rabbit-0:~
# uname -r
3.16.0-4-amd64
|
1
|
root@rabbit-0:~
# aptitude -y install nfs-client
|
1
2
3
|
root@rabbit-0:~
# showmount -e 192.168.207.129
Export list
for
192.168.207.129:
/home/tomcat/img
192.168.207.128
|
1
2
3
|
root@rabbit-0:~
# su - tomcat -c "mkdir ~/img"
root@rabbit-0:~
# ls /home/tomcat/img/ -ld
drwxr-xr-x 2 tomcat tomcat 4096 12月 4 15:23
/home/tomcat/img/
|
1
2
3
4
|
Dec 4 15:21:04 nginx-01 rpc.mountd[2178]: Version 1.2.3 starting
Dec 4 15:21:04 nginx-01 kernel: NFSD: Using
/var/lib/nfs/v4recovery
as the NFSv4 state recovery directory
Dec 4 15:21:04 nginx-01 kernel: NFSD: starting 90-second grace period
Dec 4 15:21:58 nginx-01 kernel: svc: 192.168.207.128, port=748: unknown version (4
for
prog 100003, nfsd)
|
1
2
3
4
5
6
7
|
[root@nginx-01 ~]
# vim /etc/sysconfig/nfs
# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
# Turn off v2 and v3 protocol support
RPCNFSDARGS=
"-N 2 -N 3"
----->启用
# Turn off v4 protocol support
RPCNFSDARGS=
"-N 4"
---->启用
|
1
|
[root@nginx-01 ~]
# service nfs restart
|
1
2
|
root@rabbit-0:~
# mount -t nfs 192.168.207.129:/home/tomcat/img /home/tomcat/img -o proto=tcp -o nolock
root@rabbit-0:~
#
|
1
2
3
|
root@rabbit-0:~
# ls /home/tomcat/img/
#之前有两个文件存在
fstab
test
|
1
2
3
|
root@rabbit-0:~
# touch /home/tomcat/img/nfs.txt
root@rabbit-0:~
# ls -l /home/tomcat/img/nfs.txt
-rw-r--r-- 1 500 500 0 12月 4 15:24
/home/tomcat/img/nfs
.txt
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
root@rabbit-0:~
# cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
mount
-t nfs 192.168.207.129:
/home/tomcat/img
/home/tomcat/img
-o proto=tcp -o nolock
exit
0
|