个人linux学习总结(二)Linux&linux文件共享 linux&windows共享文件夹

本文档详细介绍了如何在服务器上安装和配置NFS与Samba服务,包括安装必要的软件包,修改配置文件,创建共享目录,启动服务,并在客户端进行挂载。通过这些步骤,可以实现文件系统的跨主机共享,便于多台机器间的数据同步和访问。
摘要由CSDN通过智能技术生成

任务:

1.安装nfs服务
修改配置文件
挂载文件到指定位置
2.安装samba服务
修改配置文件
挂载文件到指定位置

1.yum install -y  nfs-utils   

#安装nfs服务

yum install -y rpcbind

#安装rpc服务

systemctl start rpcbind #先启动rpc服务
systemctl enable rpcbind #设置开机启动
systemctl start nfs-server nfs-secure-server 

#启动nfs服务和nfs安全传输服务

systemctl enable nfs-server nfs-secure-server
mkdir /public

#创建public共享目录

vi /etc/exports
	/public 192.168.128.129(insecure,rw,sync,no_root_squash)
systemctl reload nfs 

#重新加载NFS服务,使配置文件生效
NFS客户端挂载配置

[root@localhost public]# showmount -e 192.168.254.21
Export list for 192.168.128.129:
/public 192.168.128.129
[root@localhost ~]# mkdir /mnt/public
[root@localhost ~]# mkdir /mnt/data
[root@localhost ~]# vim /etc/fstab 

#在该文件中挂载,使系统每次启动时都能自动挂载

	192.168.128.129:/public  /mnt/public       nfs    defaults 0 0
[root@localhost ~]# mount -a   #是文件/etc/fstab生效
[root@localhost public]# df -Th
Filesystem             Type      Size  Used Avail Use% Mounted on
/dev/sda3              xfs        23G  4.1G   19G  18% /
devtmpfs               devtmpfs  475M     0  475M   0% /dev
tmpfs                  tmpfs     489M   84K  489M   1% /dev/shm
tmpfs                  tmpfs     489M  7.1M  482M   2% /run
tmpfs                  tmpfs     489M     0  489M   0% /sys/fs/cgroup
/dev/sda1              xfs       297M  144M  154M  49% /boot
tmpfs                  tmpfs      98M     0   98M   0% /run/user/0
tmpfs                  tmpfs      98M   20K   98M   1% /run/user/42
192.168.128.129:/public nfs4       50G  5.7G   45G  12% /mnt/public

服务器端
1、下载工具

   yum -y install nfs-utils rpcbind

2、编辑vim /etc/exports

/home/lnntest 192.168.128.0/24(rw)

3、启动

[root@localhost ~]# systemctl start rpcbind nfs
[root@localhost ~]# systemctl is-active rpcbind nfs

查看是不是active

  active

4、新建

mkdir /home/lnntest

5、复制

    cp /etc/passwd /etc/hosts /home/lnntest
6、[root@localhost ~]# ls /home/lnntest
hosts  passwd

7、重启

[root@localhost ~]# systemctl restart rpcbind nfs
[root@localhost ~]# systemctl is-active rpcbind nfs

8、挂载自己

[root@localhost ~]# showmount -e 192.168.128.132
Export list for 192.168.128.132:
/home/lnntest 192.168.128.0/24

客户端
1、下载工具

   yum -y install nfs-utils rpcbind
2、[root@localhost ~]# mount 192.168.128.132:/home/lnntest /nfs/

3、查看最后一行

[root@localhost ~]# df
Filesystem                    1K-blocks    Used Available Use% Mounted on
/dev/mapper/centos-root        38770180 1152804  37617376   3% /
devtmpfs                         920380       0    920380   0% /dev
tmpfs                            932652       0    932652   0% /dev/shm
tmpfs                            932652    9816    922836   2% /run
tmpfs                            932652       0    932652   0% /sys/fs/cgroup
/dev/sda1                       1038336  145260    893076  14% /boot
tmpfs                            186532       0    186532   0% /run/user/0
192.168.128.132:/home/lnntest  38770432 1227264  37543168   4% /nfs


echo 123456 > /nfs/wp.txt
cat /nfs/wp.txt
[root@localhost ~]# cd /nfs
[root@localhost nfs]# ll
total 16
-rw-r--r--. 1 nfsnobody nfsnobody    7 Oct  6 10:43 ap.txt
-rwxrwxrwx. 1 root      root       158 Oct  6 10:17 hosts
-rwxrwxrwx. 1 root      root      1034 Oct  6 10:17 passwd
-rw-r--r--. 1 nfsnobody nfsnobody    7 Oct  6 10:44 wp.txt

服务器:

[root@localhost home]# cd test
[root@localhost test]# ll
total 16
-rw-r--r--. 1 nfsnobody nfsnobody    7 Oct  6 10:43 ap.txt
-rwxrwxrwx. 1 root      root       158 Oct  6 10:17 hosts
-rwxrwxrwx. 1 root      root      1034 Oct  6 10:17 passwd
-rw-r--r--. 1 nfsnobody nfsnobody    7 Oct  6 10:44 wp.txt
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

neverう

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值