directory title
Set up an NFS server, and configure it according to the following requirements
1. Open the /nfs/shared directory for all users to query information
2. Open the /nfs/upload directory, which is the 192.168. The user and the group they belong to are mapped to nfs-upload, whose UID and GID are both 210
3. Only share the /home/tom directory to the host 192.168.9=81.139, and only the user tom can fully access the directory
Note: tom It is a user directory, and the tom user created on the client must be consistent with the UID/GID of the tom user on the server.
first question
1. Install the package
nfs
rpcbind
2. Enter the configuration file to define and create the corresponding resource file
[root@rhce ~]# vim /etc/exports
[root@rhce ~]# mkdir /nfs/shared -pv
[root@rhce ~]# touch /nfs/shared/{1..3}
[root@rhce ~]# exportfs -r 重新启动配置的资源文件信息
[root@rhce ~]# systemctl stop firewalld
[root@rhce ~]# setenforce 0
3. The client mounts, checks the mount information, and modifies the mount permissions
[root@rhce1 ~]# mkdir /shared
[root@rhce1 ~]# mount 192.168.81.138:/nfs/shared /shared/
[root@rhce1 ~]# mount 查看挂载信息
[root@rhce1 ~]# mount -o remount ,ro /shared
4. The client checks the mounted information
Here we have solved our first problem
second question
Since the software is already installed, go directly to the next step
1. Define the server configuration file and create the corresponding resource file
[root@rhce ~]# vim /etc/exports
[root@rhce ~]# mkdir /nfs/upload
[root@rhce ~]# touch /nfs/upload/f{4..6}
[root@rhce ~]# exportfs -r
2. The client mounts
[root@rhce1 ~]# mkdir /upload
[root@rhce1 ~]# vim /etc/fstab 设置开机自动挂载
[root@rhce1 ~]# mount -a
3. Add files in the /upload directory of the client
Change permissions on the server first
[root@rhce ~]# ll /nfs/upload/ -d
drwxr-xr-x. 2 root root 36 May 15 16:17 /nfs/upload/
[root@rhce ~]# chmod o+w /nfs/upload/
back to the client
4. Map all users and their groups to nfs-upload
Add a user information on the server side, and specify the user's id value as 210:
[root@rhce ~]# useradd -u 210 nfs-load
After changing the group id:
[root@rhce ~]# groupmod -g 210 nfs-load
After the change, we can see as shown in the figure:
on the server side, we can see that the mapping has been successful
third question
1. Server configuration file and create corresponding resource file
[root@rhce ~]# vim /etc/exports
2. Create a shared directory on the server side
[root@rhce ~]# useradd tom
[root@rhce ~]# cd /home/tom
[root@rhce tom]# touch t1 t2 t3
[root@rhce tom]# exportfs -a
3. Create a tom user on the client
Note: tom is a user directory, and the tom user created on the client must be consistent with the UID/GID of the tom user on the server.
The tom user information on the server is as follows.
The client creates tom information:
[root@rhce1 upload]# useradd -u 1002 tom
In this way, the server and client user information are the same.
4. The client mounts
[root@rhce1 ~]# mkdir /t
[root@rhce1 upload]# mount 192.168.81.138:/home/tom /t
The permission here is denied because only the tom user can access