FASTDFS Installation and Deployment

Source: Internet
Author: User
Tags openssl library

(a) Download dependent library Libevent (regardless of where the decompression must be installed in the/usr directory, otherwise fastdfs not found)
wget https://github.com/downloads/libevent/libevent/libevent-1.4.14b-stable.tar.gz
Tar zvxf libevent-1.4.14b-stable.tar.gz
./configure--PREFIX=/USR
Make clean;
Make
Make install

(ii) Download FASTDFS installation package and Nginx dependent components
FASTDFS Official forum: http://www.csource.org
Download 1:http://sourceforge.net/projects/fastdfs/files/
Download 2:https://code.google.com/p/fastdfs/downloads/list

The compressed packages you need to download are:
Fastdfs Source code: fastdfs_v5.01.tar.gz
Nginx Server source code: nginx-1.4.7.tar.gz
Nginx Extension Source code: fastdfs-nginx-module_v1.15.tar.gz
Nginx Cache Plugin Source code: ngx_cache_purge-2.1.tar.gz
Nginx-dependent Pcre Library source code: pcre-8.34.tar.gz
Nginx-dependent zlib Library source code: zlib-1.2.8.tar.gz
Nginx-dependent OpenSSL library source code: openssl-fips-2.0.9.tar.gz

--Shut down the firewall
Service Iptables Stop

(iii) installation
CP fastdfs_v5.01.tar.gz/usr/local/src/
cd/usr/local/src/
TAR-ZXVF fastdfs_v5.01.tar.gz
CD Fastdfs
./make.sh
./make.sh Install

Note:
(1)./make.sh During installation errors, the dependent packages may be missing and re-executed after installation./make.sh
(2) Installation of
Source file directory in:/usr/local/src/
Executable directory in:/usr/local/bin
All profile directories in:/etc/fdfs (this directory will produce tracker.conf, storage.conf, and client.conf)

This FASTDFS installation is successful ....



(iv) Configuring and starting tracker Server
Vim/etc/fdfs/tracker.conf
--Modify the file:
Disabled=false #启用配置文件 (this time do not know how to deal with the first do not change)
port=22122 #设置tracker的端口号
Base_path=/fdfs/tracker #设置tracker的数据文件和日志目录 (pre-creation required)
http.server_port=8090 #设置http端口号
#include http.conf

Note that the top one is 1 #, the default is 2 #, minus 1.

--Open port
Iptables-i input-p tcp-m State--state new-m TCP--dport 22122-j ACCEPT
--Save firewall rules to/etc/sysconfig/iptables (manually created and authorized if Iptables does not exist)
/etc/init.d/iptables Save
--Start tracker to confirm that the boot is successful
/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart
--See if the corresponding port 22122 starts listening
NETSTAT-UNLTP | grep Fdfs
--check tracker logs for errors
Cat/fdfs/tracker/logs/trackerd.log
--Set Boot auto start
Vim/etc/rc.d/rc.local
Added:/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart



(v) Configuring and starting storage Server
Vim/etc/fdfs/storage.conf
--Modify the file:
Group_name=group1 #组名, modify according to the actual situation
port=23000 #设置storage的端口号
Base_path=/fdfs/storage #设置storage的日志目录 (pre-creation required)
Store_path_count=1 #存储路径个数, need to match the number of Store_path
Store_path0=/fdfs/storage #存储路径
tracker_server=192.168.1.103:22122 #tracker服务器的IP地址和端口号 (IP is also written if Tracker is a separate server)
http.server_port=8888 #设置http端口号
#include http.conf

--Open port
Iptables-i input-p tcp-m State--state new-m TCP--dport 23000-j ACCEPT
--Save firewall rules to/etc/sysconfig/iptables (manually created and authorized if Iptables does not exist)
/etc/init.d/iptables Save
--Start tracker to confirm that the boot is successful
/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf restart
--See if the corresponding port 23000 starts listening
NETSTAT-UNLTP | grep Fdfs
--check tracker logs for errors
Cat/fdfs/storage/logs/storaged.log
--Set Boot auto start
Vim/etc/rc.d/rc.local
Added:/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf restart

--After successful startup, run Fdfs_monitor to see if the storage server has been enlisted to the tracker server. The first few lines see Tracker's IP as normal
/usr/local/bin/fdfs_monitor/etc/fdfs/storage.conf

