FastDFS安裝配置

安裝libfastcommon依賴環境

官網下載,或者連接:https://pan.baidu.com/s/1jIVjy0Q 密碼:jxkj(其餘人的網盤)html

tar -zxvf libfastcommon.tar.gz cd libfastcommon-1.0.7/ ./make.sh ./make.sh install cp /usr/lib64/libfastcommon.so /usr/lib

 

安裝FastDFS

官網下載,或者連接:https://pan.baidu.com/s/1c2SDMjI 密碼:8ujt(其餘人的網盤)nginx

tar -zxvf FastDFS_v5.05.tar.gz cd FastDFS/ ./make.sh ./make.sh install

 

啓動tracker

安裝tracker,因爲tracker運行程序就是fasfdfs,直接用配置文件運行便可git

cd /etc/fdfs cp tracker.conf.sample tracker.conf cp storage.conf.sample storage.conf vi tracker.conf 修改以下數據 # Tracker 數據和日誌目錄地址(此目錄必須存在,子目錄會自動建立) base_path=/opt/fastdfs/tracker # HTTP 服務端口 http.server_port=80 建立上面目錄 mkdir /opt/fastdfs/tracker 啓動 systemctl start fdfs_trackerd
設置開機啓動
chkconfig fdfs_trackerd on

啓動錯誤記錄:github

