上一篇已經成功完成了Tracker的安裝 《Fastdfs(1)安裝之Tracker》nginx
仿照《Fastdfs(1)安裝之Tracker》將fastdfs安裝完成後再繼續下面的步驟服務器
進入 /ect/fdfs測試
[root@localhost fdfs]# cp storage.conf.sample storage.conf
只留一個storage.conf配置文件並編輯修改一下幾個地方url
disabled=false #啓用配置文件spa
group_name=group1 #組名,根據此服務器修改.net
port=23000 #設置storage的端口號,默認是23000,同一個組的storage端口號必須一致rest
base_path=/mnt/data/fastdfs #設置storage的日誌目錄 mkdir /mnt/data/fastdfs日誌
store_path_count=1 #存儲路徑個數,須要和store_path個數匹配code
store_path0=/mnt/data/fastdfs #存儲路徑orm
tracker_server=192.168.22.135:22122 #tracker_1服務器的IP地址和端口號
tracker_server=192.168.22.138:22122 #tracker_2服務器的IP地址和端口號
[root@localhost fdfs]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
啓動以前最好將兩邊的防火牆都關閉
關閉防火牆:systemctl stop firewalld.service
開機禁止防火牆啓動:systemctl disable firewalld.service
[root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# firewall-cmd --state not running [root@localhost ~]#
查看運行日誌
[root@localhost ~]# tail -f /opt/softs/fastdfs-5.05/logs/storaged.log
查看集羣狀況
[root@localhost fdfs]# /usr/bin/fdfs_monitor /etc/fdfs/storage.conf
將上面配置成功的storage虛擬機再克隆一份
[root@localhost fdfs]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
再次查看集羣狀況
設置開機啓動
chkconfig fdfs_storaged on
此時須要切換到tracker服務器操做
# 修改tracker服務器client.conf配置文件 cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf vi /etc/fdfs/client.conf base_path=/root/fastdfs tracker_server=192.168.22.135:22122 tracker_server=192.168.22.138:22122 [root@localhost fdfs]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /opt/softs/test.jpg group1/M00/00/00/wKgWhllMrr-ALtlGAABsjoZmo4c027.jpg
2.一、配置mod_fastdfs.conf
複製mod_fastdfs.conf 到/etc/fdfs 下
[root@localhost nginx-1.11.13]# cp /opt/softs/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/
複製fast的配置文件 http.conf mime.types到 /etc/fdfs/
[root@localhost conf]# pwd /opt/softs/fastdfs-master/conf [root@localhost conf]# cp http.conf mime.types /etc/fdfs/
修改 /etc/fdfs/mod_fastdfs.conf 添加storage存儲信息
[root@localhost fdfs]# vi mod_fastdfs.conf # the base path to store log files base_path=/tmp # FastDFS tracker_server can ocur more than once, and tracker_server format is # "host:port", host can be hostname or ip address # valid only when load_fdfs_parameters_from_tracker is true tracker_server=192.168.22.135:22122 #tracker服務器的IP地址以及端口號 tracker_server=192.168.22.138:22122 #tracker服務器的IP地址以及端口號 # store_path#, based 0, if store_path0 not exists, it's value is base_path # the paths must be exist # must same as storage.conf store_path0=/mnt/data/fastdfs #存儲路徑 # if the url / uri including the group name # set to false when uri like /M00/00/00/xxx # set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx # default value is false url_have_group_name = true #在末尾增長分組的具體信息: [group1] group_name=group1 storage_server_port=23000 store_path_count=1 store_path0=/mnt/data/fastdfs
創建M00至存儲目錄的符號鏈接
[root@localhost ~]# ls -s /mnt/data/fastdfs/data/ /mnt/data/fastdfs/data/M00 ls: 沒法訪問/mnt/data/fastdfs/data/M00: 沒有那個文件或目錄 /mnt/data/fastdfs/data/: 總用量 3088 12 00 12 12 12 24 12 36 12 48 12 5A 12 6C 12 7E 12 90 12 A2 12 B4 12 C6 12 D8 12 EA 12 FC 12 01 12 13 12 25 12 37 12 49 12 5B 12 6D 12 7F 12 91 12 A3 12 B5 12 C7 12 D9 12 EB 12 FD 12 02 12 14 12 26 12 38 12 4A 12 5C 12 6E 12 80 12 92 12 A4 12 B6 12 C8 12 DA 12 EC 4 fdfs_storaged.pid 12 03 12 15 12 27 12 39 12 4B 12 5D 12 6F 12 81 12 93 12 A5 12 B7 12 C9 12 DB 12 ED 12 FE 12 04 12 16 12 28 12 3A 12 4C 12 5E 12 70 12 82 12 94 12 A6 12 B8 12 CA 12 DC 12 EE 12 FF 12 05 12 17 12 29 12 3B 12 4D 12 5F 12 71 12 83 12 95 12 A7 12 B9 12 CB 12 DD 12 EF 0 storage_changelog.dat 12 06 12 18 12 2A 12 3C 12 4E 12 60 12 72 12 84 12 96 12 A8 12 BA 12 CC 12 DE 12 F0 4 storage_groups_new.dat 12 07 12 19 12 2B 12 3D 12 4F 12 61 12 73 12 85 12 97 12 A9 12 BB 12 CD 12 DF 12 F1 4 storage_servers_new.dat 12 08 12 1A 12 2C 12 3E 12 50 12 62 12 74 12 86 12 98 12 AA 12 BC 12 CE 12 E0 12 F2 4 storage_stat.dat 12 09 12 1B 12 2D 12 3F 12 51 12 63 12 75 12 87 12 99 12 AB 12 BD 12 CF 12 E1 12 F3 0 storage_sync_timestamp.dat 12 0A 12 1C 12 2E 12 40 12 52 12 64 12 76 12 88 12 9A 12 AC 12 BE 12 D0 12 E2 12 F4 0 sync 12 0B 12 1D 12 2F 12 41 12 53 12 65 12 77 12 89 12 9B 12 AD 12 BF 12 D1 12 E3 12 F5 12 0C 12 1E 12 30 12 42 12 54 12 66 12 78 12 8A 12 9C 12 AE 12 C0 12 D2 12 E4 12 F6 12 0D 12 1F 12 31 12 43 12 55 12 67 12 79 12 8B 12 9D 12 AF 12 C1 12 D3 12 E5 12 F7 12 0E 12 20 12 32 12 44 12 56 12 68 12 7A 12 8C 12 9E 12 B0 12 C2 12 D4 12 E6 12 F8 12 0F 12 21 12 33 12 45 12 57 12 69 12 7B 12 8D 12 9F 12 B1 12 C3 12 D5 12 E7 12 F9 12 10 12 22 12 34 12 46 12 58 12 6A 12 7C 12 8E 12 A0 12 B2 12 C4 12 D6 12 E8 12 FA 12 11 12 23 12 35 12 47 12 59 12 6B 12 7D 12 8F 12 A1 12 B3 12 C5 12 D7 12 E9 12 FB [root@localhost ~]#
2.二、安裝nginx和添加nginx-module
[root@localhost softs]# tar -zxvf nginx-1.11.13.tar.gz [root@localhost nginx-1.11.13]# pwd /opt/softs/nginx-1.11.13 [root@localhost nginx-1.11.13]# mkdir /usr/local/nginx [root@localhost nginx-1.11.13]# ./configure --prefix=/usr/local/nginx --add-module=/opt/softs/fastdfs-nginx-module-master/src [root@localhost nginx-1.11.13]# make [root@localhost nginx-1.11.13]# make install
2.三、經過tracker的nginx訪問上傳成功的圖片
http://192.168.22.135/group1/M00/00/00/wKgWhllMwTKAUe2pAABsjoZmo4c016.jpg