14.1 NFS介绍

  • NFS 是 Network File System 的缩写

  • NFS 最早由 Sun 公司开发,分2,3,4三个版本,2和3由 Sun 起草开发,4.0开始 Netapp 公司参与并主导开发,最新为4.1版本

  • NFS 数据传输基于 RPC 协议,RPC 为 Remote Procedure Call 的简写。

  • NFS 应用场景是:A,B,C 三台机器上需要保证被访问到的文件是一样的,A 共享数据出来,B 和 C 分别去挂载 A 共享的数据目录,从而B和C访问到的数据和 A 上的一致


NFS 架构

【0525】NFS服务搭建与配置、FTP服务搭建与配置_pure-ftpd

A/B/C三台主机数据一致,仅仅将A上数据拷贝到B/C上的话,B/C上数据无法实现和A的实时同步


NFS 原理图

【0525】NFS服务搭建与配置、FTP服务搭建与配置_vsftpd_02

CentOS 5 及之前的版本为 portmap,6之后之后为 rpcbind,这是同一种,启动了这个服务,实现RPC 协议通信

rpcbind 服务产生的 RPC 协议进行通信(rpcbind服务默认监听111端口),NFS服务会在RPC注册一个端口,并告知RPC,PRC通过和用户PRC数据传输,告诉用户主机端口号,用户主机通过端口号访问

NFS服务需要借助RPC协议实现通信。


14.2 NFS服务端安装配置

1、准备两台机器,一台服务端,一台客户端

服务端 ip:192.168.194.130

客户端 ip:192.168.194.132

2、服务端上安装两个包 nfs-utils、rpcbind

[root@arslinux-01 ~]# yum install -y nfs-utils rpcbind

3、客户端上安装包 nfs-utils

[root@arslinux-02 ~]# yum install -y nfs-utils

其实写不写 rpcbind,安装 nfs-utils 时都会默认安装上 rpcbind

4、服务端编辑 /etc/exports 文件

[root@arslinux-01 ~]# vim /etc/exports
/home/nfstestdir 192.168.194.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)

共享目录、要和那个机器共享目录(特殊选项)

5、服务端因为目录不存在,首先创建共享的目录,改 777 权限

[root@arslinux-01 ~]# mkdir /home/nfstestdir/
[root@arslinux-01 ~]# chmod 777 /home/nfstestdir/

6、此时 rpcbind 实际已经启动了,监听 111 端口

[root@arslinux-01 ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      7485/nginx: master
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7463/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      7794/master
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      7485/nginx: master
tcp6       0      0 :::3306                 :::*                    LISTEN      7727/mysqld
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd
tcp6       0      0 :::22                   :::*                    LISTEN      7463/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      7794/master

7、服务端启动 nfs 服务(启动 nfs 服务的同事,会自动启动 rpc 相关的服务)

[root@arslinux-01 ~]# systemctl start nfs
[root@arslinux-01 ~]# ps aux |grep nfs
root       8365  0.0  0.0      0     0 ?        S<   10:23   0:00 [nfsd4_callbacks]
root       8371  0.0  0.0      0     0 ?        S    10:23   0:00 [nfsd]
root       8372  0.0  0.0      0     0 ?        S    10:23   0:00 [nfsd]
root       8373  0.0  0.0      0     0 ?        S    10:23   0:00 [nfsd]
root       8374  0.0  0.0      0     0 ?        S    10:23   0:00 [nfsd]
root       8375  0.0  0.0      0     0 ?        S    10:23   0:00 [nfsd]
root       8376  0.0  0.0      0     0 ?        S    10:23   0:00 [nfsd]
root       8377  0.0  0.0      0     0 ?        S    10:23   0:00 [nfsd]
root       8378  0.0  0.0      0     0 ?        S    10:23   0:00 [nfsd]
root       8396  0.0  0.0 112724   988 pts/0    R+   10:24   0:00 grep --color=auto nfs
[root@arslinux-01 ~]# ps aux |grep rpc
rpc        8315  0.1  0.1  69264  1540 ?        Ss   10:23   0:00 /sbin/rpcbind -w
root       8316  0.0  0.0      0     0 ?        S<   10:23   0:00 [rpciod]
rpcuser    8317  0.0  0.1  42432  1768 ?        Ss   10:23   0:00 /usr/sbin/rpc.statd
root       8343  0.0  0.0  42624   948 ?        Ss   10:23   0:00 /usr/sbin/rpc.mountd
root       8360  0.0  0.0  45956   544 ?        Ss   10:23   0:00 /usr/sbin/rpc.idmapd
root       8398  0.0  0.0 112724   988 pts/0    R+   10:24   0:00 grep --color=auto rpc

8、服务端设置开机启动

[root@arslinux-01 ~]# systemctl enable nfs
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service


14.3 NFS配置选项

  • rw 读写

  • ro 只读

  • sync 同步模式,内存数据实时写入磁盘

  • async 非同步模式,无需实时写入,每隔一段时间,将内存数据刷入磁盘

  • no_root_squash 客户端挂载NFS共享目录后,root用户不受约束,权限很大

  • root_squash 与上面选项相对,客户端上的root用户收到约束,被限定成某个普通用户

  • all_squash 客户端上所有用户在使用NFS共享目录时都被限定为一个普通用户

  • anonuid/anongid 和上面几个选项搭配使用,定义被限定用户的uid和gid


  • 关闭客户端和服务端的防火墙

systemctl stop firewalld

setenforce 0

--不关闭防火墙,可能会出现以下错误

[root@arslinux-02 ~]# showmount -e 192.168.194.130
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)