[root@VM_176_134_centos fdfs]# systemctl start fdfs_trackerd Job for fdfs_trackerd.service failed because the control process exited with error code. See "systemctl status fdfs_trackerd.service" and "journalctl -xe" for details. [root@VM_176_134_centos fdfs]# journalctl -xe Dec 28 12:02:22 VM_176_134_centos systemd[1]: fdfs_trackerd.service: control process exited, code=exited status=2 Dec 28 12:02:22 VM_176_134_centos systemd[1]: Failed to start LSB: FastDFS tracker server. -- Subject: Unit fdfs_trackerd.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit fdfs_trackerd.service has failed. -- 
-- The result is failed. Dec 28 12:02:22 VM_176_134_centos systemd[1]: Unit fdfs_trackerd.service entered failed state. Dec 28 12:02:22 VM_176_134_centos systemd[1]: fdfs_trackerd.service failed. Dec 28 12:02:22 VM_176_134_centos polkitd[1584]: Unregistered Authentication Agent for unix-process:3685:66989990 (system bus name :1.25092, object path /org/freedesktop/PolicyKit1/AuthenticationA Dec 28 12:02:40 VM_176_134_centos sshd[3703]: Invalid user ubnt from 206.189.225.113 Dec 28 12:02:40 VM_176_134_centos sshd[3703]: input_userauth_request: invalid user ubnt [preauth] Dec 28 12:02:40 VM_176_134_centos sshd[3703]: pam_unix(sshd:auth): check pass; user unknown Dec 28 12:02:40 VM_176_134_centos sshd[3703]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=206.189.225.113 Dec 28 12:02:42 VM_176_134_centos sshd[3703]: Failed password for invalid user ubnt from 206.189.225.113 port 36530 ssh2 Dec 28 12:02:42 VM_176_134_centos sshd[3703]: Received disconnect from 206.189.225.113: 11: Bye Bye [preauth] Dec 28 12:02:51 VM_176_134_centos sshd[3712]: Invalid user admin from 206.189.225.113 Dec 28 12:02:51 VM_176_134_centos sshd[3712]: input_userauth_request: invalid user admin [preauth] Dec 28 12:02:51 VM_176_134_centos sshd[3712]: pam_unix(sshd:auth): check pass; user unknown Dec 28 12:02:51 VM_176_134_centos sshd[3712]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=206.189.225.113 Dec 28 12:02:52 VM_176_134_centos sshd[3712]: Failed password for invalid user admin from 206.189.225.113 port 43716 ssh2 Dec 28 12:02:52 VM_176_134_centos sshd[3712]: Connection closed by 206.189.225.113 [preauth] Dec 28 12:03:01 VM_176_134_centos systemd[1]: Started Session 12492 of user root. -- Subject: Unit session-12492.scope has finished start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-12492.scope has finished starting up. -- 
-- The start-up result is done. Dec 28 12:03:01 VM_176_134_centos CROND[3730]: (root) CMD (/usr/local/qcloud/stargate/admin/start.sh > /dev/null 2>&1 &) Dec 28 12:03:10 VM_176_134_centos sshd[3750]: Invalid user eo from 106.37.75.74 Dec 28 12:03:10 VM_176_134_centos sshd[3750]: input_userauth_request: invalid user eo [preauth] Dec 28 12:03:10 VM_176_134_centos sshd[3750]: pam_unix(sshd:auth): check pass; user unknown Dec 28 12:03:10 VM_176_134_centos sshd[3750]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=106.37.75.74 Dec 28 12:03:12 VM_176_134_centos sshd[3750]: Failed password for invalid user eo from 106.37.75.74 port 56156 ssh2 Dec 28 12:03:12 VM_176_134_centos sshd[3750]: Received disconnect from 106.37.75.74: 11: Bye Bye [preauth]
View Code

解決記錄:docker

上面錯誤日誌可發現file /usr/local/bin/fdfs_trackerd does not exist! 查找:find / -name fdfs_trackerd 獲得結果: /etc/rc.d/init.d/fdfs_trackerd /usr/bin/fdfs_trackerd /root/FastDFS/init.d/fdfs_trackerd /root/FastDFS/tracker/fdfs_trackerd 檢查trackerd.conf,並沒指定此路徑,難道在環境變量?不去折騰,直接複製,其它找不到的文件作一樣處理 cp /usr/bin/fdfs_trackerd /usr/local/bin/fdfs_trackerd cp /usr/bin/stop.sh /usr/local/bin/stop.sh cp /usr/bin/restart.sh /usr/local/bin/restart.sh
View Code

 

啓動storage

因爲storage和tracker運行的都是fastDFS程序,每一臺服務器都部署一臺fasfDFS,一臺服務器是tracker,一臺是storage。 vim

 

cd /etc/fdfs cp storage.conf.sample storage.conf vi storage.conf 修改以下 base_path=/opt/fastdfs/storage store_path0=/opt/fastdfs/file
tracker_server=10.0.0.111:22122 建立上面文件夾 mkdir
/opt/fastdfs/storage mkdir /opt/fastdfs/file 啓動systemctl start fdfs_storaged
設置開機啓動
chkconfig
fdfs_storaged on

 啓動問題記錄:啓不起來storagecentos

解決方法: tracker_server=10.0.0.111:22122,不能寫成127.0.0.1,必須寫外網訪問到的?bash

參考以下:服務器

 

內部上傳文件測試

切換目錄:cd /etc/fdfs/session

拷貝配置:cp client.conf.sample client.conf

修改配置:vi client.conf

base_path=/opt/fastdfs/client

tracker_server=10.200.67.5:22122

生成文件夾:mkdir /opt/fastdfs/client

生成測試文件:echo hello>>test.txt

上傳文件:/usr/bin/fdfs_upload_file /etc/fdfs/client.conf test.txt

上傳結果:group1/M00/00/00/CshDBVwvEheAMjRsAAAABncc3SA527.txt

[root@localhost fdfs]# ls anti-steal.jpg client.conf.sample http.conf mime.types mod_fastdfs.conf storage.conf storage.conf.sample tracker.conf tracker.conf.sample [root@localhost fdfs]# cp client.conf.sample client.conf [root@localhost fdfs]# vi client.conf [root@localhost fdfs]# hello >>test.txt -bash: hello: command not found [root@localhost fdfs]# echo hello>>test.txt [root@localhost fdfs]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf test.txt [2019-01-04 15:57:20] ERROR - file: ../client/client_func.c, line: 257, "/opt/fastdfs/client" can't be accessed, error info: No such file or directory
[root@localhost fdfs]# mkdir /opt/fastdfs/client [root@localhost fdfs]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf test.txt group1/M00/00/00/CshDBVwvEheAMjRsAAAABncc3SA527.txt
View Code

在/opt/fastdfs/file/data/00/00能夠找到剛剛上傳的文件

[root@localhost fdfs]# cd /opt/fastdfs/ [root@localhost fastdfs]# ls client file storage tracker [root@localhost fastdfs]# cd file/ [root@localhost file]# ls data [root@localhost file]# cd data/ [root@localhost data]# ls 00  06  0C  12  18  1E  24  2A  30  36  3C  42  48  4E  54  5A  60  66  6C  72  78  7E  84  8A  90  96 9C A2 A8 AE B4 BA C0 C6 CC D2 D8 DE E4 EA F0 F6 FC 01  07  0D  13  19  1F  25  2B  31  37  3D  43  49  4F  55  5B  61  67  6D  73  79  7F  85  8B  91  97 9D A3 A9 AF B5 BB C1 C7 CD D3 D9 DF E5 EB F1 F7 FD 02  08  0E  14  1A  20  26  2C  32  38  3E  44  4A  50  56  5C  62  68  6E  74  7A  80  86  8C  92  98 9E A4 AA B0 B6 BC C2 C8 CE D4 DA E0 E6 EC F2 F8 FE 03  09  0F  15  1B  21  27  2D  33  39  3F  45  4B  51  57  5D  63  69  6F  75  7B  81  87  8D  93  99 9F A5 AB B1 B7 BD C3 C9 CF D5 DB E1 E7 ED F3 F9 FF 04  0A  10  16  1C  22  28  2E  34  3A  40  46  4C  52  58  5E  64  6A  70  76  7C  82  88  8E  94 9A A0 A6 AC B2 B8 BE C4 CA D0 D6 DC E2 E8 EE F4 FA 05  0B  11  17  1D  23  29  2F  35  3B  41  47  4D  53  59  5F  65  6B  71  77  7D  83  89  8F  95 9B A1 A7 AD B3 B9 BF C5 CB D1 D7 DD E3 E9 EF F5 FB [root@localhost data]# cd 0
00/ 01/ 02/ 03/ 04/ 05/ 06/ 07/ 08/ 09/ 0A/ 0B/ 0C/ 0D/ 0E/ 0F/ [root@localhost data]# cd 00 [root@localhost 00]# ls 00  06  0C  12  18  1E  24  2A  30  36  3C  42  48  4E  54  5A  60  66  6C  72  78  7E  84  8A  90  96 9C A2 A8 AE B4 BA C0 C6 CC D2 D8 DE E4 EA F0 F6 FC 01  07  0D  13  19  1F  25  2B  31  37  3D  43  49  4F  55  5B  61  67  6D  73  79  7F  85  8B  91  97 9D A3 A9 AF B5 BB C1 C7 CD D3 D9 DF E5 EB F1 F7 FD 02  08  0E  14  1A  20  26  2C  32  38  3E  44  4A  50  56  5C  62  68  6E  74  7A  80  86  8C  92  98 9E A4 AA B0 B6 BC C2 C8 CE D4 DA E0 E6 EC F2 F8 FE 03  09  0F  15  1B  21  27  2D  33  39  3F  45  4B  51  57  5D  63  69  6F  75  7B  81  87  8D  93  99 9F A5 AB B1 B7 BD C3 C9 CF D5 DB E1 E7 ED F3 F9 FF 04  0A  10  16  1C  22  28  2E  34  3A  40  46  4C  52  58  5E  64  6A  70  76  7C  82  88  8E  94 9A A0 A6 AC B2 B8 BE C4 CA D0 D6 DC E2 E8 EE F4 FA 05  0B  11  17  1D  23  29  2F  35  3B  41  47  4D  53  59  5F  65  6B  71  77  7D  83  89  8F  95 9B A1 A7 AD B3 B9 BF C5 CB D1 D7 DD E3 E9 EF F5 FB [root@localhost 00]# cd 00 [root@localhost 00]# ls CshDBVwvEheAMjRsAAAABncc3SA527.txt [root@localhost 00]# pwd /opt/fastdfs/file/data/00/00
View Code

理論上給這個路徑經過nginx映射出去就好了,不必裝模塊

也就是說,nignx.conf加入server以下代碼就行:

location /group1/M00 { #ngx_fastdfs_module; alias /opt/fastdfs/file/data; }

 

 

 

安裝fastdfs-nginx-module模塊

下載文件:wget https://github.com/happyfish100/fastdfs-nginx-module/archive/5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip

此處可能出現下載文件沒有後綴:mv 5e5f3566bbfa57418b5506aaefbe107a42c9fcb1 5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip

解壓:unzip 5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip

重命名:mv fastdfs-nginx-module-5e5f3566bbfa57418b5506aaefbe107a42c9fcb1 fastdfs-nginx-module-master

 

安裝nginx

上傳安裝包:put E:\yz_index\installPackage\nginx-1.14.0.tar.gz 解壓:tar -zxvf nginx-1.14.0.tar.gz 切換目錄:cd nginx-1.14.0 安裝時添加上面的模塊:./configure --add-module=../fastdfs-nginx-module-master/src
編譯:make 
安裝:make install
啓動:
/usr/local/nginx/sbin/nginx
設置開機啓動:vim
/etc/rc.local
添加一行,內容以下:
/usr/local/nginx/sbin/nginx
給權限:chmod
755 /etc/rc.local
查看安裝模塊:
/usr/local/nginx/sbin/nginx -V

切換到fastdfs-nginx-module-master目錄

複製配置文件到fdfs目錄: cp src/mod_fastdfs.conf /etc/fdfs/

複製fastdfs解壓部分文件到/etc/fdfs

cd /root/FastDFS/conf/

cp anti-steal.jpg http.conf mime.types /etc/fdfs/

nginx啓用模塊

在80端口下添加fastdfs-nginx模塊

location /group1/M00 { ngx_fastdfs_module; }

listen 80 端口值是要與 /etc/fdfs/storage.conf 中的 http.server_port=80 (前面改爲80了)相對應。若是改爲其它端口,則須要統一,同時在防火牆中打開該端口。

 

 

參考

用FastDFS一步步搭建文件管理系統

docker下搭建fastFDS單機版(附storage端口號不顯示解決方案)

相關文章
相關標籤/搜索