Under Linux use FastDFS

This tutorial All operations were carried out under CentOS 6.x environment.

The required documents before class profile, and upload it to / usr / local / leyou catalog:

1.1 Single node FastDFS

The entire installation process is very complex, error prone, it is recommended to back up several times.

Here we do not intend to install multiple virtual machines, and therefore would tracker and storage are installed together.

1.1.1 Install gcc

GCC used to compile and run C language code, use the yum command to install:

yum -y install gcc

Will be used later unzip command (unzip), so here you can use yum to unzip it also installed

yum install -y unzip zip

1.1.2. Installation libevent

yum -y install libevent

1.1.3 Install libfastcommon-master

解压刚刚上传的libfastcommon-master.zip
unzip libfastcommon-master.zip

进入解压完成的目录
cd libfastcommon-master

编译并且安装:
./make.sh 
./make.sh install

1.1.4. Installation fastdfs

tar -zxvf FastDFS_v5.08.tar.gz

cd FastDFS

./make.sh 

./make.sh install

If the installation is successful, you will see under /etc/init.d/ see the script file provided by:

ll /etc/init.d/ | grep fdfs

  • fdfs_trackerd It is a startup script tracker

  • fdfs_storaged A storage startup script

You can see the default configuration file template in the / etc / fdfs / directory:

ll /etc/fdfs/

  • tarcker.conf.sample The tracker is a profile template

  • storage.conf.sample A storage configuration file template

  • client.conf.sample Is the client's profile template

1.1.5. Configuration and start the tracker service

FastDFS the tracker and storage during the installation process just in, have been installed, so the way we install these two roles are the same. The difference is that both require different profiles.

We want to start tracker, just saw on the amendment tarcker.conf, and start fdfs_trackerdscript.

1) First, copy the template file

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

2) modify the configuration files after copying:

vi /etc/fdfs/tracker.conf 

# Modified as follows:

base_path=/leyou/tracker                 # 存储日志和数据的根目录

3) new catalog:

mkdir -p /leyou/tracker

Note: turn off the firewall:

chkconfig iptables off
# 或者
systemctl stop firewalld

Check Status

service firewalled status

4) Start and stop

Start the tracker: /etc/init.d/fdfs_trackerd start

Stop the tracker: /etc/init.d/fdfs_trackerd stop

However, the installation process, fdfs has been set up as a system service, familiar way we can use the service to start:

service fdfs_trackerd start # 启动fdfs_trackerd服务,停止用stop

Check that FastDFS Tracker Server started successfully:

ps -ef | grep fdfs_trackerd

Setting tracker service boot:

chkconfig fdfs_trackerd on

1.1.6. Configure and start storage service

1) First, copy the template file

cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf

2) modify the configuration files after copying:

vim /etc/fdfs/storage.conf

# Modified as follows:

base_path=/leyou/storage                 # 数据和日志文件存储根目录 

store_path0=/leyou/storage           # 第一个存储目录 

tracker_server=192.168.56.101:22122       #  tracker服务器IP和端口 

3) new catalog:

mkdir -p /leyou/storage

Note turn off the firewall: chkconfig iptables off

 

4) Start and stop

Start storage server:/etc/init.d/fdfs_storaged start

Stop storage server:/etc/init.d/fdfs_storaged stop

Recommended Use:

service fdfs_storaged start  # 启动fdfs_storaged服务,停止用stop

Set storage service boot:

chkconfig fdfs_storaged on

ps -ef | grep FDF

2. Use nginx access FastDFS

2.1. Why do I need to access with Nginx?

FastDFS by Tracker server, the files in the Storage server storage, but the same set of storage between servers need to enter the file copy, the problem of synchronization delay.

Assume Tracker to upload files to the server 192.168.4.125, after successful upload the file ID has been returned to the client. At this point FastDFS storage cluster mechanism will synchronize the file to the same set of storage 192.168.4.126, if the file has not been completed copy of the client if the file ID to take files on 192.168.4.126, will be unable to access the file mistake.

The fastdfs-nginx-module can redirect the connection to the source file server file upload documents to take to avoid the file copy client due to the delay caused by unreachable errors

 

2.2. Installing fastdfs-nginx-module

2.2.1. Unpack

tar -zxvf fastdfs-nginx-module_v1.16.tar.gz

2.2.2. Modify config

1) into the src directory

cd fastdfs-nginx-module/src/

2) Edit config

vim config

The bottom line using the following command:

:%s+/usr/local/+/usr/+g

All / usr / local Replace / usr, this is the correct directory:

2.2.3. Configuring nginx configuration files associated with FastDFS

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

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

vi /etc/fdfs/mod_fastdfs.conf

Modify the following configurations:

connect_timeout=10                       # 客户端访问文件连接超时时长(单位:秒)

tracker_server=192.168.56.101:22122    # tracker服务IP和端口

url_have_group_name=true                # 访问链接前缀加上组名

store_path0=/leyou/storage            # 文件存储路径

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

cd /usr/local/leyou/FastDFS/conf/
cp http.conf mime.types /etc/fdfs/

 

Published 215 original articles · won praise 37 · views 80000 +

Guess you like

Origin blog.csdn.net/MirabelleZWH/article/details/103608008