FastDFS stand-alone building

Brief introduction

FastDFS is an open source, high-performance distributed file system (DFS).
FastDFS system has three roles: Tracking server (Tracker Server), Storage Server (Storage Server) and client (Client).
  Tracker Server: tracking server, the main job of scheduling work, play a balancing role; responsible for managing all of the storage server and the group, each storage after starting connects Tracker, inform the group they belong to other information, and to maintain a periodic heartbeat.
  Storage Server: storage servers, mainly to provide capacity and back-up services; to group as a unit, each group can have more than one storage server, data back up each other.
  Client: The client, upload and download data server, which is our own projects in server deployment.
FastDFS stand-alone building

installation

Preparing the Environment

编译源码需要gcc gcc-c++ perl,软件包解压需要unzip
 yum -y install gcc gcc-c++ perl unzip

Download the package in advance that you need (to download in the / usr / local / src directory)

下载libfastcommon环境包:         wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz
下载FastDFS包:         wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz
下载nginx源码包:         wget -c https://nginx.org/download/nginx-1.12.1.tar.gz
下载 fastdfs-nginx-module插件包: wget  https://github.com/happyfish100/fastdfs-nginx-module/archive/5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip

1. Install libfastcommon
unzip and enter

tar -zxvf V1.0.7.tar.gz
cd libfastcommon-1.0.7

Compile, install

 ./make.sh
 ./make.sh install

libfastcommon.so installed by default to the /usr/lib64/libfastcommon.so. But we follow installation lib directory FastDFS main setting is / usr / local / lib, you need to create a soft link.

ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so

2. Download and install FastDFS
unzip and enter

 tar -zxvf V5.05.tar.gz
 cd fastdfs-5.05

Compile, install

 ./make.sh
 ./make.sh install

After installing the appropriate files and directories are as follows:
fastdfs service script

/etc/init.d/fdfs_storaged
/etc/init.d/fdfs_tracker

fastdfs profile

/etc/fdfs/client.conf.sample
/etc/fdfs/storage.conf.sample
/etc/fdfs/tracker.conf.sample

Command tool in / usr / bin /.
FastDFS service script to set the bin directory is / usr / local / bin, but the actual command installed in / usr / bin /. We need to create / usr / bin to / usr / local / bin soft link

ln -s /usr/bin/fdfs_trackerd /usr/local/bin
ln -s /usr/bin/fdfs_storaged /usr/local/bin
ln -s /usr/bin/stop.sh /usr/local/bin
ln -s /usr/bin/restart.sh /usr/local/bin

3. Configure FastDFS tracker (Tracker)
into the / etc / fdfs, sample copy FastDFS tracker profile tracker.conf.sample, and rename tracker.conf

 cd /etc/fdfs
 cp tracker.conf.sample tracker.conf
 vim tracker.conf

Edit tracker.conf, the following need to be modified, the other default.

# Tracker 数据和日志目录地址(根目录必须存在,子目录会自动创建)
base_path=/home/fastdfs/tracker
# HTTP 服务端口
http.server_port=80

Create a tracker base data directory, the corresponding directory base_path

mkdir -p /home/fastdfs/tracker

Start Tracker

# service fdfs_trackerd start   
# systemctl start fdfs_trackerd

netstat -unltp|grep fdfs

FastDFS stand-alone building
shut down

service fdfs_trackerd stop

4. FastDFS storage configuration (the Storage)
into the / etc / fdfs directory

# cd /etc/fdfs
# cp storage.conf.sample storage.conf
# vim storage.conf

Edit storage.conf

# Storage 数据和日志目录地址(根目录必须存在,子目录会自动生成)
base_path=/home/fastdfs/storage
# 如果不配置 store_path0,那它就和 base_path 对应的路径一样,此处直接注释掉。
#store_path0=/home/fastdfs/file
# 有多个 tracker server 时,每个 tracker server 写一行
tracker_server=192.168.244.8:22122
# 访问端口
http.server_port=80

Creating Storage basic data directory, the corresponding directory base_path

