Mount掛載之CentOS 6 下安裝rpcbind+nfs實(shí)現(xiàn)服務(wù)器間文件共享 2019-06-16

實(shí)際項(xiàng)目中有用到文件共享,整理一下篱瞎。

一、安裝部分

基于centos6.5-mini版痒芝,離線安裝。測試過程中為了方便關(guān)閉了防火墻牵素。

1严衬、上傳安裝包

將rpm安裝包上傳到服務(wù)器,如/root/packages/目錄下:

[root@centos6-nfs-server packages]# pwd
/root/packages
[root@centos6-nfs-server packages]# ls
keyutils-1.4-5.el6.x86_64.rpm       nfs-utils-1.2.3-78.el6.x86_64.rpm
keyutils-libs-1.4-5.el6.x86_64.rpm  nfs-utils-lib-1.1.5-13.el6.x86_64.rpm
libgssglue-0.1-11.el6.x86_64.rpm    python-argparse-1.2.1-2.1.el6.noarch.rpm
libtirpc-0.2.1-15.el6.i686.rpm      rpcbind-0.2.0-16.el6.x86_64.rpm
libevent-1.4.13-4.el6.x86_64.rpm

2笆呆、執(zhí)行安裝

[root@centos6-nfs-server packages]# 
[root@centos6-nfs-server packages]# rpm -ivh keyutils-libs-1.4-5.el6.x86_64.rpm --force
warning: keyutils-libs-1.4-5.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:keyutils-libs          ########################################### [100%]
[root@centos6-nfs-server packages]# rpm -ivh keyutils-1.4-5.el6.x86_64.rpm 
warning: keyutils-1.4-5.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:keyutils               ########################################### [100%]
[root@centos6-nfs-server packages]# rpm -ivh libevent-1.4.13-4.el6.x86_64.rpm 
warning: libevent-1.4.13-4.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:libevent               ########################################### [100%]
[root@centos6-nfs-server packages]# rpm -ivh libgssglue-0.1-11.el6.x86_64.rpm 
warning: libgssglue-0.1-11.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:libgssglue             ########################################### [100%]
[root@centos6-nfs-server packages]# rpm -ivh libtirpc-0.2.1-15.el6.x86_64.rpm 
warning: libtirpc-0.2.1-15.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:libtirpc               ########################################### [100%]
[root@centos6-nfs-server packages]# rpm -ivh python-argparse-1.2.1-2.1.el6.noarch.rpm 
warning: python-argparse-1.2.1-2.1.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:python-argparse        ########################################### [100%]
[root@centos6-nfs-server packages]# rpm -ivh rpcbind-0.2.0-16.el6.x86_64.rpm 
warning: rpcbind-0.2.0-16.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:rpcbind                ########################################### [100%]
[root@centos6-nfs-server packages]# rpm -ivh nfs-utils-lib-1.1.5-13.el6.x86_64.rpm --nodeps
warning: nfs-utils-lib-1.1.5-13.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:nfs-utils-lib          ########################################### [100%]
[root@centos6-nfs-server packages]# rpm -ivh nfs-utils-1.2.3-78.el6.x86_64.rpm 
warning: nfs-utils-1.2.3-78.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:nfs-utils              ########################################### [100%]

3请琳、查看rpcbind、nfs服務(wù)的狀態(tài)

[root@centos6-nfs-server ~]# service rpcbind status
rpcbind 已停
[root@centos6-nfs-server ~]# service nfs status
rpc.svcgssd 已停
rpc.mountd 已停
nfsd 已停

4赠幕、啟動rpcbind俄精、nfs服務(wù)

[root@centos6-nfs-server ~]# service rpcbind start
正在啟動 rpcbind:                                         [確定]
[root@centos6-nfs-server ~]# service nfs start
啟動 NFS 服務(wù):                                            [確定]
啟動 NFS mountd:                                          [確定]
啟動 NFS 守護(hù)進(jìn)程:                                        [確定]
正在啟動 RPC idmapd:                                      [確定]

