Redhat Linux NFS配置
来源:互联网 发布:异星工厂 mac 0.14 编辑:程序博客网 时间:2024/05/16 07:44
Linux下,All deviceis file,所有的设备都是文件。当我们需要把某些文件夹就或者文件共享给其他用户,就可以使用网络文件系统。
本文介绍Redhat Linux下的NFS配置。
在使用NFS之前,确保安装以下rpm包:nfs-utils-xxx.i686.rpm、nfs4-acl-tools-xxx.i686.rpm、nfs-utils-xxx.i686.rpm(xxx表示版本)。可以使用rpm-qa进行查询:
- [root@localhost nfs]# rpm -qa|grep nfs
- nfs-utils-lib-1.1.5-1.el6.i686
- nfs4-acl-tools-0.3.3-5.el6.i686
- nfs-utils-1.2.2-7.el6.i686
如果查询结果为空,则需要手动安装,可以在安装Linux系统的ISO包里查找,先挂载:mount -o loop /home/Wentasy/software/RHEL_6.2.iso /mnt,然后find,把nfs开头的3个rpm依次安装。
- [root@larrywen mnt]# find . -name "*nfs*"
- ./Packages/nfs-utils-1.2.3-15.el6.i686.rpm
- ./Packages/nfs-utils-lib-1.1.5-4.el6.i686.rpm
- ./Packages/nfs4-acl-tools-0.3.3-5.el6.i686.rpm
- ./Packages/sblim-cmpi-nfsv3-1.1.1-1.el6.i686.rpm
- ./Packages/sblim-cmpi-nfsv4-1.1.0-1.el6.i686.rpm
或者执行 yum install portmap yum install nfs-utls 来安装
现在对NFS进行配置,配置文件为/etc/exports,配置文件格式如下:
<输出目录> [客户端1 选项(访问权限,用户映射,其他)] [客户端2 选项(访问权限,用户映射,其他)]
NFS主要有3类选项:
访问权限选项
设置输出目录只读:ro
设置输出目录读写:rw
用户映射选项
all_squash:将远程访问的所有普通用户及所属组都映射为匿名用户或用户组(nfsnobody);
no_all_squash:与all_squash取反(默认设置);
root_squash:将root用户及所属组都映射为匿名用户或用户组(默认设置);
no_root_squash:与rootsquash取反;
anonuid=xxx:将远程访问的所有用户都映射为匿名用户,并指定该用户为本地用户(UID=xxx);
anongid=xxx:将远程访问的所有用户组都映射为匿名用户组账户,并指定该匿名用户组账户为本地用户组账户(GID=xxx);
其它选项
secure:限制客户端只能从小于1024的tcp/ip端口连接nfs服务器(默认设置);
insecure:允许客户端从大于1024的tcp/ip端口连接服务器;
sync:将数据同步写入内存缓冲区与磁盘中,效率低,但可以保证数据的一致性;
async:将数据先保存在内存缓冲区中,必要时才写入磁盘;
wdelay:检查是否有相关的写操作,如果有则将这些写操作一起执行,这样可以提高效率(默认设置);
no_wdelay:若有写操作则立即执行,应与sync配合使用;
subtree:若输出目录是一个子目录,则nfs服务器将检查其父目录的权限(默认设置);
no_subtree:即使输出目录是一个子目录,nfs服务器也不检查其父目录的权限,这样可以提高效率;
我的配置文件如下:
/home/nfs */24(rw,sync)
* :允许所有的网段访问
rw :读写权限
sync:资料同步写入内在和硬盘
查看/home/nfs权限及在此目录创建文件,在file1里输入内容“hello”
- [root@localhost ~]# vi /etc/exports
- [root@localhost ~]# ll /home/nfs -d
- drwxr-xr-x. 2 root root 4096 Jul 21 09:58 /home/nfs
- [root@localhost ~]# ll /home/nfs -d
- drwxr-xr-x. 2 root root 4096 Jul 21 09:58 /home/nfs
- [root@localhost ~]# cd /home/nfs
- [root@localhost nfs]# touch file1
- [root@localhost nfs]# echo "hello" file1
- hello file1
- [root@localhost nfs]# echo "hello" > file1
- [root@localhost nfs]# cat file1
- hello
- [root@localhost nfs]# cat /etc/exports
- /home/nfs *(rw,sync)
- [Wentasy@localhost test]$ ll /home/nfs -d
- drwxrwxrwx. 2 root root 4096 Jul 21 10:07 /home/nfs
现在启动NFS服务。
- [root@localhost ~]# service nfs start
- Starting NFS services: [ OK ]
- Starting NFS quotas: [ OK ]
- Starting NFS daemon: [ OK ]
- Starting NFS mountd: [ OK ]
另一个客户端以其他用户登录,然后挂载共享的文件夹到/home/Wentasy/test,编辑file1,加入“world”。
- [Wentasy@localhost ~]$ sudo mount -t nfs 169.254.140.100:/home/nfs /home/Wentasy/test/
- [Wentasy@localhost ~]$ cd /home/Wentasy/test/
- [Wentasy@localhost test]$ ll
- total 4
- -rw-r--r--. 1 root root 6 Jul 21 10:08 file1
- [Wentasy@localhost test]$ cat file1
- hello world
- /home/Wentasy/test
- [Wentasy@localhost test]$ mount
- /dev/mapper/VolGroup-lv_root on / type ext4 (rw)
- proc on /proc type proc (rw)
- sysfs on /sys type sysfs (rw)
- devpts on /dev/pts type devpts (rw,gid=5,mode=620)
- tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
- /dev/sda1 on /boot type ext4 (rw)
- none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
- sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
- nfsd on /proc/fs/nfsd type nfsd (rw)
- 169.254.140.100:/home/nfs on /home/Wentasy/test type nfs (rw,vers=4,addr=169.254.140.100,clientaddr=169.254.140.100)
切换到root用户或者先前的客户端,查看file1文件,可以看到Wentasy用户修改的文件内容已经同步了。
- [root@localhost nfs]# cat file1
- Redhat Linux NFS配置
- Redhat Linux NFS配置
- Redhat Linux NFS配置
- Redhat Linux NFS配置
- RedHat linux配置nfs文件服务器
- RedHat-linux下NFS的配置
- redhat nfs配置
- Redhat Linux下NFS的配置及操作
- redhat linux下nfs的配置及操作
- Redhat Linux下NFS的配置及操作
- redhat Linux 设置nfs共享
- REDHAT 共享服务器配置(NFS+SAMBA)
- RedHat下NFS的配置和操作
- redhat server上配置NFS服务
- redhat enterprise linux 5 tftpd + nfs
- Redhat-linux下搭建NFS环境
- RedHat Enterprise Linux 5 NFS服务器
- linux 服务器配置 NFS
- [Python]网络爬虫(七):Python中的正则表达式教程
- 算法与数据结构面试题(18)-二叉树镜像
- 青岛地图
- [Python]网络爬虫(六):一个简单的百度贴吧的小爬虫
- poj 2288 Islands and Bridges(状压dp)
- Redhat Linux NFS配置
- 关于安控RTU和宏电DTU的通讯设置
- 12306的坑
- 使用严苛模式打破Android4.0以上平台应用中UI主线程的“独断专行”
- MYSQL-建索引的几大原则
- [Python]网络爬虫(五):urllib2的使用细节与抓站技巧
- ios tableview ios7 分割线短 15 像素(废弃) ios8方法
- 页面最大过期时间
- 【后缀回文自动机】 URAL 1960 Palindromes and Super Abilities