zoukankan      html  css  js  c++  java
  • NFS搭建配置

    参考博客:http://www.cnblogs.com/mchina/archive/2013/01/03/2840040.html

    1.关闭防火墙和SELINUX

    $ service iptables status        #查看防火墙运行状态
    $ service iptables stop           #停止防火墙
    $ chkconfig iptables off          #禁用防火墙
    $ vim /etc/selinux/config        #修改SELinux配置,重启
    SELINUX=disabled
    SELINUX禁用后需要重启后生效
    $reboot
    2.配置网卡,改成静态IP
    $ cd /etc/sysconfig/network-scripts/
    $ mkdir bak
    cp ifcfg-* bak        #备份网卡配置
    $ vim ifcfg-p2p1      #修改网卡配置(每个电脑网卡名估计不同,ifcfg-eth0,ifcfg-em1.....)  
    内容:
    1. DEVICE="eth0"
    2. BOOTPROTO="static"
    3. DNS1="1.2.4.8"
    4. DNS2="114.114.114.114"
    5. GATEWAY="172.29.1.254"
    6. HOSTNAME="kvm-03-110"
    7. HWADDR="52:54:00:63:43:28"
    8. IPADDR="172.29.1.109"
    9. IPV6INIT="yes"
    10. MTU="1500"
    11. NETMASK="255.255.255.0"
    12. NM_CONTROLLED="yes"
    13. ONBOOT="yes"
    14. TYPE="Ethernet"
    15. UUID="5857d9ac-ff3d-431a-af96-3a2e14b0fb58"
    3.安装必须的软件包
    $ rpm -qa | grep nfs        #检查软件是否安装
    rpm -qa | grep portmap    #检查是否安装portmap;centos6好像改名了叫portreserve
    $ rpm -qa | grep portreserve    #检查是否安装portreserve
    $ 一般系统ISO镜像中就有这些包,默认是安装的,如果没安装可以挂在光盘找到此rpm包
    mount /dev/cdrom /mnt/cdrom/    #挂在光驱
    cd /mnt/cdrom/CentOS/
    rpm -ivh portmap*.rpm        
    $ rpm -ivh nfs-utils*.rpm
    或者yum源安装
    $ yum -y install portreserve  portmap nfs-utils
    4.配置NFS共享目录
    vim /etc/exports
    1. /opt/mirrors/src/*(rw,async,no_root_squash,no_subtree_check)
    NFS命令和配置目录:
    /etc/exports                           NFS服务的主要配置文件
    /usr/sbin/exportfs                   NFS服务的管理命令
    /usr/sbin/showmount              客户端的查看命令
    /var/lib/nfs/etab                      记录NFS分享出来的目录的完整权限设定值
    /var/lib/nfs/xtab                      记录曾经登录过的客户端信息
    $启动NFS和端口映射
    $ service portmap start    #高版本centos没有portmap
    $ service portreserve  start   #高版本centos没有portmap可以启动这个,名字不同而已
    service nfs start            #启动NFS服务
    service portreserve status    #查看服务状态
    $ service nfs  status        #查看NFS服务状态
    配置服务开机自启
    $ chkconfig --level 35 portmap on
    $ chkconfig --level 35 portreserve  on
    $ chkconfig --level 35 nfs  on
    配置hosts主机名
    $ vim /etc/hosts
    1. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 hadoop1
    2. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
    $ showmount -e        #查看nfs服务共享了哪些目录
    用其他机器挂在此共享NFS(挂在的/home/mount必须存在)
    $ mount 192.168.10.10:/opt/mirrors/src /home/mount
    $ df -h         #客户机查看挂在哪些文件系统
    showmount -a        #显示已经与客户端连接上的目录信息
    showmount -e NFS服务器IP    #客户端使用showmount命令查询NFS的共享状态
    mount |grep nfs        #客户端查看nfs挂在目录信息
    umount /home/mount    #客户端卸载挂在目录
    开机客户机自动挂在NFS
    $ vim /etc/rc.local
    1. #!/bin/sh
    2. #
    3. # This script will be executed *after* all the other init scripts.
    4. # You can put your own initialization stuff in here if you don't
    5. # want to do the full Sys V style init stuff.
    6. touch /var/lock/subsys/local
    7. mount 192.168.10.10:/opt/mirrors/src /home/mount
    也可以这样自动开机挂载
    格式:<server>:</remote/export> </local/directory> nfs < options> 0 0
    $ vim /etc/fstab
    开机查看是否自动挂在
    $ mount
     
    博采众长才能相互印证,故步自封必将粗陋浅薄!
  • 相关阅读:
    ABP 数据库 -- ABP&EF中的多表、关联查询
    C# List集合基础操作
    C# ABP 允许跨域请求
    异或运算、与运算、或运算 运用在 多项选择题
    C# ABP 配置连接数据库&创建表
    C# ABP WebApi与Swagger UI的集成
    C# 深入了解泛型
    8、SpringBoot+Mybatis整合------参数取值方式
    7、SpringBoot+Mybatis整合------PageHelper简单分页
    6、SpringBoot+Mybatis整合------参数传递
  • 原文地址:https://www.cnblogs.com/tangwan/p/5388629.html
Copyright © 2011-2022 走看看