- NFS,Network File System。網絡文件系統,即經過網絡,對在不一樣主機上的文件進行共享。
- NFS最先由Sun公司開發,分2,3,4三個版本,2和3由Sun起草開發,4.0開始Netapp公司參與並主導開發,最新爲4.1版本,更新比較慢其實4.1是從2010年就開始使用了。
- NFS數據傳輸基於RPC協議,RPC爲Remote Procedure Call的簡寫。
NFS應用場景是:A,B,C三臺機器上須要保證被訪問到的文件是同樣的,A共享數據出來,B和C分別去掛載A共享的數據目錄,從而B和C訪問到的數據和A上的一致;php
在生產環境,咱們不多使用單機部署應用,由於單機存在單點故障,一旦宕機,將沒法爲前端業務提供服務,這是客戶沒法容忍的。 如今提倡的高可用及7*24服務,是咱們追求的目標。 對於一些小的應用,雙機成爲了主流。前端
咱們來看一種簡單集羣場景, 應用分別部署在A及B上, 前端經過F5或着web服務器訪問應用。NFS提供了一種機制,可讓A、B訪問C中的一個共享目錄,就像是操做本地文件同樣。 以下圖:mysql
首先:NFS包括兩部分,服務端及客戶端linux
因爲NFS服務功能不少,會有不少端口,這些端口還有可能不固定,那麼客戶端就沒法與服務器進行通訊,由於程序間通訊必須經過端口(tcp/udp都是端到端通訊),那麼就須要一箇中間的橋接機制,RPC進程即充當這樣一個角色,RPC的端口是必定的(111),當NFS啓動時,會向RPC進行註冊, 那麼客戶端PRC就能與服務器RPC進行通訊, 從而進行文件的傳輸。nginx
當客戶端用戶打開一個文件或目錄時,內核會判斷,該文件是本地文件仍是遠程共享目錄文件,若是是遠程文件則經過RPC進程訪問遠程NFS服務端的共享目錄,若是是本地文件,則直接打開。git
爲了更好的併發,RPC進程及NFS進程都有多個。web
用兩臺機器作實驗,一臺做爲服務端(ying01 192.168.112.136),一臺做爲客戶端(ying02 192.168.112.138);redis
在ying01上安裝:nfs-utils包sql
[root@ying01 ~]# yum install -y nfs-utils 已加載插件:fastestmirror
同時也在ying02上安裝:nfs-utils包;shell
[root@ying02 ~]# yum install -y nfs-utils 已加載插件:fastestmirror
在ying01上,新建配置文件;寫入如下語句
[root@ying01 ~]# vim /etc/exports /home/nfstestdir 192.168.112.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
語句釋義:
- /home/nfstestdir :共享的目錄
- rw: 讀寫
- ro: 只讀
- sync: 同步模式,內存數據實時寫入磁盤
- async :非同步模式
- no_root_squash: 客戶端掛載NFS共享目錄後,root用戶不受約束,權限很大
- root_squash: 與上面選項相對,客戶端上的root用戶收到約束,被限定成某個普通用戶
- all_squash:客戶端上全部用戶在使用NFS共享目錄時都被限定爲一個普通用戶
- anonuid/anongid: 和上面幾個選項搭配使用,定義被限定用戶的uid和gid
- 192.168.112.0/24:爲客戶端的網段;
建立nfstestdir目錄,並給予777權限;
[root@ying01 ~]# mkdir /home/nfstestdir [root@ying01 ~]# ls /home/ mysql nfstestdir user1 user11 user13 user15 user18 user4 user8 nba php-fpm user10 user12 user14 user17 user3 user7 ying111 [root@ying01 ~]# chmod 777 /home/nfstestdir/
開啓nfs服務,並監聽端口,端口111爲其默認端口;
[root@ying01 ~]# systemctl start nfs [root@ying01 ~]# netstat -lnpt 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:60556 0.0.0.0:* LISTEN 3152/rpc.statd tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 3160/rpcbind tcp 0 0 0.0.0.0:20048 0.0.0.0:* LISTEN 3172/rpc.mountd tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 975/nginx: master p tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 671/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 798/master tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 975/nginx: master p tcp 0 0 0.0.0.0:33280 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN - tcp6 0 0 :::59663 :::* LISTEN 3152/rpc.statd tcp6 0 0 :::111 :::* LISTEN 3160/rpcbind tcp6 0 0 :::20048 :::* LISTEN 3172/rpc.mountd tcp6 0 0 :::22 :::* LISTEN 671/sshd tcp6 0 0 ::1:25 :::* LISTEN 798/master tcp6 0 0 :::2049 :::* LISTEN - tcp6 0 0 :::43138 :::* LISTEN - tcp6 0 0 :::3306 :::* LISTEN 1179/mysqld
設置開機啓動:systemctl enable nfs
[root@ying01 ~]# systemctl enable nfs Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
在客戶端ying02上設置:
查看服務端共享目錄:showmount -e 192.168.112.136
[root@ying02 ~]# showmount -e 192.168.112.136 Export list for 192.168.112.136: /home/nfstestdir 192.168.112.0/24 //192.168.241.0/24網段
注意:假如沒有出現共享目錄,有下面可能,注意排查:
- 一、二者通訊問題;
- 二、把二者的防火牆關閉
掛載NFS
[root@ying02 ~]# mount -t nfs 192.168.112.136:/home/nfstestdir /mnt/ [root@ying02 ~]# df -h 文件系統 容量 已用 可用 已用% 掛載點 /dev/sda3 27G 1004M 26G 4% / devtmpfs 907M 0 907M 0% /dev tmpfs 916M 0 916M 0% /dev/shm tmpfs 916M 8.7M 908M 1% /run tmpfs 916M 0 916M 0% /sys/fs/cgroup /dev/sda1 197M 113M 84M 58% /boot tmpfs 184M 0 184M 0% /run/user/0 192.168.112.136:/home/nfstestdir 27G 7.0G 20G 27% /mnt
在增長的/mnt分區,就是NFS共享的目錄,在該目錄下建立測試文件:
[root@ying02 ~]# cd /mnt/ [root@ying02 mnt]# ls [root@ying02 mnt]# touch ying.111 [root@ying02 mnt]# ls ying.111 [root@ying02 mnt]# ls -l 總用量 0 -rw-r--r--. 1 1000 1000 0 7月 13 15:14 ying.111 //注意gud爲1000
在服務端ying01機器上,查看其詳細信息
[root@ying01 ~]# ls -l /home/nfstestdir/ 總用量 0 -rw-r--r-- 1 user1 user1 0 7月 13 15:14 ying.111 [root@ying01 ~]# id user1 uid=1000(user1) gid=1020(grp3) 組=1020(grp3),1007(user6) //uid也爲1000
**測試結果:**能夠看到建立的新文件ying.111,uid爲1000.
看下圖:假如A的NFS服務停掉了,可是B和C還在掛載着A分享的分區,這就沒法正常工做了,因爲B和C上面的進程是d狀態(不可中斷進程,在ps一節中學習到的),一旦A中止了,B和C必定會出問題,沒法服務,既不能夠重啓,也不能夠關閉,就會把系統整掛掉。因此NFS必定不能夠隨便重啓。 若是必須重啓怎麼辦?先把B和C上面的目錄卸載下來。
那麼就開始卸載 B和C的目錄,一個一個卸載下來;
出現這種狀況,不利於生產以及智能化。所以須要利用exportps命令。
exportps命令經常使用選項:
選項 | 釋義 |
---|---|
-a | 所有掛載或者所有卸載 |
-r | 從新掛載 |
-u | 卸載某一個目錄 |
-v | 顯示共享目錄 |
在服務端ying01上:
[root@ying01 ~]# exportfs -arv exporting 192.168.112.0/24:/home/nfstestdir
這樣就可讓服務器直接生效,不須要再次重啓nfs服務,也不會對客戶端形成以前所說的錯誤!
編輯配置文件,增長一個共享的目錄
[root@ying01 ~]# vim /etc/exports /home/nfstestdir 192.168.112.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000) /tmp/ 192.168.112.138(rw,sync,no_root_squash) //新增一個共享目錄,及其權限
用命令:exportfs -arv 直接生效,不用重啓NFS服務
[root@ying01 ~]# exportfs -arv exporting 192.168.112.138:/tmp //新增長的共享目錄 exporting 192.168.112.0/24:/home/nfstestdir
使用客戶端測試;
查看服務端共享目錄:showmount -e 192.168.112.136
[root@ying02 ~]# showmount -e 192.168.112.136 Export list for 192.168.112.136: /home/nfstestdir 192.168.112.0/24 /tmp 192.168.112.138 [root@ying02 ~]# mount -t nfs 192.168.112.136:/tmp /mnt/ [root@ying02 ~]# df -h 文件系統 容量 已用 可用 已用% 掛載點 /dev/sda3 27G 1004M 26G 4% / devtmpfs 907M 0 907M 0% /dev tmpfs 916M 0 916M 0% /dev/shm tmpfs 916M 8.6M 908M 1% /run tmpfs 916M 0 916M 0% /sys/fs/cgroup /dev/sda1 197M 113M 84M 58% /boot tmpfs 184M 0 184M 0% /run/user/0 192.168.112.136:/tmp 27G 7.0G 20G 27% /mnt
在mnt下建立一個測試文本;
新檢測試文本1212.txt,查看其gid和uid都爲root;
[root@ying02 ~]# vi /mnt/1212.txt [root@ying02 ~]# ls -l /mnt/ 總用量 1988 -rw-r--r--. 1 root root 33 7月 13 15:44 1212.txt -rw-r--r--. 1 root root 29744 7月 11 23:36 mysql2.sql -rw-r--r--. 1 root root 1311133 7月 11 23:32 mysql_all.sql -rw-r--r--. 1 root root 655770 7月 11 22:49 mysqlbak.sql srwxrwxrwx. 1 1060 1060 0 7月 13 10:59 mysql.sock drwxr-xr-x. 3 root root 18 6月 25 13:57 pear -rw-r--r--. 1 daemon daemon 1842 7月 2 11:35 php_errors.log-20180704 srw-rw-rw-. 1 root root 0 7月 13 10:59 php-fcgi.sock drwx------. 3 root root 17 7月 13 10:58 systemd-private-88c2142b67f24ac1bcaeaf0f2fa0d228-chronyd.service-FDdtJL drwx------. 3 root root 17 7月 13 10:58 systemd-private-88c2142b67f24ac1bcaeaf0f2fa0d228-vgauthd.service-HwW5sv drwx------. 3 root root 17 7月 13 10:58 systemd-private-88c2142b67f24ac1bcaeaf0f2fa0d228-vmtoolsd.service-jYj9pf -rw-r--r--. 1 root root 4229 7月 9 13:09 test.com.log -rw-r--r--. 1 root root 174 7月 5 21:02 test.com.log-20180704 -rw-r--r--. 1 root root 7223 7月 11 23:24 user.sql srw-rw-rw-. 1 root root 0 7月 13 10:59 ying.sock
在服務端ying01下
查看/tmp目錄下的1212.txt測試文本,其uid和gid都爲root
[root@ying01 ~]# ls -l /tmp/ 總用量 1988 -rw-r--r-- 1 root root 33 7月 13 15:44 1212.txt -rw-r--r-- 1 root root 29744 7月 11 23:36 mysql2.sql -rw-r--r-- 1 root root 1311133 7月 11 23:32 mysql_all.sql -rw-r--r-- 1 root root 655770 7月 11 22:49 mysqlbak.sql srwxrwxrwx 1 mysql mysql 0 7月 13 10:59 mysql.sock drwxr-xr-x 3 root root 18 6月 25 13:57 pear -rw-r--r-- 1 daemon daemon 1842 7月 2 11:35 php_errors.log-20180704 srw-rw-rw- 1 root root 0 7月 13 10:59 php-fcgi.sock drwx------ 3 root root 17 7月 13 10:58 systemd-private-88c2142b67f24ac1bcaeaf0f2fa0d228-chronyd.service-FDdtJL drwx------ 3 root root 17 7月 13 10:58 systemd-private-88c2142b67f24ac1bcaeaf0f2fa0d228-vgauthd.service-HwW5sv drwx------ 3 root root 17 7月 13 10:58 systemd-private-88c2142b67f24ac1bcaeaf0f2fa0d228-vmtoolsd.service-jYj9pf -rw-r--r-- 1 root root 4229 7月 9 13:09 test.com.log -rw-r--r-- 1 root root 174 7月 5 21:02 test.com.log-20180704 -rw-r--r-- 1 root root 7223 7月 11 23:24 user.sql srw-rw-rw- 1 root root 0 7月 13 10:59 ying.sock
注意:NFS 4版本會有該問題
咱們在分享一個目錄且權限設置爲no_root_squash,客戶端看到的文件屬主、組不是root,倒是nobody。 這個不是設置錯誤,是軟件自己自帶的BUG。
解決方案:
[root@ying02 ~]# mount -t nfs -o,nfsvers=3 192.168.112.136:/tmp /mnt/ [root@ying02 ~]# df -h 文件系統 容量 已用 可用 已用% 掛載點 /dev/sda3 27G 1004M 26G 4% / devtmpfs 907M 0 907M 0% /dev tmpfs 916M 0 916M 0% /dev/shm tmpfs 916M 8.6M 908M 1% /run tmpfs 916M 0 916M 0% /sys/fs/cgroup /dev/sda1 197M 113M 84M 58% /boot tmpfs 184M 0 184M 0% /run/user/0 192.168.112.136:/tmp 27G 7.0G 20G 27% /mnt
[root@ying02 ~]# vi /etc/idmapd.conf #Domain = local.domain.edu // 改成 Domain = xxx.com
而後再重啓rpcidmapd服務;
咱們以前傳輸文件所用的是rzsz命令,能夠簡單明瞭的就把咱們所需的文件下載或者上傳。可是有個缺陷,不能夠上傳或者下載大致積的文件。FTP就能夠解決這個問題! 超過4G, 跳板機,
FTP是File Transfer Protocol(文件傳輸協議,簡稱文傳協議)的英文簡稱,用於在Internet上控制文件的雙向傳輸。
FTP的主要做用就是讓用戶鏈接一個遠程計算機(這些計算機上運行着FTP服務器程序),並查看遠程計算機中的文件,而後把文件從遠程計算機複製到本地計算機,或把本地計算機的文件傳送到遠程計算機。 小公司用的多,大企業不用FTP,由於不安全。大多數的企業使用git。
centos上自帶的FTP軟件vsftpd,默認沒有安裝;須要用yum安裝;
[root@ying01 ~]# yum install -y vsftpd
安裝後,不用配置,能夠直接使用,默認支持使用系統帳號登陸,可是由於安全緣由,須要創建帳號體系;
[root@ying01 ~]# useradd -s /sbin/nologin virftp //建立虛擬用戶 [root@ying01 ~]# vim /etc/vsftpd/vsftpd_login //編寫帳號、密碼文件 ying001 //帳號 1223 //密碼 ying002 //帳號 1225 //密碼
vsfptd 使用的密碼不是明文,因此須要生產相對應的庫文件;
[root@ying01 ~]# ls /etc/vsftpd/vsftpd_login /etc/vsftpd/vsftpd_login [root@ying01 ~]# ls /etc/vsftpd/ ftpusers user_list vsftpd.conf vsftpd_conf_migrate.sh vsftpd_login [root@ying01 ~]# db_load -T -t hash -f /etc/vsftpd/vsftpd_login /etc/vsftpd/vsftpd_login.db //成成庫文件 [root@ying01 ~]# ls -l /etc/vsftpd/ 總用量 36 -rw------- 1 root root 125 8月 3 2017 ftpusers -rw------- 1 root root 361 8月 3 2017 user_list -rw------- 1 root root 5030 8月 3 2017 vsftpd.conf -rwxr--r-- 1 root root 338 8月 3 2017 vsftpd_conf_migrate.sh -rw------- 1 root root 26 7月 15 08:09 vsftpd_login -rw-r--r-- 1 root root 12288 7月 15 08:12 vsftpd_login.db //此爲生成的庫文件密碼
建立與虛擬帳號相關的虛擬帳號,以及配置文件
[root@ying01 ~]# mkdir /etc/vsftpd/vsftpd_user_conf [root@ying01 ~]# cd /etc/vsftpd/vsftpd_user_conf [root@ying01 vsftpd_user_conf]# vim ying001 //新建ying001帳號的配置文件 local_root=/home/virftp/ying001 //虛擬用戶的家目錄 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 //最大容許鏈接的clients客戶端
建立帳號ying001的家目錄,並在其下面建立新文件
[root@ying01 vsftpd_user_conf]# mkdir /home/virftp/ying001 [root@ying01 vsftpd_user_conf]# touch /home/virftp/ying001/test.txt [root@ying01 vsftpd_user_conf]# chown -R virftp:virftp /home/virftp //更改整個目錄權限
配置認證文件及路徑。按下面增長2行語句;注意每行語句後面不能有空格;
[root@ying01 vsftpd_user_conf]# vim /etc/pam.d/vsftpd #%PAM-1.0 auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login //新增語句 account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login //新增語句 session optional pam_keyinit.so force revoke auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed auth required pam_shells.so auth include password-auth account include password-auth session required pam_loginuid.so session include password-auth ~
修改全局配置文件/etc/vsftpd/vsftpd.conf。注意每行語句後面不能有空格;
[root@ying01 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 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
啓動服務並查看啓動狀態:
[root@ying01 vsftpd_user_conf]# systemctl start vsftpd [root@ying01 vsftpd_user_conf]# ps aux |grep vsftp root 6275 0.0 0.0 53256 572 ? Ss 08:31 0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf //啓動成功 root 6279 0.0 0.0 112720 984 pts/1 S+ 08:32 0:00 grep --color=auto vsftp [root@ying01 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:60556 0.0.0.0:* LISTEN 3152/rpc.statd tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 3160/rpcbind tcp 0 0 0.0.0.0:20048 0.0.0.0:* LISTEN 3172/rpc.mountd tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 975/nginx: master p tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 671/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 798/master tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 975/nginx: master p tcp 0 0 0.0.0.0:33280 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN - tcp6 0 0 :::59663 :::* LISTEN 3152/rpc.statd tcp6 0 0 :::111 :::* LISTEN 3160/rpcbind tcp6 0 0 :::20048 :::* LISTEN 3172/rpc.mountd tcp6 0 0 :::21 :::* LISTEN 6275/vsftpd tcp6 0 0 :::22 :::* LISTEN 671/sshd tcp6 0 0 ::1:25 :::* LISTEN 798/master tcp6 0 0 :::2049 :::* LISTEN - tcp6 0 0 :::43138 :::* LISTEN - tcp6 0 0 :::3306 :::* LISTEN 1179/mysqld [root@ying01 vsftpd_user_conf]#
注意: 21端口FTP; 22端口SSHD; 23端口TELNET
服務器端安裝lftp
[root@ying01 ~]# yum install -y lftp
查看服務端的文件:lftp ying001@127.0.0.1
[root@ying01 ~]# lftp ying001@127.0.0.1 //鏈接ying001用戶 口令: //剛纔設置的密碼,1223 lftp ying001@127.0.0.1:~> ls //查看ying001目錄下的文件 -rw-r--r-- 1 1062 1062 0 Jul 15 00:23 test.txt lftp ying001@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 ying001@127.0.0.1:/>
使用 get+文件名 來下載一個文件到根目錄:/root/
lftp ying001@127.0.0.1:/> get test.txt //獲取test.txt文件,存放在root下 lftp ying001@127.0.0.1:/> quit [root@ying01 ~]# ls 10 11 221.txt 3 555 8 anaconda-ks.cfg ccc grep ib_logfile1 sed shiyan test.txt xargs 100 12zhang 222 5 6 9 awk ch ib_logfile0 NBA sed1 test wenben ysb [root@ying01 ~]# ls -l test.txt -rw-r--r-- 1 root root 0 7月 15 08:23 test.txt
原理就是:使用sftp模式登陸服務器
第一步:在xshell下,新建會話,按下圖設置其屬性;
第二步:按下圖,設置其目標目錄;
第三步:此時彈出頁面,填寫主機名,root
第四步:此時進入到/root下,能夠到有大文件的目錄xia;
sftp:/root> cd /usr/local/src/ //進入一個目錄下 sftp:/usr/local/src> ls drwxr-xr-x 9 root root 4096 Jul 3 16:52 . drwxr-xr-x 21 root root 254 Jul 3 16:55 .. -rw-r--r-- 1 root root 9076901 Mar 22 00:20 httpd-2.4.33.tar.gz drwxr-sr-x 12 root 40 4096 Jun 25 12:38 httpd-2.4.33 -rw-r--r-- 1 root root 316320366 Mar 18 2017 mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz -rw-r--r-- 1 root root 541295045 May 16 2017 mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz -rw-r--r-- 1 root root 9076901 Mar 22 00:20 httpd-2.4.33.tar.gz.1 -rw-r--r-- 1 root root 1072661 Oct 23 2017 apr-1.6.3.tar.gz -rw-r--r-- 1 root root 428595 Oct 23 2017 apr-util-1.6.1.tar.bz2 drwxr-xr-x 28 nba user2 4096 Jun 24 22:33 apr-1.6.3 drwxr-xr-x 21 nba user2 4096 Jun 25 11:33 apr-util-1.6.1 -rw-r--r-- 1 root root 15055569 Oct 25 2017 php-5.6.32.tar.bz2 drwxr-xr-x 17 user1 user1 4096 Jul 3 15:25 php-5.6.32 -rw-r--r-- 1 root root 15732452 Jun 7 2017 php-7.1.6.tar.bz2 drwxrwxr-x 19 user1 user1 4096 Jun 25 15:57 php-7.1.6 -rw-r--r-- 1 root root 239183 Jul 2 12:16 phpredis-develop.zip drwxr-xr-x 11 root root 4096 Jul 2 12:23 phpredis-develop -rw-r--r-- 1 root root 769153 Mar 19 2014 nginx-1.4.7.tar.gz drwxr-xr-x 9 nba user2 186 Jul 3 16:54 nginx-1.4.7 sftp:/usr/local/src> get httpd-2.4.33.tar.gz //獲取此文件 Fetching /usr/local/src/httpd-2.4.33.tar.gz to httpd-2.4.33.tar.gz sftp: received 8.65 MB in 0.50 seconds sftp:/usr/local/src> get mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz //再獲取一個文件 Fetching /usr/local/src/mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz to mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz sftp: received 516 MB in 24.38 seconds
此時windows在桌面上,找到對應的目錄,便可看到相應的文件;
在xshell界面上按下「ctrl+alt+F」彈出如下對話框
此時會彈出一個xftp 6 下載網頁,許可證選擇 學校和家庭,其他本身填寫
而後會彈出,此信息,下載連接已經發到你的郵箱;下載安裝就能夠了。
安裝完成後,回到虛擬機上,按下「ctrl+alt+F」彈出軟件界面
咱們選擇好要傳輸的目錄;好比按下圖,我傳輸NBA目錄到,windows下
此時可以清晰的看到,windows目錄下有剛纔傳的文件;
安裝並配置pure-ftpd
[root@ying01 ~]# yum install -y pure-ftpd
配置文件 /etc/pure-ftpd/pure-ftpd.conf,
[root@ying01 ~]# vim /etc/pure-ftpd/pure-ftpd.conf
按下圖,讓其語句加載(即去掉前面的#)
由於vsftpd和pure-ftpd 共用21端口,所以須要把vsftpd服務關掉,再開啓pure-ftpd
[root@ying01 ~]# systemctl stop vsftpd [root@ying01 ~]# systemctl start pure-ftpd [root@ying01 ~]# ps aux | grep pure-ftpd root 2376 0.0 0.0 202520 1204 ? Ss 14:44 0:00 pure-ftpd (SERVER) root 2378 0.0 0.0 112720 984 pts/0 S+ 14:44 0:00 grep --color=auto pure-ftpd
建立一個新的用戶
[root@ying01 ~]# mkdir /data/ftp //建立數據目錄 [root@ying01 ~]# touch /data/ftp/123.txt //建立一個文件 [root@ying01 ~]# useradd -u 1010 pure-ftp //設置UID [root@ying01 ~]# chown -R pure-ftp:pure-ftp /data/ftp/
經過PW命令,配置相關信息;
[root@ying01 ~]# pure-pw useradd ftp_usera -u pure-ftp -d /data/ftp/ //創建相關信息 Password: Enter it again: [root@ying01 ~]# pure-pw mkdb //創建虛擬用戶數據 [root@ying01 ~]# lftp ftp_usera@127.0.0.1 口令: //輸入以前新的虛擬用戶的的密碼 lftp ftp_usera@127.0.0.1:~> ls drwxr-xr-x 2 1010 pure-ftp 21 Jul 15 14:51 . drwxr-xr-x 2 1010 pure-ftp 21 Jul 15 14:51 .. -rw-r--r-- 1 1010 pure-ftp 0 Jul 15 14:51 123.txt lftp ftp_usera@127.0.0.1:/> lftp ftp_usera@127.0.0.1:/> quit