-- showmount -e 查看对某台做了nfs服务的机器,有没有权限

[root@arslinux-02 ~]# showmount -e 192.168.194.130
Export list for 192.168.194.130:
/home/nfstestdir 192.168.133.0/24


  • 客户端上挂载:192.168.194.132

  • mount -t 类型 远程ip:共享目录 挂载点

[root@arslinux-02 ~]# mount -t nfs 192.168.194.130:/home/nfstestdir /mnt


·客户端上 /mnt 目录下创建一个新文件 20190526.txt,到服务端共享目录查看

[root@arslinux-02 ~]# touch /mnt/20190526.txt
[root@arslinux-01 ~]# ll /home/nfstestdir/
总用量 0
-rw-r--r-- 1 arslinux arslinux 0 5月  26 11:29 20190526.txt

在NFS配置选项设置了anonuid和anongid为1000,所以一旦挂载了nfs共享目录,无论客户端上用什么用户去创建文件,在服务端上都显示为uid为1000,gid为1000


14.4 exportfs命令

exportfs 这个命令是和 nfs-utils 这个包一起安装的

·更改 nfs 配置文件后,重启 nfs 服务,那么此时如果有远程客户端正在挂载共享目录,那么先停止 nfs 服务,就会导致远程客户端挂起

·NFS 服务不能随便重启,如果想重启,先将挂载的客户端先 umount 掉再重启服务端

·但是服务器过多,就太麻烦了,那么 exportfs 命令就很方便了。

exportfs:

-a             全部挂载或者全部卸载

-r             重新挂载

-u             卸载某一个目录

-v             显示共享目录

-arv         一般同时使用


  • 在 /etc/exports 里增加一行

[root@arslinux-01 ~]# vim /etc/exports
/tmp    192.168.194.132(rw,sync,no_root_squash)
  • 执行 exportfs

[root@arslinux-01 ~]# exportfs -arv
exporting 192.168.194.132:/tmp
exporting 192.168.194.0/24:/home/nfstestdir
  • 挂载到客户端上

[root@arslinux-02 ~]# showmount -e 192.168.194.130
Export list for 192.168.194.130:
/home/nfstestdir 192.168.194.0/24
/tmp             192.168.194.132
[root@arslinux-02 ~]# mount -t nfs 192.168.194.130:/tmp/ /mnt
[root@arslinux-02 ~]# df -h
文件系统               容量  已用  可用 已用% 挂载点
/dev/sda3               28G  1.2G   27G    5% /
devtmpfs               476M     0  476M    0% /dev
tmpfs                  487M     0  487M    0% /dev/shm
tmpfs                  487M  7.7M  479M    2% /run
tmpfs                  487M     0  487M    0% /sys/fs/cgroup
/dev/sda1              197M  105M   93M   54% /boot
tmpfs                   98M     0   98M    0% /run/user/0
192.168.194.130:/tmp/   28G  4.2G   24G   15% /mnt
  • 客户端 /mnt 中创建新文件,看服务端共享目录中是否有变化

