CentOS Installation Fastdfs+nginx (day time)

Source: Internet
Author: User
Tags crc32 file url


Recently in the study and use of Fastdfs, other people's environment, after all, is someone else, I know this matter to preach ~ Preach AH ~

The following script mainly refers to the official install file, which is more authoritative, and some areas and the actual situation is inconsistent.
such as the name of the configuration file, Fastdfs installation location.


First, download
Https://github.com/happyfish100/fastdfs Fastdfs-5.05.zip

Https://github.com/happyfish100/libfastcommon Libfastcommon-1.0.7.zip

Https://github.com/happyfish100/fastdfs-nginx-module Fastdfs-nginx-module.zip
Second, installation
Install Libfastcommon-1.0.7.zip First

Decompression command Unzip Libfastcommon-1.0.7.zip

CD libfastcommon-1.0.7
./make.sh
./make.sh Install

Re-install Fastdfs
Unzip Fastdfs-5.05.zip
./make.sh
./make.sh Install

If Libfastcommon is not installed first, an error will be
"Execution./make.sh reported the following error:


Cc-wall-d_file_offset_bits=64-d_gnu_source-g-o-ddebug_flag-dos_linux-dioevent_use_epoll-c-O. /COMMON/FDFS_GLOBAL.O. /common/fdfs_global.c-i. /common-i/usr/include/fastcommon
.. /common/fdfs_global.c:20:20:fatal error:logger.h:no such file or directory
#include "Logger.h"
^
Compilation terminated. "


Iii. configuration and start-up
Location of the configuration file
/etc/fdfs/tracker.conf
/etc/fdfs/storage.conf

My Centos/etc/fdfs has 3 files client.conf.sample, storage.conf.sample, tracker.conf.sample

Rename these 3 files directly for, *.conf, modify config ~
Start Tracker First
/usr/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart
Start storage again.
/usr/bin/fdfs_storaged/etc/fdfs/storage.conf restart

It's strange why there is no start command, but restart?

[Email protected] ~]# Ps-ef|grep Tracker
Root 25433 1 0 16:26? 00:00:00/usr/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart


[Email protected] ~]# Ps-ef|grep Storage
Root 25533 1 2 16:28? 00:00:00/usr/bin/fdfs_storaged/etc/fdfs/storage.conf restart

Iv. Uploading
#把配置文件上传了
/usr/bin/fdfs_test/etc/fdfs/client.conf upload/etc/fdfs/client.conf

[Email protected] logs]#/usr/bin/fdfs_test/etc/fdfs/client.conf upload/etc/fdfs/client.conf
This was FASTDFS Client test program v5.05


Copyright (C), Happy fish/yuqing


Fastdfs may copied only under the terms of the GNU general
Public License V3, which is found in the FASTDFS source kit.
Please visit the Fastdfs Home Page http://www.csource.org/
For more detail.


[2015-10-28 17:27:29] Debug-base_path=/root/fdfsdata, connect_timeout=30, network_timeout=60, Tracker_server_count=1, anti_steal_token=0 , Anti_steal_secret_key length=0, Use_connection_pool=0, g_connection_pool_max_idle_time=3600s, Use_storage_id=0, Storage Server ID count:0


Tracker_query_storage_store_list_without_group:
Server 1. Group_name=, ip_addr=42.96.184.84, port=23000


Group_name=group1, ip_addr=42.96.184.84, port=23000
Storage_upload_by_filename
Group_name=group1, remote_filename=m00/00/00/kmc4vfywlqgaitigaaafshrmxek69.conf
Source IP address:42.96.184.84
File timestamp=2015-10-28 17:27:29
File size=1456
File crc32=2060213737
Example File url:http://42.96.184.84:8090/group1/m00/00/00/kmc4vfywlqgaitigaaafshrmxek69.conf
Storage_upload_slave_by_filename
Group_name=group1, remote_filename=m00/00/00/kmc4vfywlqgaitigaaafshrmxek69_big.conf
Source IP address:42.96.184.84
File timestamp=2015-10-28 17:27:29
File size=1456
File crc32=2060213737
Example File url:http://42.96.184.84:8090/group1/m00/00/00/kmc4vfywlqgaitigaaafshrmxek69_big.conf


Five, monitoring
/usr/bin/fdfs_monitor/etc/fdfs/client.conf


[Email protected] logs]#/usr/bin/fdfs_monitor/etc/fdfs/client.conf
[2015-10-28 17:25:13] Debug-base_path=/root/fdfsdata, connect_timeout=30, network_timeout=60, Tracker_server_count=1, anti_steal_token=0 , Anti_steal_secret_key length=0, Use_connection_pool=0, g_connection_pool_max_idle_time=3600s, Use_storage_id=0, Storage Server ID count:0


Server_count=1, server_index=0


Tracker server is 42.96.184.84:22122


Group Count:1


Group 1:
Group name = Group1
Disk total space = 20157 MB
Disk free space = 12235 MB
Trunk free space = 0 MB
Storage Server Count = 1
Active Server Count = 1
Storage Server Port = 23000
Storage HTTP Port = 8888
Store Path count = 1
SubDir count per path = 256
Current Write Server index = 0


