14.4 exportfs命令 14.5 NFS客户端问题 15.1 FTP介绍

命令exportfs

exportfs常用选项

-a:表示全部挂载或者卸载

-r:表示重新挂载

-u:表示卸载某一个目录

-v:表示显示共享的目录

当改变/etc/exports配置文件后,使用exports命令挂载不需要重启NFS服务。修改在服务端(188.128)的配置文件

[root@aminglinux-128 ~]# vim /etc/exports

在vim /etc/exports里添加一行,/tmp/ 192.168.193.0/24(rw,sync,no_root_squash)

在服务端(193.128)上执行命令:

[root@aminglinux-128 ~]# exportfs -avr
exporting 192.168.193.0/24:/tmp
exporting 192.168.193.0/24:/home/nfstestdir

mount -t nfs指定挂载的类型为nfs。

常用-o nolock选项(即不加锁),在客户端(localhost)上执行命令。

[root@localhost ~]# mkdir /aminglinux
[root@localhost ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent 
success
[root@localhost ~]# firewall-cmd --zone=public --add-port=1000-2000/tcp --permanent 
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --zone=public --query-port=80/tcp
yes
[root@localhost ~]# firewall-cmd --zone=public --remove-port=80/tcp --permanent
[root@localhost ~]# mount -t nfs -o nolock 192.168.193.128:/tmp/ /aminglinux/
[root@localhost ~]# umount /aminglinux
[root@localhost ~]# mount -a 
[root@localhost ~]# cd /aminglinux/
[root@localhost aminglinux]# touch 1.txt
[root@localhost aminglinux]# ls -l 1.txt
-rw-r--r-- 1 root root 0 8月  27 15:12 1.txt

配置ftp服务

企业用的少,个人用的多。centos自带ftp软件vsftd。

安装vsftp

[root@aminglinux-128 ~]# yum install -y vsftp db4-utils

建立与虚拟账号相关联的系统账号,

[root@aminglinux-128 ~]# useradd virftp -s /sbin/nologin

建立与虚拟账号相关的文件,

[root@aminglinux-128 ~]# vim /etc/vsftpd/vsftpd_login
[root@aminglinux-128 etc]# chmod 600 /etc/vsftpd/vsftpd_login

生成对应的库文件


[root@aminglinux-128 etc]# db_load -T -t hash -f /etc/vsftpd/vsftpd_login /etc/vsftpd/vsftpd_login.db

建立与虚拟账号相关的目录以及配置文件,

[root@aminglinux-128 etc]# mkdir /etc/vsftpd/vsftpd_user_conf
[root@aminglinux-128 etc]# cd /etc/vsftpd/vsftpd_user_conf/
[root@aminglinux-128 vsftpd_user_conf]#  mkdir /home/virftp/testuser1
[root@aminglinux-128 vsftpd_user_conf]# touch /home/virftp/testuser1/aming.txt
[root@aminglinux-128 vsftpd_user_conf]# chown -R virftp:virftp /home/virftp
[root@aminglinux-128 vsftpd_user_conf]# vim /etc/pam.d/vsftpd

修改全局配置文件

[root@aminglinux-128 ~]# vim /etc/vsftpd/vsftpd.conf
[root@aminglinux-128 ~]# systemctl start vsftpd
[root@aminglinux-128 ~]# ps aux |grep vsftp
root       6793  0.0  0.0  53260   572 ?        Ss   21:57   0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
root       6820  0.0  0.0 112720   984 pts/0    R+   21:59   0:00 grep --color=auto vsftp
[root@aminglinux-128 ~]# yum install lftp
[root@aminglinux-128 ~]# lftp [email protected]
口令: 
lftp [email protected]:~> ls          
-rw-r--r--    1 1002     1002            0 Aug 27 08:58 aming.txt
sftp:/root>


猜你喜欢

转载自blog.51cto.com/13107353/2165139