一、nfs文件系统的安装和启用
nfs服务:(network file system)linux或unix系统之间实现资源的共享
本是思想:linuxA下/share文件夹,linuxB可以利用挂载(mount)机制将linuxA系统中的/share文件夹挂在到linuxB中,从而实现资源的共享。
[root@server ~]# yum install nfs-utils -y
[root@server ~]# systemctl start nfs
[root@server ~]# systemctl stop firewalld
[root@client ~]# yum install nfs-utils -y
[root@client ~]# showmount -e 172.25.254.229 ##查看nfs共享状态
Export list for 172.25.254.229:
二、配置共享
1.只读权限
[root@server ~]# vim /etc/exports
写入:
1 /mnt *(sync,ro) ##只读
[root@server ~]# exportfs -rv ##刷新
exporting *:/mnt
[root@client ~]# umount /mnt/
[root@client ~]# mount 172.25.254.229:/mnt/ /mnt/
[root@client ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3182752 7291148 31% /
devtmpfs 469344 0 469344 0% /dev
tmpfs 484932 80 484852 1% /dev/shm
tmpfs 484932 12776 472156 3% /run
tmpfs 484932 0 484932 0% /sys/fs/cgroup
/dev/mapper/vg0-vo 483670 2357 451822 1% /home
172.25.254.229:/mnt 10473984 3158400 7315584 31% /mnt
[root@client ~]# cd /mnt/
[root@client mnt]# ls
fiel1
[root@client mnt]# ll
total 0
-rw-r--r-- 1 root root 0 Jun 2 02:52 fiel1 ##只读
[root@client mnt]#
2.读写权限
[root@server ~]# vim /etc/exports
写入:
1 /mnt *(sync,rw) ##读写
[root@server ~]# exportfs -rv
exporting *:/mnt
[root@client ~]# mount 172.25.254.229:/mnt/ /mnt/
[root@client ~]# cd /mnt/
[root@client mnt]# ls
fiel1
[root@client mnt]# touch file2
touch: cannot touch ‘file2’: Permission denied
在server: chmod 777 /mnt/
[root@client mnt]# touch file2
[root@client mnt]# ll
total 0
-rw-r-