[root@arslinux-02 ~]# echo "asdfafdfa" > /mnt/20190526.log
[root@arslinux-02 ~]# ll /mnt/20190526.log
-rw-r--r-- 1 root root 10 5月  26 11:51 /mnt/20190526.log
[root@arslinux-01 ~]# cat /tmp/20190526.log
asdfafdfa
[root@arslinux-01 ~]# ll /tmp/20190526.log
-rw-r--r-- 1 root root 10 5月  26 11:51 /tmp/20190526.log

客户端和服务端上的属主和属组都是 root,是因为在 nfs 配置文件中,定义了对 /tmp 共享目录下,no_root_squash 不限制 root

一般不限制root的情况比较多


14.5 NFS客户端问题

  • NFS 4 版本会有该问题

  • 客户端挂载共享目录后,不管是 root 还是普通用户,创建新文件时属主、属组为 nobody

  • 要解决问题有2种方法:

1、客户端挂载时加上 -o nfsvers=3 (指定 nfs 版本为3)

mount -t nfs -o nfsvers=3 192.168.65.128:/tmp/ /mnt

mount -t nfs -oremount,nfsvers=3 192.168.65.128:/tmp/ /mnt (须在挂载后才能remount)

2、客户端和服务端都需要 vim /etc/idmapd.conf 

把“#Domain = local.domain.edu” 改为 “Domain = xxx.com” (这里的xxx.com,随意定义吧),然后再重启 rpcidmapd 服务,CentOS 7 中没有 rpcidmapd 服务,需重启 rpcbind


15.1 FTP介绍

  • FTP是File Transfer Protocol(文件传输协议,简称文传协议)的英文简称,用于在Internet上控制文件的双向传输。

  • FTP的主要作用就是让用户连接一个远程计算机(这些计算机上运行着FTP服务器程序),并查看远程计算机中的文件,然后把文件从远程计算机复制到本地计算机,或把本地计算机的文件传送到远程计算机。

  • 小公司用的多,大企业不用FTP,因为不安全


15.2/15.3 使用vsftpd搭建ftp

1、安装 vsftpd 服务

[root@arslinux-01 ~]# yum install -y vsftpd

2、创建普通用户

[root@arslinux-01 ~]# useradd -s /sbin/nologin virftp

3、编辑虚拟用户密码文件,奇数行为用户名,偶数行为密码

[root@arslinux-01 ~]# vim /etc/vsftpd/vsftpd_login
testuser1
12345678
user1
87654321

4、密码文件权限改为 600

[root@arslinux-01 ~]# chmod 600 /etc/vsftpd/vsftpd_login

5、将以上文本文件转化成计算机可以识别的二进制文件

[root@arslinux-01 ~]# db_load -T -t hash -f /etc/vsftpd/vsftpd_login /etc/vsftpd/vsftpd_login.db
[root@arslinux-01 ~]# ll /etc/vsftpd/
总用量 36
-rw------- 1 root root   125 10月 31 2018 ftpusers
-rw------- 1 root root   361 10月 31 2018 user_list
-rw------- 1 root root  5116 10月 31 2018 vsftpd.conf
-rwxr--r-- 1 root root   338 10月 31 2018 vsftpd_conf_migrate.sh
-rw------- 1 root root    34 5月  26 16:06 vsftpd_login
-rw-r--r-- 1 root root 12288 5月  26 16:08 vsftpd_login.db

6、创建虚拟用户配置文件所在目录

[root@arslinux-01 ~]# mkdir /etc/vsftpd/vsftpd_user_conf
[root@arslinux-01 ~]# cd !$
cd /etc/vsftpd/vsftpd_user_conf
[root@arslinux-01 vsftpd_user_conf]#

7、编辑用户的配置文件

[root@arslinux-01 vsftpd_user_conf]# vim testuser1
local_root=/home/virftp/testuser1
anonymous_enable=NO
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
idle_session_timeout=600
data_connection_timeout=120
max_clients=10

