Linux基础(4)


vim :

ip地址:


NFS : 网络文件共享服务
    
    服务器:
        1 安装nfs服务
        1> : 获取安装包包源 .iso
            /tools/rhel55.iso
        2> : 挂载镜像文件
        挂载命令:mount 
        format : cmd -t filetype -o option 设备名  挂载点
        [root@localhost 02ken]# mkdir /iso    表示创建一个挂载点
        [root@localhost 02ken]# mount -t iso9660 -o loop /tools/rhel55.iso /iso   表示挂载镜像文件到/iso下
        [root@localhost 02ken]# df -h  表示查看挂载是否成功
        文件系统              容量  已用 可用 已用% 挂载点
        /dev/sda3              29G  9.7G   18G  36% /
        /dev/sda1              99M   30M   65M  32% /boot
        tmpfs                 506M     0  506M   0% /dev/shm
        /tools/rhel55.iso     2.9G  2.9G     0 100% /iso 显示出来

        [root@localhost 02ken]# 

            挂载网络共享课件
                mount servierip:sharedir /mnt
            3> : 配置yum 为了解决包之间依赖关系
                /etc/yum.repos.d/rhel-debuginfo.repo


                Server    :    表示服务安装包
                VT        :    表示图形化安装包
                Cluster    :    表示集群包
                ClusterStorage    :    表示集群存储
                
                表示标签 可以随意命名
                [rhel-debuginfo]
                表示名字  可以随意命名
                name=Red Hat Enterprise Linux $releasever - $basearch - Debug
                表示包的存放路径
                baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
                    ftp://    :    表示ftp服务包存放路径
                    https://:    表示https服务包存放路径
                    file://    :    表示本地文件
                表示是否开启    
                enabled=0
                    0    :    表示关闭
                    1    :    表示开启
                表示检验位    
                gpgcheck=1
                    1    :    表示校验
                    0    :     表示不校验
                表示校验关键字存放路径    
                gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

            4>: 加载yum
                yum clean all    清空以前yum
                yum list        重新加载配置yum
        
        
        yum install nfs*        表示安装nfs服务
        yum reinstall nfs*        表示再次安装
        yum reinstall nfs* -y     表示无需确认安装
    2 : 配置nfs服务
        /etc/exports
        书写格式:
        sharedir client(option)

        sharedir     :    必须是绝对路径
        client        :    表示允许访问客户端
            *    :    表示可以ping通服务器的所有用户
            192.168.0.*        :    表示同一网段的所有用户
            192.168.0.113    :    表示只允许113的用户访问
        option     :
            ro    :    表示只读
            rw    :    表示读写
            sync:    表示数据同步
            man exports

    3 : 重启服务
        service nfs restart

    客户端:
        1 ping 服务器
            [root@localhost 02ken]# ping 192.168.0.254 -c 3
            PING 192.168.0.254 (192.168.0.254) 56(84) bytes of data.
            64 bytes from 192.168.0.254: icmp_seq=1 ttl=64 time=0.305 ms
            64 bytes from 192.168.0.254: icmp_seq=2 ttl=64 time=0.062 ms
            64 bytes from 192.168.0.254: icmp_seq=3 ttl=64 time=0.055 ms

            --- 192.168.0.254 ping statistics ---
            3 packets transmitted, 3 received, 0% packet loss, time 3098ms
            rtt min/avg/max/mdev = 0.055/0.140/0.305/0.117 ms
            以上表示可以ping通

            [root@localhost 02ken]# ping 192.168.0.211 -c 3
            PING 192.168.0.211 (192.168.0.211) 56(84) bytes of data.
            From 192.168.0.254 icmp_seq=1 Destination Host Unreachable
            From 192.168.0.254 icmp_seq=2 Destination Host Unreachable
            From 192.168.0.254 icmp_seq=3 Destination Host Unreachable

            --- 192.168.0.211 ping statistics ---
            3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3110ms
            , pipe 3

            以上表示ping不通

        2 查看共享课件
            [root@localhost 02ken]# showmount -e 192.168.0.254
            Export list for 192.168.0.254:
            /test  *
            /tools *
            /02ken *

        3 挂载共享目录到客户端
            mount 192.168.0.254:/02ken /mnt
        4 拷贝
            cp /mnt/* /test -rf
        5 解挂
            umount /mnt
            umount -l /mnt    :    表示强制解挂
======================================================

实现自动挂载
    1 修改配置文件
        /etc/fstab
    表示设备名       表示挂载点     文件类型  参数         校验位
    LABEL=/            /              ext3    defaults        1 1
    LABEL=/boot        /boot          ext3    defaults        1 2
    tmpfs              /dev/shm       tmpfs   defaults        0 0
    devpts             /dev/pts       devpts  gid=5,mode=620  0 0
    sysfs              /sys           sysfs   defaults        0 0
    proc               /proc          proc    defaults        0 0
    LABEL=SWAP-sda2    swap           swap    defaults        0 0

    添加如下一行
    /tools/rhel55.iso        /iso    iso9660   defaults,loop     0 0


    保存退出

    mount -a : 表示模拟重启


server:

1 安装服务
    1>:get .iso
    2>:mount -t iso9660 -o loop /tools/rhel.iso /iso
    3>:yum /etc/yum.repos.d/rhel-debuginfo.repo
    4>: yum clean all yum list
    5>:yum install nfs* => yum erase nfs*
2 配置
    vim /etc/exports
3 重启服务
    service nfs restart
    /etc/init.d/nfs restart    Ubuntun

client :
    1 ping 
    2 showmount
    3 mount
    4 cp
    5 umount

猜你喜欢

转载自blog.csdn.net/qq_40788199/article/details/84671781
今日推荐