linux nfsnobody用戶,處理CentOS 5.5 x64 配置NFS服務過程中nfsnobody用戶造成的問題

4、我們編譯一下這個NFS的配置文件。

[root@NFS /]# vi /etc/exports

/share 192.168.60.0/24(rw,sync,all_squash,root_squash) ? ?(我們允許這個共享對192.168.60.0/24網段可讀可寫,且將所有訪問者包括root的身份都改為nfsnobody)

[root@NFS /]# /etc/init.d/nfs restart ? ? ? ? ? (重新啟動一下NFS服務)

Shutting down NFS mountd:????????????????????????????????? [? OK? ]

Shutting down NFS daemon:????????????????????????????????? [? OK? ]

Shutting down NFS quotas:????????????????????????????????? [? OK? ]

Shutting down NFS services:??????????????????????????????? [? OK? ]

Starting NFS services:???????????????????????????????????? [? OK? ]

Starting NFS quotas:?????????????????????????????????????? [? OK? ]

Starting NFS daemon:?????????????????????????????????????? [? OK? ]

Starting NFS mountd:?????????????????????????????????????? [? OK? ]

[root@NFS /]#?showmount -e 192.168.60.3 ? ? ? ? (查看一下掛載生效了)

Export list for 192.168.60.3:

/share 192.168.60.0/24

去客戶端操作我們連接NFS共享到客戶端本地。

[root@session ~]#?mkdir /test ? ? ? ? ? ? ? ? ?(新建一個目錄)

[root@session ~]# showmount -e 192.168.60.3 ? ?(查看一下NFS服務器端的共享目錄)

Export list for 192.168.60.3:

/share 192.168.60.0/24

[root@session ~]# mount -t nfs 192.168.60.3:/share /test ? (我們掛載共享到/test)

屏幕卡在這里不動了,檢查發現,因為NFS客戶端沒有啟動portmap服務會造成卡住的現象,我們用下面的方法來解決

[root@session ~]# /etc/init.d/portmap start ? ?(啟動RPC服務)

Starting portmap:??????????????????????????????????????? [? OK? ]

[root@session ~]# mount -t nfs 192.168.60.3:/share /test ? ?(再次掛載就成功了)

[root@session ~]# cd /test ? ? ? ? ? ? ? ? ? ? (進入/test這個NFS目錄)

[root@session test]# touch 1 ? ? ? ? ? ? ? ? ? (我們新建一個文件,發現居然沒有權限)