local_root=/home/virftp/testuser1               定义虚拟用户家目录

anonymous_enable=NO                              是否允许匿名用户

write_enable=YES                                       是否允许可写

local_umask=022                                         umask

anon_upload_enable=NO                            是否允许匿名用户上传

anon_mkdir_write_enable=NO                     是否允许匿名用户创建目录和写

idle_session_timeout=600                            超时断开

data_connection_timeout=120                     数据传输超时时间

max_clients=10                                            最大客户端


8、创建虚拟用户家目录,更改权限

[root@arslinux-01 vsftpd_user_conf]# mkdir /home/virftp/testuser1
[root@arslinux-01 vsftpd_user_conf]# touch /home/virftp/testuser1/arslinux.txt
[root@arslinux-01 vsftpd_user_conf]# chown -R virftp:virftp /home/virftp

9、编辑 /etc/pam.d/vsftpd ,定义密码文件位置

[root@arslinux-01 vsftpd_user_conf]# vim /etc/pam.d/vsftpd

在文件最前面加上

auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login

account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login

【0525】NFS服务搭建与配置、FTP服务搭建与配置_pure-ftpd_03

10、编辑 vsftpd 主配置文件 /etc/vsftpd/vsftpd.conf

[root@arslinux-01 vsftpd_user_conf]# vim /etc/vsftpd/vsftpd.conf

将anonymous_enable=YES 改为 anonymous_enable=NO

将#anon_upload_enable=YES 改为 anon_upload_enable=NO

将#anon_mkdir_write_enable=YES 改为 anon_mkdir_write_enable=NO

【0525】NFS服务搭建与配置、FTP服务搭建与配置_XFTP_04

11、在最下方再增加几行

chroot_local_user=YES

guest_enable=YES

guest_username=virftp

virtual_use_local_privs=YES                                  //告诉服务现在使用的是虚拟用户

user_config_dir=/etc/vsftpd/vsftpd_user_conf      //定义虚拟用户配置文件所在路径

allow_writeable_chroot=YES

12、启动 vsftpd 服务

[root@arslinux-01 vsftpd_user_conf]# systemctl start vsftpd
[root@arslinux-01 vsftpd_user_conf]# ps aux|grep vsftpd
root       8396  0.0  0.0  53276   572 ?        Ss   16:29   0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
root       8398  0.0  0.0 112724   988 pts/0    R+   16:29   0:00 grep --color=auto vsftpd
[root@arslinux-01 vsftpd_user_conf]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:39342           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      7530/nginx: master
tcp        0      0 0.0.0.0:20048           0.0.0.0:*               LISTEN      7576/rpc.mountd
tcp        0      0 0.0.0.0:39058           0.0.0.0:*               LISTEN      7509/rpc.statd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7501/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      7891/master
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      7530/nginx: master
tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      -
tcp6       0      0 :::3306                 :::*                    LISTEN      7800/mysqld
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd
tcp6       0      0 :::20048                :::*                    LISTEN      7576/rpc.mountd
tcp6       0      0 :::21                   :::*                    LISTEN      8396/vsftpd
tcp6       0      0 :::22                   :::*                    LISTEN      7501/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      7891/master
tcp6       0      0 :::59161                :::*                    LISTEN      7509/rpc.statd
tcp6       0      0 :::37467                :::*                    LISTEN      -
tcp6       0      0 :::2049                 :::*                    LISTEN      -

windows 上 ftp 客户端:filezilla client


  • 安装 ftp 客户端

[root@arslinux-01 ~]# yum install -y lftp
  • 测试

[root@arslinux-01 ~]# lftp testuser1@127.0.0.1
口令:
lftp testuser1@127.0.0.1:~> ls
-rw-r--r--    1 1011     1012            0 May 26 08:17 arslinux.txt

arslinux.txt 是之前创建的文件

  • 可用命令

