zoukankan      html  css  js  c++  java
  • centos7安装nfs

    nfs图解:

    nfs服务端安装脚本:

    #!/bin/sh
    
    #关闭防火墙
    systemctl stop firewalld.service
    
    #下载安装rpcbind,nfs-utils服务端
    yum -y install rpcbind nfs-utils
    
    #创建nfs服务端存放文件的目录,编辑/etc/exports共享配置文件
    mkdir /test
    cat > /etc/exports << EOF
    /test 10.0.0.0/24(rw,sync,no_root_squash)
    EOF
    
    #注意顺序,必须先启动rpcbind服务,然后再启动nfs-server服务(nfs需向rpcbind注册端口)
    systemctl enable rpcbind.service
    systemctl enable nfs-server.service
    systemctl start rpcbind.service
    sleep 1
    systemctl start nfs-server.service
    

    客户端安装脚本:

    #!/bin/sh
    
    #关闭防火墙
    systemctl stop firewalld.service
    
    #下载安装rpcbind,nfs-utils服务端
    yum -y install rpcbind nfs-utils
    
    #客户端启动rpcbind即可,无需启动nfs-server服务
    systemctl enable rpcbind.service
    systemctl start rpcbind.service
    

    查看服务是否正常:

    [root@nfs-server ~]# rpcinfo -p
    program vers proto port service
    100000 4 tcp 111 portmapper
    100000 3 tcp 111 portmapper
    100000 2 tcp 111 portmapper
    100000 4 udp 111 portmapper
    100000 3 udp 111 portmapper
    100000 2 udp 111 portmapper
    100005 1 udp 20048 mountd
    100005 1 tcp 20048 mountd
    100024 1 udp 41116 status
    100005 2 udp 20048 mountd
    100024 1 tcp 47426 status
    100005 2 tcp 20048 mountd
    100005 3 udp 20048 mountd
    100005 3 tcp 20048 mountd
    100003 3 tcp 2049 nfs
    100003 4 tcp 2049 nfs
    100227 3 tcp 2049 nfs_acl
    100003 3 udp 2049 nfs
    100003 4 udp 2049 nfs
    100227 3 udp 2049 nfs_acl
    100021 1 udp 41056 nlockmgr
    100021 3 udp 41056 nlockmgr
    100021 4 udp 41056 nlockmgr
    100021 1 tcp 39001 nlockmgr
    100021 3 tcp 39001 nlockmgr
    100021 4 tcp 39001 nlockmgr
    [root@nfs-server ~]# systemctl status rpcbind.service 
    [root@nfs-server ~]# systemctl status nfs-server.service 

    查看nfs服务端默认加载的配置:

    [root@nfs-server ~]# cat /var/lib/nfs/etab
    /test 10.0.0.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,no_root_squash,no_all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=65534,anongid=65534,sec=sys,rw,secure,no_root_squash,no_all_squash)

    查看可挂载的nfs服务端的共享信息:

    [root@nfs-server ~]# showmount -e localhost         #<===nfs服务端查看,正常情况下是这样的
    Export list for localhost:
    /test 10.0.0.0/24
    
    [root@nfs-client ~]# showmount -e 10.0.0.6           #<===客户端正常情况下查看本机,提示nfs服务未向注册rpcbind注册
    clnt_create: RPC: Program not registered
    [root@nfs-client ~]# showmount -e 10.0.0.3
    Export list for 10.0.0.3:
    /test 10.0.0.0/24

    客户端挂载nfs服务端:

    [root@nfs-client ~]# mkdir /data
    [root@nfs-client ~]# mount -t nfs 10.0.0.3:/test /data/
    [root@nfs-client ~]# df -h
    文件系统 容量 已用 可用 已用% 挂载点
    /dev/mapper/centos-root 39G 1.8G 37G 5% /
    devtmpfs 984M 0 984M 0% /dev
    tmpfs 996M 0 996M 0% /dev/shm
    tmpfs 996M 9.2M 987M 1% /run
    tmpfs 996M 0 996M 0% /sys/fs/cgroup
    /dev/sda1 1014M 130M 885M 13% /boot
    tmpfs 200M 0 200M 0% /run/user/0
    10.0.0.3:/test 39G 8.9G 30G 23% /data
    

    永久挂载:

    [root@nfs-client ~]# echo "/usr/bin/mount -t nfs 10.0.0.3:/test /data/" >>/etc/rc.local
    
  • 相关阅读:
    MyBatis(第三方缓存整合原理&ehcache适配包下载)
    MyBatis(缓存机制)
    MyBatis(动态SQL2)
    MyBatis(动态SQL)
    MyBatis(映射文件中使用foreach标签时报错,属性collection的问题)
    MyBatis映射文件(编写SQL语句;可有可无(无的时候,使用注解编程))
    Python virtualenv with Sublime Text 3
    python & mongo问题记录
    CentOS On VirtualBox
    MySQL GROUP BY用法
  • 原文地址:https://www.cnblogs.com/blog-tim/p/10691199.html
Copyright © 2011-2022 走看看