touch: cannot touch `1': Permission denied

【接下來,我們開始排錯】 我們回到服務器端操作,為了解決權限的問題,我們先放777的權限給NFS目錄測試。

[root@NFS /]# chmod 777 share ? ? ? ? ? ? (修改NFS共享目錄的權限為777)

[root@NFS /]# ll ? ? ? ? ? ? ? ? ? ? ? ? ?(確認修改成功了)

total 166

drwxr-xr-x? 2 root????? root?????? 4096 Mar 23 20:52 bin

drwxr-xr-x? 4 root????? root?????? 1024 Mar 23 18:18 boot

drwxr-xr-x 12 root????? root?????? 4220 May 27 19:42 dev

drwxr-xr-x 84 root????? root?????? 4096 May 27 20:33 etc

drwxr-xr-x? 3 root????? root?????? 4096 Mar 23 22:26 home

drwxr-xr-x 11 root????? root?????? 4096 Mar 23 20:52 lib

drwxr-xr-x? 7 root????? root????? 12288 Mar 23 20:52 lib64

drwx------? 2 root????? root????? 16384 Mar 23 18:14 lost+found

drwxr-xr-x? 2 root????? root?????? 4096 Jan 27? 2010 media

drwxr-xr-x? 2 root????? root?????? 4096 Mar 31? 2010 misc

drwxr-xr-x? 2 root????? root?????? 4096 Jan 27? 2010 mnt

drwxr-xr-x? 2 root????? root?????? 4096 Jan 27? 2010 opt

dr-xr-xr-x 77 root????? root????????? 0 May 27 19:41 proc

drwxr-x---? 2 root????? root?????? 4096 Mar 23 22:24 root

drwxr-xr-x? 2 root????? root????? 12288 Mar 23 20:52 sbin

drwxr-xr-x? 2 root????? root?????? 4096 Mar 23 18:14 selinux

drwxrwxrwx? 2 nfsnobody nfsnobody? 4096 May 27 20:16 share

drwxr-xr-x? 2 root????? root?????? 4096 Jan 27? 2010 srv

drwxr-xr-x 11 root????? root????????? 0 May 27 19:41 sys

drwxrwxrwt? 3 root????? root?????? 4096 May 27 19:42 tmp

drwxr-xr-x 15 root????? root?????? 4096 Mar 23 18:16 usr

drwxr-xr-x 20 root????? root?????? 4096 Mar 23 18:17 var

【接下來我們回到客戶端操作】此時在客戶端,我們發現已經可以正常寫入文件到NFS共享了。

[root@session test]# touch 1 ? ?(新建文件成功)

[root@session test]# ll ? ? ? ? (查看一下,我們發現文件所有者和所屬組均為65534 ?不是我們指定的nfsnobody用戶)

total 0

-rw-r--r-- 1???? 65534???? 65534 0 May 27 20:42 1

由此我們判斷,剛才沒有權限寫入,是因為客戶端不是nfsnobody的身份。由此我們找到了故障點。

【我們回到服務器端排錯,解決問題】

[root@NFS /]# cat /etc/passwd ? ? ? ? (查看一下用戶文件)

root:x:0:0:root:/root:/bin/bash

bin:x:1:1:bin:/bin:/sbin/nologin

daemon:x:2:2:daemon:/sbin:/sbin/nologin

adm:x:3:4:adm:/var/adm:/sbin/nologin

lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

sync:x:5:0:sync:/sbin:/bin/sync

shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown

halt:x:7:0:halt:/sbin:/sbin/halt

mail:x:8:12:mail:/var/spool/mail:/sbin/nologin

news:x:9:13:news:/etc/news:

uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin

operator:x:11:0:operator:/root:/sbin/nologin

games:x:12:100:games:/usr/games:/sbin/nologin

gopher:x:13:30:gopher:/var/gopher:/sbin/nologin

ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin

nobody:x:99:99:Nobody:/:/sbin/nologin

nscd:x:28:28:NSCD Daemon:/:/sbin/nologin

vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin

rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin

mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin

smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin

oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin

pcap:x:77:77::/var/arpwatch:/sbin/nologin

ntp:x:38:38::/etc/ntp:/sbin/nologin

sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin

rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin

nfsnobody:x:4294967294:4294967294:Anonymous NFS User:/var/lib/nfs:/sbin/nologin

dbus:x:81:81:System message bus:/:/sbin/nologin

avahi:x:70:70:Avahi daemon:/:/sbin/nologin

xfs:x:43:43:X Font Server:/etc/X11/fs:/sbin/nologin

haldaemon:x:68:68:HAL daemon:/:/sbin/nologin

avahi-autoipd:x:100:104:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin

zhangyang:x:500:500::/home/zhangyang:/bin/bash

我們看到nfsnobody的UID和GID是4294967294,并不是65534。我們通過修改NFS配置文件,指定匿名用戶的UID和GID

[root@NFS /]# vi /etc/exports ? ? ?(在配置文件里面增加指定UID和GID的部分)

/share 192.168.60.0/24(rw,sync,all_squash,root_squash,anonuid=4294967294,anongid=4294967294)

[root@NFS /]# /etc/init.d/nfs restart ? ? (重啟啟動一下NFS服務,使配置生效)

Shutting down NFS mountd:????????????????????????????????? [? OK? ]

Shutting down NFS daemon:????????????????????????????????? [? OK? ]

Shutting down NFS quotas:????????????????????????????????? [? OK? ]

Shutting down NFS services:??????????????????????????????? [? OK? ]

Starting NFS services:???????????????????????????????????? [? OK? ]

Starting NFS quotas:?????????????????????????????????????? [? OK? ]

Starting NFS daemon:?????????????????????????????????????? [? OK? ]

Starting NFS mountd:?????????????????????????????????????? [? OK? ]

[root@NFS /]# chmod 755 share ? ? ? ? ? ? (我們將共享文件的權限改回755)

[root@NFS /]# ll ? ? ? ? ? ? ? ? ? ? ? ? ?(確認修改成功)

total 166

drwxr-xr-x? 2 root????? root?????? 4096 Mar 23 20:52 bin

drwxr-xr-x? 4 root????? root?????? 1024 Mar 23 18:18 boot

drwxr-xr-x 12 root????? root?????? 4220 May 27 19:42 dev

drwxr-xr-x 84 root????? root?????? 4096 May 27 20:33 etc

drwxr-xr-x? 3 root????? root?????? 4096 Mar 23 22:26 home

drwxr-xr-x 11 root????? root?????? 4096 Mar 23 20:52 lib

drwxr-xr-x? 7 root????? root????? 12288 Mar 23 20:52 lib64

drwx------? 2 root????? root????? 16384 Mar 23 18:14 lost+found

drwxr-xr-x? 2 root????? root?????? 4096 Jan 27? 2010 media

drwxr-xr-x? 2 root????? root?????? 4096 Mar 31? 2010 misc

drwxr-xr-x? 2 root????? root?????? 4096 Jan 27? 2010 mnt

drwxr-xr-x? 2 root????? root?????? 4096 Jan 27? 2010 opt

dr-xr-xr-x 77 root????? root????????? 0 May 27 19:41 proc

drwxr-x---? 2 root????? root?????? 4096 Mar 23 22:24 root

drwxr-xr-x? 2 root????? root????? 12288 Mar 23 20:52 sbin

drwxr-xr-x? 2 root????? root?????? 4096 Mar 23 18:14 selinux

drwxr-xr-x? 2 nfsnobody nfsnobody? 4096 May 27 20:42 share

drwxr-xr-x? 2 root????? root?????? 4096 Jan 27? 2010 srv

drwxr-xr-x 11 root????? root????????? 0 May 27 19:41 sys

drwxrwxrwt? 3 root????? root?????? 4096 May 27 19:42 tmp

drwxr-xr-x 15 root????? root?????? 4096 Mar 23 18:16 usr

drwxr-xr-x 20 root????? root?????? 4096 Mar 23 18:17 var

【回到客戶端操作】確認配置正確,排錯完成。[root@session test]# touch 2 ? ?(新建一個文件2)

[root@session test]# touch 3?? ?(新建一個文件3)

[root@session test]# ll ? ? ? ? (查看一下。我們發現寫入和用戶都正常了)

total 0

-rw-r--r-- 1???? 65534???? 65534 0 May 27 20:42 1

-rw-r--r-- 1 nfsnobody nfsnobody 0 May 27? 2012 2

-rw-r--r-- 1 nfsnobody nfsnobody 0 May 27? 2012 3

【總結】

我們發現在CentOS 5.5 X64中 cat /etc/passwd之后,nfsnobody用戶的UID和GID均為4294967294。但是NFS服務,默認使用65534作為匿名用戶的UID和GID,由此造成權限問題。該問題在32位centos和最新版的64位Centos中不存在。如果您遇到了和我一樣的問題。可以通過修改配置文件,指定匿名用戶的UID和GID來解決。0b1331709591d260c1c78e86d0c51c18.png

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/373150.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/373150.shtml
英文地址,請注明出處:http://en.pswp.cn/news/373150.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

計算機語言

軟件:是一系列按照特定順序組織的計算機數據和指令的集合。一般來講軟件被劃分為系統軟件、應用軟件和介于這兩者之間的中間件。 系統軟件 系統軟件是各類操作系統,如windows、Linux、UNIX等,還包括操作系統的補丁程序及硬件驅動程序&#xf…

Apache Shiro第2部分–領域,數據庫和PGP證書

這是致力于Apache Shiro的系列文章的第二部分。 我們從簡單的不安全Web應用程序開始了上一部分 。 完成后,該應用程序具有基本的身份驗證和授權。 用戶可以登錄和注銷。 所有網頁和按鈕均已分配和實施訪問權限。 授權和身份驗證數據都已存儲在靜態配置文件中。 正如…

js中變量作用域的小理解

一:變量作用域 在js代碼中每個變量都是有自己的作用域的,js中不像C語言有塊級作用域的概念,取而代之的是函數作用域,看如下代碼: var scope"global"; function init(){ alert(scope);var scope "local…

安卓linux開機畫面,Android系統的開機畫面顯示過程分析(1)

好幾個月都沒有更新過博客了,從今天開始,老羅將嘗試對Android系統的UI實現作一個系統的分析,也算是落實之前所作出的承諾。提到Android系統的UI,我們最先接觸到的便是系統在啟動過程中所出現的畫面了。Android系統在啟動的過程中&…

如果你的NavigationDrawer里面的Item沒有響應,Drawer不能左滑關閉

如果你的NavigationDrawer里面的Item沒有響應,Drawer不能左滑關閉,應該是因為你沒有把主要內容放在DrawerLayout標簽下的第一位。 The main content view (the FrameLayout above) must be the first child in the DrawerLayout because the XML order i…

JAXB和未映射的屬性

JAXB(JSR-222)是例外配置,這意味著存在默認映射應用于域對象。 這意味著有時您需要顯式排除字段/屬性。 在本文中,我將討論如何使用XmlTransient或XmlAccessorType(XmlAccessType.NONE)以及何時使用每個選項…

sublime text3 使用SVN插件

Simon在項目中經常使用SVN,每次都要切換提交,很麻煩,有了這個SVN插件就很方便了,使用快捷方式提交,更新。 安裝: Ctrl Shift P 調用出Sublime Text的包管理工具,輸入TortoiseSVN,回車進行安裝…

c語言空格有什么作用,空格在c語言中怎么表示 C語言中的空格字符怎么表示

c語言中表示空格的是什么代碼?分析如下: 不是所有字符都需要轉義的,空格直接就敲空格,或者使用ASCII碼值賦值為32。 空格沒有轉義字符。合法轉義字符如下:\a 響鈴(BEL) 、\b 退格(BS)、\f 換頁(FF)、\n 換行(LF)、\r 回…

二維數組實現八皇后問題

之前關八皇后的問題全部使用的是一維數組進行實現(http://www.cnblogs.com/SeaSky0606/p/4604955.html)&#xff0c;現改一種數據存儲方式&#xff0c;按照8x8的二維棋盤存儲皇后。基本邏輯不變&#xff0c;可參見如下代碼&#xff1a; #include<cstdio> #include<alg…

Java的深度:通過協方差暴露的API泄漏

Java有時可能非常棘手&#xff0c;特別是在API設計中。 讓我們看一個非常有趣的展示柜。 jOOQ強烈地將API與實現分開。 所有API都在org.jooq包中&#xff0c;并且是公共的。 大多數實現都在org.jooq.impl包和package-private中。 只有工廠和一些專用的基礎實現是公開的。 這允許…

StringMVC 中如何做數據校驗

步驟一&#xff1a;引入四個jar包 步驟二&#xff1a;注冊類型轉換器 <context:component-scan base-package"cn.happy.controller"></context:component-scan><!-- 配置驗證器 --><bean id"myvalidator" class"org.springframe…

ibm+x3650+m4+linux+raid驅動,IBM X3650M4陣列卡驅動下載

ibm X3650M4raid陣列卡驅動適合安裝windowsserver2008,windowsserver2008R2,系統問題&#xff0c;服務器問題&#xff0c;可以聯系我們也可以到5分享論壇發帖求助。IBM System x3650 M4服務器是一款應用最為廣泛的2U機架服務器&#xff0c;支持Xeon E5-2600機架服務器的所有產品…

為什么在Java 6上Math.round(0.499999999999999917)舍入為1

總覽 錯誤表示錯誤和算術舍入錯誤有兩種類型&#xff0c;它們在浮點計算中很常見。 在此簡單示例中&#xff0c;這兩個錯誤組合在一起&#xff0c;在Java 6中Math.round&#xff08;0.4999999999999999999917&#xff09;舍入為1。 表示錯誤 浮點數是以2為底的格式&#xff0c…

單利模式

class Singleton{ public:static Singleton* GetInstance(){if (m_pInstance nullptr){m_pInstance new Singleton;}return m_pInstance;} private:Singleton(){}//需要將構造和析構定義成私有的防止外界構造和析構~Singleton(){}static Singleton* m_pInstance;//static所有…

C語言switch中break的作用,C語言中switch...case語句中break的重要性

在C語言中switch...case語句是經常用到的&#xff0c;下面我介紹一下在使用該語句時候需要注意的一個細節問題。話不多說&#xff0c;直接舉例子&#xff1a;例子1&#xff1a;switch(fruit){case 1:printf("apple"); break;case 2:printf("banana"); brea…

BZOJ 1898: [Zjoi2005]Swamp 沼澤鱷魚 [矩陣乘法]

1898: [Zjoi2005]Swamp 沼澤鱷魚 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1082 Solved: 602[Submit][Status][Discuss]Description 潘塔納爾沼澤地號稱世界上最大的一塊濕地&#xff0c;它地位于巴西中部馬托格羅索州的南部地區。每當雨季來臨&#xff0c;這里碧波蕩漾…

從Spring開始,Java EE 6必須具備哪些附加功能?

我是一名高級Java開發人員&#xff0c;必須研究應用程序架構師選擇的技術。 我最多只能表達對特定技術的看法&#xff0c;不能做出/影響技術選擇的決定。 因此&#xff0c;在我的正式項目中&#xff0c;我別無選擇從Spring遷移到JavaEE6或從JavaEE6遷移到Spring。 我堅信&#…

UML類圖與類的關系詳解

在畫類圖的時候&#xff0c;理清類和類之間的關系是重點。類的關系有泛化(Generalization)、實現&#xff08;Realization&#xff09;、依賴(Dependency)和關聯(Association)。其中關聯又分為一般關聯關系和聚合關系(Aggregation)&#xff0c;合成關系(Composition)。下面我們…

教程:Hibernate,JPA和Spring MVC –第2部分

本教程將向您展示如何使用基本的Hibernate / JPA應用程序&#xff0c;如何將其轉換為Spring MVC Web項目&#xff0c;以便能夠在Web瀏覽器中查看數據庫&#xff0c;以及最后使用Spring的Transactional注釋來減少樣板代碼。 本教程假定您熟悉Java和Maven&#xff0c;并且已經完成…

算法轉換c語言程序,(轉)C語言實現卡爾曼濾波算法程序

非常感謝原作者&#xff0c;我在這個的基礎上轉換成純整形運算。STM32F103 12位ADC先放大1000倍再運算&#xff0c;理論上可以保留小數點后三位的結果。效果非常不錯&#xff0c;運算速度也快&#xff0c;72M時鐘 1-2uS左右(根據MDK周期數)。]uint32_t KalmanFilter(int32_t Re…