【初學菜鳥作--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                                  //設開機啓動

 

 


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