5、開機(jī)啟動rpcbind榕堰、nfs服務(wù)

1) 添加rpcbind竖慧、nfs系統(tǒng)服務(wù)
[root@centos6-nfs-server ~]# chkconfig --add rpcbind
[root@centos6-nfs-server ~]# chkconfig --add nfs
2) 設(shè)置開機(jī)啟動
[root@centos6-nfs-server ~]# chkconfig rpcbind on
[root@centos6-nfs-server ~]# chkconfig --list rpcbind
rpcbind         0:關(guān)閉  1:關(guān)閉  2:啟用  3:啟用  4:啟用  5:啟用  6:關(guān)閉
?
[root@centos6-nfs-server ~]# chkconfig nfs on
[root@centos6-nfs-server ~]# chkconfig --list nfs
nfs             0:關(guān)閉  1:關(guān)閉  2:啟用  3:啟用  4:啟用  5:啟用  6:關(guān)閉

至此,服務(wù)端rpcbind+nfs服務(wù)安裝部分完成逆屡。

二圾旨、配置部分

1、服務(wù)端配置

[root@centos6-nfs-server ~]# vi /etc/exports
# 共享目錄  客戶端IP(權(quán)限)
/mnt/serverfile 192.168.56.12(rw,no_root_squash)

關(guān)于其他權(quán)限的代碼:

  • rw:可讀寫的權(quán)限魏蔗;
  • ro:只讀的權(quán)限砍的;
  • no_root_squash:登入到NFS主機(jī)的用戶如果是root,該用戶即擁有root權(quán)限莺治;(不添加此選項(xiàng)ROOT只有RO權(quán)限)
  • root_squash:登入NFS主機(jī)的用戶如果是root廓鞠,該用戶權(quán)限將被限定為匿名使用者nobody;
  • all_squash:不管登陸NFS主機(jī)的用戶是何權(quán)限都會被重新設(shè)定為匿名使用者nobody谣旁。
  • anonuid:將登入NFS主機(jī)的用戶都設(shè)定成指定的user id床佳,此ID必須存在于/etc/passwd中。
  • anongid:同anonuid蔓挖,但是變成group ID就是了夕土!
  • sync:資料同步寫入存儲器中。
  • async:資料會先暫時(shí)存放在內(nèi)存中,不會直接寫入硬盤怨绣。
  • insecure:允許從這臺機(jī)器過來的非授權(quán)訪問角溃。

2、客戶端

1)查看服務(wù)端配置掛載情況
[root@centos6-nfs-client ~]# showmount -e 192.168.56.11
Export list for 192.168.56.11:
/mnt/serverfile 192.168.56.12
2) 創(chuàng)建掛載目錄
[root@centos6-nfs-client ]# cd /home 
[root@centos6-nfs-client home]# mkdir mntdir
[root@centos6-nfs-client home]# ls
mntdir
3)掛載
[root@centos6-nfs-client home]# mount -t nfs 192.168.56.11:/mnt/serverfile /mnt/clientfile/
  • 192.168.56.11 代表服務(wù)器ip
  • /mnt/serverfile 代表服務(wù)器共享的文件夾
  • /mnt/clientfile/ 代表客戶機(jī)掛載地址
4)查看掛載結(jié)果
[root@centos6-nfs-client mntdir]# df -h
Filesystem                             Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos65test01-lv_root  6.7G  2.1G  4.3G  33% /
tmpfs                                  939M     0  939M   0% /dev/shm
/dev/sda1                              485M   39M  421M   9% /boot
192.168.56.11:/mnt/serverfile          6.7G  2.1G  4.3G  33% /mnt/clientfile

三篮撑、測試部分

服務(wù)端分享目錄初始情況:

[root@centos6-nfs-server serverfile]# pwd
/mnt/serverfile
[root@centos6-nfs-server serverfile]# ll
總用量 0
[root@centos6-nfs-server serverfile]# 

客戶端掛載目錄初始情況:

[root@centos6-nfs-client clientfile]# pwd
/mnt/clientfile
[root@centos6-nfs-client clientfile]# ll
總用量 0