lftp testuser1@127.0.0.1:/> ?
!<shell-command>                     (commands)                           alias [<name> [<value>]]
attach [PID]                         bookmark [SUBCMD]                    cache [SUBCMD]
cat [-b] <files>                     cd <rdir>                            chmod [OPTS] mode file...
close [-a]                           [re]cls [opts] [path/][pattern]      debug [<level>|off] [-o <file>]
du [options] <dirs>                  exit [<code>|bg]                     get [OPTS] <rfile> [-o <lfile>]
glob [OPTS] <cmd> <args>             help [<cmd>]                         history -w file|-r file|-c|-l [cnt]
jobs [-v] [<job_no...>]              kill all|<job_no>                    lcd <ldir>
lftp [OPTS] <site>                   ln [-s] <file1> <file2>              ls [<args>]
mget [OPTS] <files>                  mirror [OPTS] [remote [local]]       mkdir [-p] <dirs>
module name [args]                   more <files>                         mput [OPTS] <files>
mrm <files>                          mv <file1> <file2>                   [re]nlist [<args>]
open [OPTS] <site>                   pget [OPTS] <rfile> [-o <lfile>]     put [OPTS] <lfile> [-o <rfile>]
pwd [-p]                             queue [OPTS] [<cmd>]                 quote <cmd>
repeat [OPTS] [delay] [command]      rm [-r] [-f] <files>                 rmdir [-f] <dirs>
scache [<session_no>]                set [OPT] [<var> [<val>]]            site <site-cmd>
source <file>                        torrent [-O <dir>] <file|URL>...     user <user|URL> [<pass>]
wait [<jobno>]                       zcat <files>                         zmore <files>
  • 下载文件

lftp testuser1@127.0.0.1:/> get arslinux.txt
lftp testuser1@127.0.0.1:/> quit
[root@arslinux-01 vsftpd_user_conf]# ls
arslinux.txt  testuser1


xshell 实现 ftp 方案:1、SFTP 2、XFTP

1、新建会话,协议为 SFTP

【0525】NFS服务搭建与配置、FTP服务搭建与配置_NFS_05

2、输入用户名、密码

3、查看文件

【0525】NFS服务搭建与配置、FTP服务搭建与配置_FTP_06

4、定义本地文件夹:(get的文件存放位置)

【0525】NFS服务搭建与配置、FTP服务搭建与配置_NFS_07

还有一个方法:

在xshell中,Ctrl + Alt + F ,下载 xftp 插件


15.4 xshell 使用 xftp 传输文件

官网下载:https://www.netsarang.com/en/all-downloads/?code=523&downloadType=0&licenseType=1


1、选择 XFTP 下载

2、选择免费通信证页面,填写信息

【0525】NFS服务搭建与配置、FTP服务搭建与配置_FTP_08

3、填写姓名,留下邮箱,网站会发个下载链接到邮箱里

4、点邮箱收到的链接,就可以下载,安装

5、安装完成后,在未打开 XFTP 的情况下,在 XSHELL 页面,Ctrl + Alt + F  呼出 XFTP

【0525】NFS服务搭建与配置、FTP服务搭建与配置_vsftpd_09

6、如果无法打开,可以重新新建会话,和 XSHELL 方法一样,填写用户名密码,就能进入到服务器

7、直接拖动文件即可上传和下载文件


15.5 使用pure-ftpd搭建ftp服务

pure-ftpd 比 vsftpd 更轻量、更简单

  • 安装 pure-ftpd(首先要安装 epel-release)

[root@arslinux-01 ~]# yum install -y pure-ftpd
  • 更改配置文件 /etc/pure-ftpd/pure-ftpd.conf

[root@arslinux-01 ~]# vim /etc/pure-ftpd/pure-ftpd.conf

找到pureftpd.pdb这行,把行首的#删除

【0525】NFS服务搭建与配置、FTP服务搭建与配置_vsftpd_10

因为 pure-ftpd 也是fptd,监听21端口,因此在启动pure-ftpd之前需要停止vsftpd,否则会报错

  • 启动 pure-ftpd (先关闭 vsftpd)

