第1章 搭建NFS服务(指定WWW用户)

 

1.1 服务端操作(nfs01服务端)

1.1.1 安装NFS服务

 

rpm -qa nfs-utils rpcbind

yum install nfs-utils rpcbind -y

rpm -qa nfs-utils rpcbind

 

1.1.2 启动服务

 

/etc/init.d/rpcbind start

/etc/init.d/nfs start

rpcinfo -p localhost

chkconfig nfs on

chkconfig rpcbind on

 

1.1.3 配置

 

mkdir /data -p

useradd www -s /sbin/nologin -M -u 888

id www

chown -R www.www /data

ls -ld /data

[root@nfs01 data]# vim /etc/exports              ###编辑配置文件

#---------- time by oldboy for kaifa.

/data172.16.1.0/24(rw,sync,all_squash,anonuid=888,anongid=888)

[root@nfs01 data]# cat /etc/exports

[root@nfs01 data]# exportfs -rv                     ###使配置生效

###或者使用/etc/init.d/nfs reload       ###平滑重启

 

1.1.4 测试

 

showmount -e 172.16.1.31

mount -t nfs 172.16.1.31:/data /mnt

df -h

umount /mnt           ###如果卸载不掉,使用umount -lf /mnt   强制卸载(数据不会丢失)

 

1.2 客户端1操作(在backup客户端)

1.2.1 安装NFS相关服务包

 

rpm -qa nfs-utils rpcbind

yum install nfs-utils rpcbind -y

rpm -qa nfs-utils rpcbind

 

1.2.2 启动服务

 

/etc/init.d/rpcbind start

chkconfig rpcbind on

 

1.2.3 配置

 

useradd www -s /sbin/nologin -M -u 888

id www

 

1.2.4 挂载测试

 

[root@backup ~]# ping 172.16.1.31

[root@backup ~]# telnet 172.16.1.31 111

showmount -e 172.16.1.31

mount -t nfs 172.16.1.31:/data /mnt

df -h

cat /proc/mounts

touch /mnt/oldboy.txt

 

 

1.3 客户端2操作(在web01客户端)

1.3.1 安装NFS相关服务包

 

rpm -qa nfs-utils rpcbind

yum install nfs-utils rpcbind -y

rpm -qa nfs-utils rpcbind

 

1.3.2 启动服务

 

/etc/init.d/rpcbind start

chkconfig rpcbind on

 

1.3.3 配置

 

useradd www -s /sbin/nologin -M -u 888

id www

 

1.3.4 挂载测试

 

[root@web01 ~]# ping 172.16.1.31

[root@web01 ~]# telnet 172.16.1.31 111

showmount -e 172.16.1.31

mount -t nfs 172.16.1.31:/data /mnt

df -h

cat /proc/mounts

touch /mnt/oldgirl.txt