Vi. Access to Documents
Online search, with the HTTP may not be used, maybe Ah ~
server {
Listen 80;
server_name file.fansunion.cn;
48
location/group1/m00 {
Root/root/fdfsdata/data;
Wuyi #ngx_fastdfs_module;
52}
53}

The Nginx configuration did not use the Ngx_fastdfs_module module, which appeared 403.
Http://file.fansunion.cn/group1/M00/00/00/KmC4VFYwlQGAItigAAAFsHrMXek69_big.conf
403 Forbidden
nginx/1.6.2

The local host has been configured with 42.96.184.84 file.fansunion.cn

Seven, try to install ngx_fastdfs_module, because before always 403 various problems
Refer to the install document in Ngx_fastdfs_module
1. Source installation Nginx, the previous nginx is directly installed
Nginx http://nginx.org/en/download.html

Written before the Nginx,yum remove Nginx

Before installing Nginx, you may need to install the GCC, openssl-devel, pcre-devel, and Zlib-devel repositories, as follows:
#没用
Yum Install gcc-c++
#没用
Yum Install Openssl-devel
#用了
Yum Install Pcre-devel
#用了
Yum Install Zlib-devel


./configure--ADD-MODULE=/ROOT/SOFT/FASTDFS-NGINX-MODULE-MASTER/SRC
Make
make install;

#检查语法
/usr/local/nginx/sbin/nginx-t
Nginx:configuration file/usr/local/nginx/conf/nginx.conf Test is successful
As can be seen from here, the default is to use/usr/local/nginx/conf/nginx.conf this configuration file

And before the manual command installation, the configuration file in the/etc/nginx directory, this need to pay attention to OH ~

#启动-Specify configuration file
/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf
#
/usr/local/nginx/sbin/nginx-s Reload

Ps-ef|grep Nginx
Root 20897 1 0 10:39? 00:00:00 Nginx:master Process/usr/local/nginx/sbin/nginx
Root 20918 13217 0 10:40 pts/3 00:00:00 grep nginx


Upload/usr/bin/fdfs_test/etc/fdfs/client.conf upload/etc/fdfs/client.conf again
Access file http://file.fansunion.cn/group1/M00/00/00/KmC4VFYwlQGAItigAAAFsHrMXek69_big.conf

Ln-s/root/fdfsdata/data/root/fdfsdata/data/m00

Eight, do a half-day has not done well, gas dead me ah ~
Configure firewall, restart, re-upload
Iptables-i input-p tcp-m State--state new-m TCP--dport 23000-j ACCEPT
/etc/init.d/iptables Save


/usr/local/nginx/sbin/nginx


/usr/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart
/usr/bin/fdfs_storaged/etc/fdfs/storage.conf restart
/usr/bin/fdfs_test/etc/fdfs/client.conf upload/etc/fdfs/client.conf
Http://42.96.184.84:8080/group1/M00/00/00/KmC4VFYxlIWAOq-xAAAFsCOGhRQ76_big.conf

Netstat-ano |grep 8080

All kinds of debugging nginx, all error, even the most basic configuration can not find the ~
See Nginx Log, also did not find, finally know, Nginx source installation log file located in "/usr/local/nginx/logs".

Inside error, hint/etc/fdfs/not mod_fastdfs.conf this file ~

Copy an http.conf to the/etc/fdfs directory





Nine, paralysis, paralysis ah ~ finally took care of ~
1.base_path placed under/root/fdfsdata and/root/fdfsdata2, both prompt for insufficient permissions.
Just put it under the/home/fdfsdata.
2.mime.types and other configuration files, usually the hint can not be found, from Fastdfs and other original files conf directory copy to/etc/fdfs/
3.400 or 404
May be nginx configuration or group-name that true option

It didn't turn on groupname.
Http://42.96.184.84:8080/M00/00/00/KmC4VFYxy2OAAqGdAAAFrZvGHAA99.conf

server {
Listen 80;
Panax Notoginseng server_name 42.96.184.84 alias File.test;
38
The location/{
Root/root/fdfsdata/data #;
Ngx_fastdfs_module #;
root/home/www;
Index a.html;
44}
45}
46
server{
Listen 8080;
server_name 42.96.184.84;
50
Wuyi location/m00 {
Root/home/fdfsdata/data;
Ngx_fastdfs_module;
54}
55
56}

The 1th server, is the test nginx can start normally.
The 2nd server is a data directory that listens on 8080 ports, without group mappings, to Fdfs.

URL Access with Group
Http://42.96.184.84:8080/group1/M00/00/00/KmC4VFYxy2OAAqGdAAAFrZvGHAA99.conf

Nginx Configuration
location/group1/m00 {
Root/home/fdfsdata/data;
Ngx_fastdfs_module;
51}

/etc/fdfs/mod_fastdfs.conf this configuration file.
Url_have_group_name = True (the default is False, and true is changed)

Restart Tracker, storage
Re-start Nginx
It's done ~ Oh, too ~

Ten, summary
Spend a day, finally successfully set up a preliminary FDFS environment.
Nginx+fastdfs.

Reference: http://blog.csdn.net/gaofuqi/article/details/27052155
This person writes has the mold to have kind, feels more feasible ah ~
My own, relatively tortuous, all kinds of problems, but have been solved one by one ~

http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=3598287

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

CentOS Installation Fastdfs+nginx (day time)

Related Article

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.