【初学菜鸟作--NFS共享服务在配置】

配置NFS共享服务,以客户机1可以访问服务器的共享



1. /root共享给192.168.1.250,可写、同步,允许客户机以root权限访问

 

 

查看服务器有没有安装portmapnfs-utils-1.0.9-66.el5

[root@host1 ~]# rpm -q nfs-utils-portmap

 

配置nfs配置文件

[root@host1 ~]# vim /etc/exports

/root          192.168.10.20(rw,sync,no_root_squash)

 

重启portmapnfs

[root@host1 ~]# serviceportmap restart

[root@host1 ~]# service nfs restart

 

进入客户机验证

[root@localhost ~]# serviceportmap restart

[root@localhost ~]# showmount -e 192.168.1.1

Export list for 192.168.1.1:

/root    12.168.1.250

 

[root@localhost ~]# mkdir -p /data/root/

[root@localhost ~]# mount 192.168.10.253:/root//data/root/

[root@localhost ~]# df -hT | grepnfs

nfs     19G  2.7G  16G  15% /data/root

[root@localhost ~]# cd /data/root/

[root@localhost root]# touch file1.txt

[root@localhost root]# ls -l file1.txt

-rw-r--r-- 1 root root 0 06-12 17:18 file1.txt

 

2. /usr/src共享给192.168.1.0/24网段,可写、异步NFS服务端操作

在服务器上配置nfs文件

root@host1 ~]# vim /etc/exports

/usr/src       192.168.1.0*(rw,sync)

[root@host1 ~]# serviceportmap restart

[root@dhcpser ~]# setfacl -m u:nfsnobody:rwx /usr/src/设置nfsnobody用户拥有读写权限

[root@host1 ~]# setfacl -m u:nfsnobody:rwx /usr/src/.

[root@host1 ~]# getfacl /usr/src/

getfacl: Removing leading '/' from absolute path names

# file: usr/src

# owner: root

# group: root

user::rwx

user:nfsnobody:rwx

group::r-x

mask::rwx

other::r-x

 

客户机上重启portmap服务

[root@localhost ~]# serviceportmap restart

创建目录并将/usr/src挂载

[root@localhost ~]# mkdir /data/src/

[root@localhost ~]# showmount -e 192.168.1.1

Export list for 192.168.1.1:

/root   192.168.1.250

/usr/src 192.168.1.0*

[root@localhost ~]# mount 192.168.1.1:/usr/src//data/src/

[root@localhost ~]# cd /data/src/

[root@localhostsrc]# touch file1.txt

[root@localhostsrc]# ls -l file1.txt

-rw-r--r-- 1 nfsnobodynfsnobody 0 06-12 17:23file1.txt

 

[root@localhost ~]# cd /data/src/

[root@localhostsrc]# touch file1.txt

[root@localhostsrc]# ls -l file1.txt

-rw-r--r-- 1 nfsnobodynfsnobody 0 06-12 17:23file1.txt

 

3. 在上一个实验基础上实现客户端上面所有用户身份都映射成nfsnobody

NFS服务端操作:

[root@dhcpser ~]# chmodo+w /usr/src/

NFS客户端操作:

[root@localhost ~]# useraddyeyue

[root@localhost ~]# su – yeyue

[yeyue@localhost ~]$ cd /data/src/

[yeyue@localhostsrc]$ touch yeyue1.txt

[yeyue@localhostsrc]$ ls -l yeyue1.txt

-rw-rw-r-- 1 yeyueyeyue 0 06-12 17:29 yeyue1.txt

再来修改NFS主配置文件

[root@dhcpser ~]# cat /etc/exports

/root  192.168.1.250(rw,sync,no_root_squash)

/usr/src       192.168.1.0*(rw,async,all_squash)

[root@dhcpser ~]# exportfs –rv执行上次重启服务操作

NFS客户端操作:

[yeyue@localhostsrc]$ touch yeyue2.txt

[yeyue@localhostsrc]$ ls -l yeyue2.txt

-rw-rw-r-- 1 yeyueyeyue     0 06-12 21:53 yeyue1.txt

-rw-rw-r-- 1 nfsnobodynfsnobody 0 06-12 21:54 yeyue2.Txt

 

设置开机自动挂载:

[root@client root]# cat /etc/fstab |tail -2                     //编辑开机挂载配置

192.168.1.1:/root      /date/root          nfs defaults     00

192.168.1.1:/usr/src   /date/srvnfs  defaults  0 0

客户端实现触发挂载

[root@client root]#vim /etc/auto.master                   //编辑触发挂载主文件添加

/date /etc/auto.nfs

[root@client root]#vim /etc/auto.nfs                      //编辑文件添加触发目录

root           -rw                    192.168.1.1:/root

srv            -rw                    192.168.1.1:/usr/src

service autofs restart                                  //重启服务

chkconfig autofs on                                  //设开机启动

 

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章