NFS与CIFS服务(复习)

NFS服务

首先需要两台虚拟机

一台做服务节点,另一台做客户端节点

修改主机名

[root@localhost ~]# hostnamectl set-hostname nfs-server
[root@nfs-server ~]# bash

两台虚拟机安装NFS

[root@nfs-server ~]# yum -y install nfs-utils rpcbind

服务节点 (IP地址一定要写对)

#创建一个共享文件
[root@nfs-server ~]# mkdir /mnt/test
#修改NFS配置文件
[root@nfs-server ~]# vi /etc/exports
/mnt/test   192.168.200.0/24(rw,no_root_squash,no_all_squash,sync,anonuid=501,anongid=501)
#命令生效
[root@nfs-server ~]# exportfs -r
#启动NFS
[root@nfs-server ~]# systemctl start rpcbind
[root@nfs-server ~]# systemctl start nfs
#查看NFS客户端的挂载地址
[root@nfs-client ~]# showmount -e 192.168.200.11
Export list for 192.168.200.11:
/mnt/gm 192.168.200.0/24

客户端节点

#把 NFS 共享目录的挂在 (挂载的IP地址是服务器的IP)
[root@nfs-client ~]# mount -t nfs 192.168.200.10:/mnt/test /mnt/
[root@nfs-client ~]# df -h
直接进去/mnt创建文件  就可以直接使用

 

CIFS服务

安装服务

 [root@samba ~]# yum install -y samba

修改配置文件

#修改配置文件
[root@samba ~]#vim /etc/samba/smb.conf
#修改[global]中的内容如下(找到配置文件中的字段并修改,disable spoolss = yes是新增的):
[global]
        workgroup = SAMBA
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = no
        cups options = raw

        printcap name = /dev/null
        printcap name = lpstat
        printing = bsd
         disable spoolss = yes

#在配置文件的最后,添加如下内容:
[share]
        path = /opt/share
        browseable = yes
        public = yes
        writable = yes

/opt/share:这个目录是将要共享的目录,若没有,需要创建。

browseable:参数是操作权限;

public:参数是访问权限;

writable:参数是对文件的操作权限。

在 /opt 目录下创建一个文件夹

[root@samba ~]# mkdir /opt/shae
#给文件夹加权限
[root@samba ~]# chmod 777 /opt/share
#开启服务
[root@samba ~]# systemctl start smb
[root@samba ~]# systemctl start nmb
#查看端口状态(可多端口将开启)
[root@samba ~]# netstat -ntpl

创建用户

#输入密码的时候是看不间的
[root@samba ~]# smbpasswd -a root
New SMB password:123456
Retype new SMB password:123456
Added user root.

#重启服务
[root@samba ~]# service smb restart

windows下使用

windows+R 然后输入 \192.168.200.20 (IP是你虚拟机的IP)。

输入完成等待输入用户密码即可。

可以创建在虚拟机里创建个文件夹试试可否在windows下出现。

 

posted @ 2021-12-01 14:29  花花de代码生活  阅读(183)  评论(0编辑  收藏  举报