1减细、客戶端讀取共享目錄文件

1)服務(wù)端添加文件,添加內(nèi)容為server123
[root@centos6-nfs-server serverfile]# vi server-test-file.txt
[root@centos6-nfs-server serverfile]# 
[root@centos6-nfs-server serverfile]# ls
server-test-file.txt
[root@centos6-nfs-server serverfile]# cat server-test-file.txt 
server123
2)客戶端查看
[root@centos6-nfs-client clientfile]# pwd
/mnt/clientfile
[root@centos6-nfs-client clientfile]# ll
總用量 4
-rw-r--r--. 1 root root 10 6月  16 10:57 server-test-file.txt
[root@centos6-nfs-client clientfile]# cat server-test-file.txt 
server123

客戶端讀取共享目錄文件成功赢笨。

2未蝌、客戶端寫文件到共享目錄

1)客戶端寫入文件,文件內(nèi)容client123
[root@centos6-nfs-client clientfile]# vi client-test-file.txt
[root@centos6-nfs-client clientfile]# ls
client-test-file.txt  server-test-file.txt
[root@centos6-nfs-client clientfile]# cat client-test-file.txt 
client123
2) 服務(wù)端讀取文件
[root@centos6-nfs-server serverfile]# ll
總用量 8
-rw-r--r--. 1 root root 10 6月  16 11:02 client-test-file.txt
-rw-r--r--. 1 root root 10 6月  16 10:57 server-test-file.txt
[root@centos6-nfs-server serverfile]# cat client-test-file.txt 
client123

客戶端寫文件到共享目錄成功茧妒。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末萧吠,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子桐筏,更是在濱河造成了極大的恐慌纸型,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,544評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件梅忌,死亡現(xiàn)場離奇詭異狰腌,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)牧氮,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,430評論 3 392
  • 文/潘曉璐 我一進(jìn)店門琼腔,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人踱葛,你說我怎么就攤上這事丹莲。” “怎么了剖毯?”我有些...
    開封第一講書人閱讀 162,764評論 0 353
  • 文/不壞的土叔 我叫張陵圾笨,是天一觀的道長。 經(jīng)常有香客問我逊谋,道長擂达,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,193評論 1 292
  • 正文 為了忘掉前任胶滋,我火速辦了婚禮板鬓,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘究恤。我一直安慰自己俭令,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,216評論 6 388
  • 文/花漫 我一把揭開白布部宿。 她就那樣靜靜地躺著抄腔,像睡著了一般瓢湃。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上赫蛇,一...
    開封第一講書人閱讀 51,182評論 1 299
  • 那天绵患,我揣著相機(jī)與錄音,去河邊找鬼悟耘。 笑死落蝙,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的暂幼。 我是一名探鬼主播筏勒,決...
    沈念sama閱讀 40,063評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼旺嬉!你這毒婦竟也來了管行?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 38,917評論 0 274
  • 序言:老撾萬榮一對情侶失蹤邪媳,失蹤者是張志新(化名)和其女友劉穎病瞳,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體悲酷,經(jīng)...
    沈念sama閱讀 45,329評論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,543評論 2 332
  • 正文 我和宋清朗相戀三年亲善,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了设易。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,722評論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡蛹头,死狀恐怖顿肺,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情渣蜗,我是刑警寧澤屠尊,帶...
    沈念sama閱讀 35,425評論 5 343
  • 正文 年R本政府宣布,位于F島的核電站耕拷,受9級特大地震影響讼昆,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜骚烧,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,019評論 3 326
  • 文/蒙蒙 一浸赫、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧赃绊,春花似錦既峡、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,671評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春传惠,著一層夾襖步出監(jiān)牢的瞬間迄沫,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,825評論 1 269
  • 我被黑心中介騙來泰國打工涉枫, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留邢滑,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 47,729評論 2 368
  • 正文 我出身青樓愿汰,卻偏偏與公主長得像困后,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子衬廷,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,614評論 2 353