# mkdir -p /home/fastdfs/storage

Start Storage

# service fdfs_storaged 
#查看状态
# netstat -unltp|grep fdfs
#关闭
# service fdfs_storaged stop

FastDFS stand-alone building
See if Storage and Tracker in communication
/etc/fdfs/storage.conf / usr / bin / fdfs_monitor
FastDFS stand-alone building
5. test file upload
client configuration file to modify Tracker server 

# cd /etc/fdfs
# cp client.conf.sample client.conf
# vim client.conf

Configuration can be modified as follows, other default.

# Client 的数据和日志目录
base_path=/home/fastdfs/client
# Tracker端口
tracker_server=192.168.244.8:22122
#tracker服务器的端口
http.tracker_server_port=8081 

Upload Test

# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf  xxx.jpg

FastDFS stand-alone building
FastDFS stand-alone building

Install nginx

1. Install the required environment nginx
PCRE pcre-devel installed
# yum install -y pcre pcre-devel
zlib mounting
# yum install -y zlib zlib-devel
OpenSSL Installation
# yum install -y openssl openssl-devel
2. Installation nginx

# tar -zxvf nginx-1.12.1.tar.gz
# cd nginx-1.12.1

# ./configure

# make
# make install

#启动
# cd /usr/local/nginx/sbin/
# ./nginx

# ./nginx -s stop
# ./nginx -s quit
# ./nginx -s reload

/usr/local/nginx/sbin/nginx -V

FastDFS stand-alone building
Modify nginx.conf

# vim /usr/local/nginx/conf/nginx.conf

#添加如下行,将 /group1/M00 映射到 /home/fastdfs/storage/data
location /group1/M00 {
alias /home/fastdfs/storage/data;
}

Restart

# /usr/local/nginx/sbin/nginx -s reload

FastDFS stand-alone building
Before uploading browser to access the file successfully.
http://192.168.244.8/group1/M00/00/00/wKj0CF0cTBKAYwBiAABdrZgsqUU227.jpg

The module 3.Nginx fastdfs
decompression fastdfs-nginx-module

# 解压
# unzip 5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip
# 重命名
# mv fastdfs-nginx-module-5e5f3566bbfa57418b5506aaefbe107a42c9fcb1 fastdfs-nginx-module

Nginx configuration

# 先停掉nginx服务
# /usr/local/nginx/sbin/nginx -s stop
进入nginx解压包目录
# cd /usr/local/src/nginx-1.12.1/

# 添加模块
# ./configure --add-module=../fastdfs-nginx-module/src
重新编译、安装
# make && make install

#查看Nginx的版本模块
# /usr/local/nginx/sbin/nginx -V

FastDFS stand-alone building

Copy Profile fastdfs-nginx-module of the source / etc / fdfs directory, and modify

# cd /usr/local/src/fastdfs-nginx-module/src
# cp mod_fastdfs.conf /etc/fdfs/

Modify the configurations other default

# 连接超时时间
connect_timeout=10
# Tracker Server
tracker_server=192.168.244.8:22122
# 如果文件ID的uri中包含/group**,则要设置为true
url_have_group_name = true
# Storage 配置的store_path0路径,必须和storage.conf中的一致,统一注释掉
#store_path0= /home/yuqing/fastdfs

Copy FastDFS part of the configuration file to the / etc / fdfs directory

# cd /usr/local/src/fastdfs-5.05/conf/
# cp anti-steal.jpg http.conf mime.types /etc/fdfs/

Configuration nginx, modify nginx.conf
added fastdfs-nginx module at port 80

location ~/group0/M00 {
ngx_fastdfs_module;
}

FastDFS stand-alone building
Note:
  the listen port 80 to the value of /etc/fdfs/storage.conf http.server_port = 80 (the front into 80), respectively.
Start nginx

# /usr/local/nginx/sbin/nginx

FastDFS stand-alone building
Re-upload a picture, you can open the browser, that the installation was successful.

Guess you like

Origin blog.51cto.com/6324115/2474288