1. 程式人生 > >Centos6.4和Centos5.8混合實例(五)

Centos6.4和Centos5.8混合實例(五)

服務器 客戶端 服務端 主機 角色 nsf

Centos6.4Centos5.8混合實例:

服務器系統

角色

IP

CentOS-64-121-server1

NFS服務器端

192.168.1.121

CentOS-5.8-119-client

NFS客戶端

192.168.1.119

共享CentOS-64-121-server1/data/bbs目錄,使192.168.1.1 IP段所有主機都可以訪問

Centos6.4配置服務端:

首先創建實驗環境目錄

[[email protected] ~]# mkdir /data/bbs –p
[[email protected] bbs]# chown -Rnfsnobody.nfsnobody /data/bbs
[[email protected]
/* */ bbs]# ls -ld /data/bbs drwxr-xr-x. 2 nfsnobody nfsnobody 4096 Jan19 17:08 /data/bbs

  • 檢查服務器系統信息

[[email protected] ~]# cat /etc/redhat-release
CentOS release 6.4 (Final)
[[email protected] ~]# uname -n
64server1
[[email protected] ~]# uname -r
2.6.32-358.el6.x86_64
[[email protected]
/* */ ~]# uname -m x86_64 [[email protected] ~]# uname -a Linux 64server1 2.6.32-358.el6.x86_64 #1SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux [[email protected] ~]# [[email protected] ~]# ifconfig eth0 Link encap:Ethernet HWaddr00:0C:29:03:A5:40 inet addr:192.168.1.121 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe03:a540/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:163 errors:0 dropped:0 overruns:0 frame:0 TX packets:126 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:14926 (14.5 KiB) TXbytes:13877 (13.5 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0b)

分別查看服務端的相關信息,如ip,主機名等等

  • 檢查NFS軟件

[[email protected] ~]# rpm -aq|egrep"nfs-utils|rpcbind"
nfs-utils-1.2.3-36.el6.x86_64
nfs-utils-lib-1.1.5-6.el6.x86_64
rpcbind-0.2.0-11.el6.x86_64

  • 查看服務器的centos5.8 portmap6.4 rpcbind服務有沒有啟動和檢查nfs、啟動nfs

[[email protected] ~]# /etc/init.d/rpcbindstatus      
rpcbind (pid  1100) is running...
[[email protected] ~]# /etc/init.d/nfs status
rpc.svcgssd is stopped
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped
[[email protected] ~]# /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Stopping RPC idmapd:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
[[email protected] ~]# /etc/init.d/nfsstatus   
rpc.svcgssd is stopped
rpc.mountd (pid 1606) is running...
nfsd (pid 1671 1670 1669 1668 1667 16661665 1664) is running...
rpc.rquotad (pid 1602) is running...
  • 配置NFSportmapCentos6.4下為rpcbind)服務開機自啟動

[[email protected] ~]# echo "#NFS6.4Server start at dingjian to2014.01.19">>/etc/rc.local
[[email protected] ~]# echo "/etc/init.d/rpcbindstart" >>/etc/rc.local
[[email protected] ~]# echo"/etc/init.d/nfs start" >>/etc/rc.local      
[[email protected] ~]# tail -3 /etc/rc.local
#NFS6.4 Server start at dingjianto2014.01.19
/etc/init.d/rpcbind start
/etc/init.d/nfs start

  • 配置NFS服務

[[email protected] ~]# echo "#NFS shared/data/bbs 2014.01.19">>/etc/exports
[[email protected] ~]# echo "/data/bbs/192.168.1.1/24(rw,sync)">>/etc/exports
[[email protected] ~]# tail -2 /etc/exports
#NFS shared /data/bbs 2014.01.19
/data/bbs/ 192.168.1.1/24(rw,sync)

六、/etc/init.d/nfs reload exportfs -rv進行nfs重新加載

七、showmount -e localhost show一下自己,看服務端有沒有配置好

[[email protected] bbs]# showmount -elocalhost
Export list for localhost:
/data/bbs 192.168.1.1/24

Centos5.8配置客戶端

  1. 檢查系統環境

[[email protected] ~]# cat /etc/redhat-release
CentOS release 5.8 (Final)
[[email protected] ~]# uname -n
58client
[[email protected] ~]# uname -r
2.6.18-308.el5
[[email protected] ~]# uname -a
Linux 58client 2.6.18-308.el5 #1 SMP TueFeb 21 20:06:06 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
[[email protected] ~]# uname -m
x86_64

2.檢查和啟動portmap(6.4rpcbind)服務(註意無需啟動NFS服務)

[[email protected] ~]# rpm -aq|grep portmap
portmap-4.0-65.2.2.1
[[email protected] ~]# /etc/init.d/portmapstatus
portmap is stopped
[[email protected] ~]# /etc/init.d/portmapstart
Starting portmap:                                         [  OK  ]
[[email protected] ~]# /etc/init.d/portmapstatus
portmap (pid 22949) is running...

3.portmap加入開機自啟動

[[email protected] ~]# echo "#NFS Clientstart at dingjian to 2014.01.19">>/etc/rc.local
[[email protected] ~]# echo"/etc/init.d/portmap start">>/etc/rc.local
[[email protected] ~]# tail -2 /etc/rc.local
#NFS Client start at dingjian to 2014.01.19
/etc/init.d/portmap start

4掃描NFS服務器的文件共享例表

[[email protected] ~]# showmount -e 192.168.1.121
Export list for 192.168.1.121:
/data/bbs 192.168.1.1/24

5.掛載NFS服務器共享目錄到本地系統

[[email protected] ~]# mount -t nfs192.168.1.121:/data/bbs /mnt
[[email protected] ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3             17981340   2124724 14928464  13% /
/dev/sda1               295561     16842   263459   7% /boot
tmpfs                    60136         0    60136   0% /dev/shm
192.168.1.121:/data/bbs
                      18375552   1526656 15915456   9% /mnt

6.配置開機自動掛載NFS共享目錄

[[email protected] ~]# echo "mount -t nfs192.168.1.121/data/bbs /mnt" >>/etc/rc.local
[[email protected] ~]# tail -1  /etc/rc.local
mount -t nfs 192.168.1.121/data/bbs /mnt

7.測試數據

[[email protected] ~]# cd /data/bbs
[[email protected] bbs]# touch aa
 
[[email protected] ~]# ls /mnt
aa

提示: 1.配置NFS服務端後,不用重啟NFS服務,只要使用exportfs -rv/etc/init.d/nfs reload重新加載就可以了

2.rpc主程序Centos5.8下為portmap Centos6.4下為rpcbind

3.NFS共享目錄不要授權於777權限,可以改所屬主和組為nfsnobody,因為nfsnobody權限不是很大,也不能登陸


本文出自 “Mr.Xiong`s 運維日誌” 博客,請務必保留此出處http://mrxiong2017.blog.51cto.com/12559394/1932246

Centos6.4和Centos5.8混合實例(五)