At this point, the non-nginx Fastdfs file system has been installed complete

(vi) Verification fastdfs upload Download (upload download can save the client configuration can be omitted)
Vim/etc/fdfs/client.conf
--Modify Client.conf
Base_path=/fdfs/client
tracker_server=192.168.1.103:22122
http.tracker_server_port=8090 #设置tracker端口号

--Upload
Fdfs_test/etc/fdfs/client.conf upload/data/monk.jpg
Http://192.168.1.103:8090/group1/M00/00/00/OlPQG1Db6jWAFmbTAAADqdgNsks5096460_big.jpg
--Delete
fdfs_test/etc/fdfs/client.conf Delete group1 m00/00/00/olpqg1db6jwafmbtaaadqdgnsks5096460_big.jpg

Http://192.168.1.103:8090/group1/M00/00/00/wKgBZ1UX8tGACWOJAACdM6nw92I711_big.jpg





Seven Fastdfs and Nginx Integration
(1) nginx install extension plug-in
CP FASTDFS-NGINX-MODULE_V1.15.TAR.GZ/USR/LOCAL/SRC
TAR-ZXVF fastdfs-nginx-module_v1.15.tar.gz
Cd/usr/local/src
CD nginx-1.4.7
./configure--prefix=/usr/local/nginx--add-module=/usr/local/src/fastdfs-nginx-module/src--with-pcre=/usr/local /src/pcre-8.34/--with-zlib=/usr/local/src/zlib-1.2.8
Make
Make install

--Copy the extension configuration file to/etc/fdfs
cp/usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/



(2) Configuration mod_fastdfs.conf
Vim/etc/fdfs/mod_fastdfs.conf
--Modify the file:
Base_path=/fdfs/storage #保存日志目录
tracker_server=192.168.1.103:22122 #tracker服务器的IP地址以及端口号
storage_server_port=23000 #storage服务器的端口号
Group_name=group1 #当前服务器的group名
Url_have_group_name = True #文件url中是否有group名
Store_path_count=1 #存储路径个数, need to match the number of Store_path
Store_path0=/fdfs/storage #存储路径
Http.need_find_content_type=true #从文件扩展名查找文件类型 (True at Nginx)
Group_count = 1 #设置组的个数

--Establish a soft connection
Ln-s/fdfs/storage/data/fdfs/storage/data/m00



(3) Configuration nginx.conf
Vim/usr/local/nginx/conf/nginx.conf
--Modify the file:
server {
Listen 8888;
Location/{
root HTML;
Index index.html index.htm;
}
location/group1/m00 {
Root/fdfs/storage/data;
Ngx_fastdfs_module;
}
}

--Restart Tracker
/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart
--Restart Storage
/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf restart
--Restart Nginx
/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx-s Reload

--View the boot log:
Cat/fdfs/tracker/logs/trackerd.log
Cat/fdfs/storage/logs/storaged.log
Cat/usr/local/nginx/logs/error.log

--Visit Nginx
http://192.168.1.103:8888/



--View Port usage:
NETSTAT-LNP--tcp

TCP 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN 1761/fdfs_storaged
TCP 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN 1718/nginx
TCP 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 1809/fdfs_trackerd
TCP 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 1809/fdfs_trackerd

The default port of 8888 is storage and is now replaced by Nginx



(8) Upload and download
--Ensure/etc/fdfs/client.conf is properly configured before uploading
Base_path=/fdfs/tracker #日志存放路径
tracker_server=192.168.1.103:22122 #tracker服务器IP地址和端口号
http.tracker_server_port=8090 #tracker服务器的http端口号

--using/usr/local/bin/fdfs_upload_file to upload a file, the program will automatically return the URL of the file
/usr/local/bin/fdfs_upload_file/etc/fdfs/client.conf/data/8.jpg

--Return:
Group1/m00/00/00/wkgbz1ux_7waqtfpaacdm6nw92i838.jpg

--Browser access:
Http://192.168.1.103:8888/group1/M00/00/00/wKgBZ1UX_7WAQTFPAACdM6nw92I838.jpg

--View Nginx's Access.log log, can see Access returned 200 successful

Tail-n 10-f/usr/local/nginx/logs/access.log



Http://nonfu.me/p/4843.html














FASTDFS Installation and Deployment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.