【前言】nginx
在工做過程當中用到了FastDFS來作分佈式文件管理和存儲,關於FastDFS的東西百科(詳情猛擊me)寫的很明白,在此再也不贅述;接下來主要爲你們介紹一下FastDFS搭建過程。c++
【FastDFS搭建詳解】瀏覽器
1、所需基本環境服務器
一、Linux版本:CentOS7分佈式
二、FastDFS版本:5.05工具
三、Xsheel版本:5學習
2、FastDFS安裝測試
一、安裝gcc
yum install gcc-c++
二、安裝libevent工具包
yum -y install libevent
三、安裝wget
yum -y install wget
四、安裝perl
(1)wget http://www.cpan.org/src/5.0/perl-5.24.1.tar.gz
(2)tar -xzf perl-5.24.1.tar.gz
(3)cd perl-5.24.1
(4)./Configure -des -Dprefix=$HOME/localperl
(5)make
(6)make test
(7)make install
五、安裝libfastcommon-1.0.7
(1)下載
(2)unzip libfastcommon-1.0.7.zip (若沒有unzip插件則用yum install -y unzip zip安裝)
(3)cd libfastcommon-1.0.7
(4)./make.sh
(5)./make.sh install
(6)將 /usr/lib64 中的libfastcommon.so 拷貝到/usr/lib下
cp /usr/lib64/libfastcommon.so /usr/lib/
六、安裝Tracker服務。
(1)解壓縮(FastDFS_v5.05.tar.gz)
(2)./make.sh
(3)./make.sh install
安裝後在/usr/bin/目錄下有以fdfs開頭的文件都是編譯出來的。
配置文件都放到/etc/fdfs文件夾
(4)把/root/FastDFS/conf目錄下的全部的配置文件都複製到/etc/fdfs下。
(5)配置tracker服務。修改/root/FastDFS/conf/tracker.conf文件。
(6)啓動tracker。/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
重啓使用命令:/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
七、安裝storage服務
(1)若是是在不一樣的服務器安裝,第四步的1~4須要從新執行
(2)配置storage服務。修改/root/FastDFS/conf/storage.conf文件
(3)啓動storage服務。
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
八、測試服務
(1)修改配置文件/etc/fdfs/client.conf
插件
(2)測試
/usr/bin/fdfs_test /etc/fdfs/client.conf upload anti-steal.jpg
九、啓動tracker和storage的命令改善
(1)每次啓動fastdfs啓動都須要輸入如下這兩個命令不容易記
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
(2)進行相關改善
①trackerd相關:
vi /etc/init.d/fdfs_trackerd
修改相應的路徑(共5處)
3d
②storaged相關
vi /etc/init.d/fdfs_storaged
修改相應的路徑,有五處
③設置環境變量
vi /etc/profile
在最末尾加入
④環境變量生效:
source /etc/profile
(3)啓動命令變爲
fdfs_trackerd start
fdfs_storaged start
(4)執行完(3)中命令後分別用如下命令進行檢查
ps -ef | grep trackerd
ps -ef | grep storage
3、搭建nginx提供http服務
一、說明:
可使用官方提供的nginx插件。要使用nginx插件須要從新編譯。
fastdfs-nginx-module_v1.16.tar03.gz
二、解壓插件壓縮包
三、修改/root/fastdfs-nginx-module/src/config文件,把其中的local去掉。
四、對nginx從新config
./configure \
--prefix=/usr/local/nginx-1.10.3 \
--add-module=/root/fastdfs-nginx-module/src
五、make
六、make install
七、修改環境變量
(1)vi /etc/profile 加入如下內容
(2)source /etc/profile
八、將配置文件修改成配置文件在Nginx安裝目錄下的conf中的nginx.conf
/usr/local/nginx-1.10.3/sbin/nginx -c /usr/local/nginx-1.10.3/conf/nginx.conf
九、把/root/fastdfs-nginx-module/src/mod_fastdfs.conf文件複製到/etc/fdfs目錄下。編輯:
十、nginx的配置
在nginx的配置文件中添加一個Server:
十一、將libfdfsclient.so拷貝至/usr/lib下
cp /usr/lib64/libfdfsclient.so /usr/lib/
十二、啓動nginx
1三、進行測試
(1)進入相關目錄
cd /etc/fdfs/
(2)上傳圖片
/usr/bin/fdfs_test /etc/fdfs/client.conf upload anti-steal.jpg
(3)在瀏覽器中進行訪問
【總結】
一、實踐出真知;
二、持續不斷的去學習;
三、不斷去接受新的事物。