NFS:on RHEL 6
NFS会依赖一些服务。
在RHEL5中,它们是:portmap
在RHEL6中,它们是:rpcbind
操作系统版本:
1 2 3 |
[root@oracle-me ~]# cat /etc/redhat-release CentOS release 6.8 (Final) [root@oracle-me ~]# |
启动依赖的服务:
1 2 3 4 5 6 7 8 9 |
[root@oracle-me ~]# service rpcbind status rpcbind is stopped [root@oracle-me ~]# [root@oracle-me ~]# service rpcbind start Starting rpcbind: [ OK ] [root@oracle-me ~]# [root@oracle-me ~]# service rpcbind status rpcbind (pid 14243) is running... [root@oracle-me ~]# |
启动NFS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@oracle-me ~]# service nfs status rpc.svcgssd is stopped rpc.mountd dead but subsys locked nfsd dead but subsys locked rpc.rquotad dead but subsys locked [root@oracle-me ~]# [root@oracle-me ~]# service nfs start Starting NFS services: [ OK ] Starting NFS quotas: [ OK ] Starting NFS mountd: [ OK ] Starting NFS daemon: [ OK ] Starting RPC idmapd: [ OK ] [root@oracle-me ~]# [root@oracle-me ~]# |
如果没有启动依赖的服务,而启动NFS服务,将会遇到下面的报错:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@oracle-me ~]# service nfs status rpc.svcgssd is stopped rpc.mountd is stopped nfsd is stopped rpc.rquotad is stopped [root@oracle-me ~]# [root@oracle-me ~]# service nfs start Starting NFS services: [ OK ] Starting NFS quotas: Cannot register service: RPC: Unable to receive; errno = Connection refused rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp). [FAILED] Starting NFS mountd: [FAILED] Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused) rpc.nfsd: unable to set any sockets for nfsd [FAILED] [root@oracle-me ~]# |
配置需要共享的目录:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@oracle-me ~]# cat /etc/exports /nfs_me 192.168.92.0/24(rw) [root@oracle-me ~]# [root@oracle-me ~]# exportfs -auv [root@oracle-me ~]# showmount -e localhost Export list for localhost: [root@oracle-me ~]# [root@oracle-me ~]# exportfs -arv exporting 192.168.92.0/24:/nfs_me [root@oracle-me ~]# [root@oracle-me ~]# showmount -e localhost Export list for localhost: /nfs_me 192.168.92.0/24 [root@oracle-me ~]# |
客户端:
查看【showmount】命令是由什么软件包提供的:
1 2 3 |
[root@oracle-me ~]# rpm -qf /usr/sbin/showmount nfs-utils-1.2.3-75.el6.x86_64 [root@oracle-me ~]# |
在客户端安装该软件包:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
[root@localhost ~]# Last login: Thu Jun 22 07:07:58 2017 from 192.168.92.1 [root@mysql-slave ~]# [root@mysql-slave ~]# yum install -y nfs-utils Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile * base: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.163.com * updates: mirrors.163.com Resolving Dependencies --> Running transaction check ---> Package nfs-utils.x86_64 1:1.2.3-75.el6 will be installed --> Processing Dependency: nfs-utils-lib >= 1.1.0-3 for package: 1:nfs-utils-1.2.3-75.el6.x86_64 --> Processing Dependency: libtirpc >= 0.2.1-11 for package: 1:nfs-utils-1.2.3-75.el6.x86_64 --> Processing Dependency: keyutils >= 1.4-4 for package: 1:nfs-utils-1.2.3-75.el6.x86_64 --> Processing Dependency: rpcbind for package: 1:nfs-utils-1.2.3-75.el6.x86_64 --> Processing Dependency: libgssglue.so.1(libgssapi_CITI_2)(64bit) for package: 1:nfs-utils-1.2.3-75.el6.x86_64 --> Processing Dependency: libgssglue for package: 1:nfs-utils-1.2.3-75.el6.x86_64 --> Processing Dependency: libevent for package: 1:nfs-utils-1.2.3-75.el6.x86_64 --> Processing Dependency: libtirpc.so.1()(64bit) for package: 1:nfs-utils-1.2.3-75.el6.x86_64 --> Processing Dependency: libnfsidmap.so.0()(64bit) for package: 1:nfs-utils-1.2.3-75.el6.x86_64 --> Processing Dependency: libgssglue.so.1()(64bit) for package: 1:nfs-utils-1.2.3-75.el6.x86_64 --> Processing Dependency: libevent-1.4.so.2()(64bit) for package: 1:nfs-utils-1.2.3-75.el6.x86_64 --> Running transaction check ---> Package keyutils.x86_64 0:1.4-5.el6 will be installed ---> Package libevent.x86_64 0:1.4.13-4.el6 will be installed ---> Package libgssglue.x86_64 0:0.1-11.el6 will be installed ---> Package libtirpc.x86_64 0:0.2.1-13.el6_9 will be installed ---> Package nfs-utils-lib.x86_64 0:1.1.5-13.el6 will be installed ---> Package rpcbind.x86_64 0:0.2.0-13.el6_9.1 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================== Installing: nfs-utils x86_64 1:1.2.3-75.el6 base 336 k Installing for dependencies: keyutils x86_64 1.4-5.el6 base 39 k libevent x86_64 1.4.13-4.el6 base 66 k libgssglue x86_64 0.1-11.el6 base 23 k libtirpc x86_64 0.2.1-13.el6_9 updates 82 k nfs-utils-lib x86_64 1.1.5-13.el6 base 71 k rpcbind x86_64 0.2.0-13.el6_9.1 updates 51 k Transaction Summary ====================================================================================================================================== Install 7 Package(s) Total download size: 668 k Installed size: 1.7 M Downloading Packages: (1/7): keyutils-1.4-5.el6.x86_64.rpm | 39 kB 00:00 (2/7): libevent-1.4.13-4.el6.x86_64.rpm | 66 kB 00:00 (3/7): libgssglue-0.1-11.el6.x86_64.rpm | 23 kB 00:00 (4/7): libtirpc-0.2.1-13.el6_9.x86_64.rpm | 82 kB 00:00 (5/7): nfs-utils-1.2.3-75.el6.x86_64.rpm | 336 kB 00:00 (6/7): nfs-utils-lib-1.1.5-13.el6.x86_64.rpm | 71 kB 00:00 (7/7): rpcbind-0.2.0-13.el6_9.1.x86_64.rpm | 51 kB 00:00 -------------------------------------------------------------------------------------------------------------------------------------- Total 223 kB/s | 668 kB 00:02 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : libgssglue-0.1-11.el6.x86_64 1/7 Installing : libtirpc-0.2.1-13.el6_9.x86_64 2/7 Installing : rpcbind-0.2.0-13.el6_9.1.x86_64 3/7 Installing : libevent-1.4.13-4.el6.x86_64 4/7 Installing : keyutils-1.4-5.el6.x86_64 5/7 Installing : nfs-utils-lib-1.1.5-13.el6.x86_64 6/7 Installing : 1:nfs-utils-1.2.3-75.el6.x86_64 7/7 Verifying : rpcbind-0.2.0-13.el6_9.1.x86_64 1/7 Verifying : 1:nfs-utils-1.2.3-75.el6.x86_64 2/7 Verifying : libtirpc-0.2.1-13.el6_9.x86_64 3/7 Verifying : keyutils-1.4-5.el6.x86_64 4/7 Verifying : libevent-1.4.13-4.el6.x86_64 5/7 Verifying : nfs-utils-lib-1.1.5-13.el6.x86_64 6/7 Verifying : libgssglue-0.1-11.el6.x86_64 7/7 Installed: nfs-utils.x86_64 1:1.2.3-75.el6 Dependency Installed: keyutils.x86_64 0:1.4-5.el6 libevent.x86_64 0:1.4.13-4.el6 libgssglue.x86_64 0:0.1-11.el6 libtirpc.x86_64 0:0.2.1-13.el6_9 nfs-utils-lib.x86_64 0:1.1.5-13.el6 rpcbind.x86_64 0:0.2.0-13.el6_9.1 Complete! [root@mysql-slave ~]# |
客户端查看远端的服务器信息,并挂载:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
[root@mysql-slave ~]# showmount -e 192.168.92.169 Export list for 192.168.92.169: /nfs_me 192.168.92.0/24 [root@mysql-slave ~]# [root@mysql-slave ~]# mkdir /nfs_me [root@mysql-slave ~]# [root@mysql-slave ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 27G 3.2G 22G 13% / tmpfs 1.9G 68K 1.9G 1% /dev/shm /dev/sda1 283M 39M 229M 15% /boot [root@mysql-slave ~]# [root@mysql-slave ~]# mount 192.168.92.169:/nfs_me /nfs_me/ [root@mysql-slave ~]# [root@mysql-slave ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 27G 3.2G 22G 13% / tmpfs 1.9G 68K 1.9G 1% /dev/shm /dev/sda1 283M 39M 229M 15% /boot 192.168.92.169:/nfs_me 27G 16G 9.4G 63% /nfs_me [root@mysql-slave ~]# |
——————————————————————
Done。