[root@arslinux-01 ~]# systemctl stop vsftpd
[root@arslinux-01 ~]# systemctl start pure-ftpd
[root@arslinux-01 ~]# ps aux|grep pure-ftpd
root       8707  0.0  0.1 202608  1200 ?        Ss   17:59   0:00 pure-ftpd (SERVER)
root       8714  0.0  0.0 112724   984 pts/0    R+   18:00   0:00 grep --color=auto pure-ftpd
[root@arslinux-01 ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:39342           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      7530/nginx: master
tcp        0      0 0.0.0.0:20048           0.0.0.0:*               LISTEN      7576/rpc.mountd
tcp        0      0 0.0.0.0:39058           0.0.0.0:*               LISTEN      7509/rpc.statd
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      8707/pure-ftpd (SER
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7501/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      7891/master
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      7530/nginx: master
tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      -
tcp6       0      0 :::3306                 :::*                    LISTEN      7800/mysqld
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd
tcp6       0      0 :::20048                :::*                    LISTEN      7576/rpc.mountd
tcp6       0      0 :::21                   :::*                    LISTEN      8707/pure-ftpd (SER
tcp6       0      0 :::22                   :::*                    LISTEN      7501/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      7891/master
tcp6       0      0 :::59161                :::*                    LISTEN      7509/rpc.statd
tcp6       0      0 :::37467                :::*                    LISTEN      -
tcp6       0      0 :::2049                 :::*                    LISTEN      -
  • 创建测试目录,用来给 pure-ftpd 用户使用

[root@arslinux-01 ~]# mkdir /data/ftp
  • 创建 pure-ftp 用户,pid 为 1020

[root@arslinux-01 ~]# useradd -u 1020 pure-ftp
  • 将目录 /data/ftp 更改属主和属组,都为 pure-ftp

[root@arslinux-01 ~]# chown -R pure-ftp:pure-ftp /data/ftp
  • 添加虚拟用户并映射到系统用户,-u 指定系统用户,-d 指定家目录

[root@arslinux-01 ~]# pure-pw useradd ftp_usera -u pure-ftp -d /data/ftp
Password:
Enter it again:
  • 把密码文件转换成 pure-ftpd 能识别的文件

[root@arslinux-01 ~]# pure-pw mkdb
  • 在 /data/ftp 中创建文件,再到 ftp 中查看是否存在

[root@arslinux-01 ~]# echo "12343aefdfa" > /data/ftp/123.txt
[root@arslinux-01 ~]# lftp ftp_usera@127.0.0.1
口令:
lftp ftp_usera@127.0.0.1:~> ls
drwxr-xr-x    2 1020       pure-ftp           21 May 26 18:09 .
drwxr-xr-x    2 1020       pure-ftp           21 May 26 18:09 ..
-rw-r--r--    1 0          0                  12 May 26 18:09 123.txt
  • 给 123.txt 改属主、属组

[root@arslinux-01 ~]# chown pure-ftp:pure-ftp /data/ftp/123.txt
[root@arslinux-01 ~]# lftp ftp_usera@127.0.0.1
口令:
lftp ftp_usera@127.0.0.1:~> ls
drwxr-xr-x    2 1020       pure-ftp           21 May 26 18:09 .
drwxr-xr-x    2 1020       pure-ftp           21 May 26 18:09 ..
-rw-r--r--    1 1020       pure-ftp           12 May 26 18:09 123.txt

属主映射为uid,属组映射为系统里组的名称


扩展

vsftp使用mysql存放虚拟用户并验证 http://www.aminglinux.com/bbs/thread-342-1-1.html

ftp的主动和被动模式  http://www.aminglinux.com/bbs/thread-961-1-1.html


课堂笔记

1·、NFS 使用场景分析

小范围文件共享,服务器多了,很慢,3台以内

2、NFS 生产环境使用注意事项

PHP卡死,无法释放资源,单点故障隐患

暂时不让去读

如何避免:rsync + inotify(条件触发自动同步工具),一份数据存两份

NFS 背景是否适合,网络是否会造成拥堵,读写频率很快的话,那么不合适

NFS 共享数据库不允许,图片,文本文件可以

3、FTP 使用场景分析

上传下载文件,小公司比较常用

FTP 走21端口,SFTP 走22端口,基于openssl加密,更安全

4、FTP 使用建议

代码发布工具发布

5、FTP 的主动和被动 http://ask.apelearn.com/question/961

端口