Centos7 build FastFDS ---- distributed file system server service

A, FastDFS Introduction

FastDFS Open Source Address: https://github.com/happyfish100
Reference: Distributed File System Design Principles FastDFS
Reference: FastDFS Distributed File System

1.1 Introduction

FastDFS is an open source, high-performance distributed file system (DFS). Its main features include: file storage, file synchronization and file access, as well as high-capacity and load balancing. Mainly to solve the problem of mass data storage, especially for small and medium file (recommended range: 4KB <file_size <500MB) as the carrier online services.
FastDFS system has three roles: Tracking server (Tracker Server), Storage Server (Storage Server) and client (Client).

1.2Tracker 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. Tracker rarely need to manage meta information, will all be stored in memory; additional meta-information is generated on the tracker reported by the information storage, the data itself does not need any persistence, such that the tracker is easy to expand, increasing the direct tracker the machine can be extended to serve as a tracker cluster, cluster in between each tracker is completely equal, all are accepted heartbeat tracker information stroage generate metadata information to provide literacy services.

1.3Storage Server

Storage server (abbreviated after storage) in a group (the volume, Volume or group) as the unit, the group comprises a plurality of storage machines, data backup for each other, an amount of storage space to the minimum storage group content subject, it is recommended that the group multiple storage as similar as possible to avoid wasting storage space.
In group as the unit can easily be stored in the application isolation, load balancing, customized copy number (storage server within the group number is the number of copies of the group), such data is stored to the different applications can be isolated from a different group application data, but can also be assigned according to characteristics of the application access to the different applications do load balancing group; disadvantage is limited by the capacity of the single group of storage capacity, while the broken when a machine group, group data recovery rely Mainland other machines, so that recovery time will be very long.

store relies on the storage of each group in the local file system, a plurality of data storage may be configured to store a directory, such as a magnetic disk 10, are mounted in / data / disk1- / data / disk10 , can these directories 10 configured for storage of data storage directory.

When writing a file storage request is received, based on configured rules (will be described later), to select one of the memory to store the file directory. In order to avoid an excessive number of files in a single directory, when storage is first started, it creates in each data storage directory in a subdirectory level 2, 256 per level, a total of 65,536 files, the new file will be written to hash manner which is routed to a subdirectory, and then stores the file data directly to the local file as a directory.

1.4Client

The client, server upload download data, that is, our own projects in server deployment.

 

 

 

 

 Two, FastDFS installation

 

资源包:
资源包百度云链接
1、解决Windows下安装FastDFS报 Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat 问题
2、解决Windows下安装FastDFS报 fdfs_client/sendfilemodule.c(53) fatal error C1189: #error : platfom not supported 问题,fdfs_client-py-1.2.6-jj 安装包已经修改过, 使用python setup.py install 安装

2.1安装gcc

yum install gcc

 

 

 2.2安装libfastcommon

1. 解压缩libfastcommon-master.zip
2. 进入到libfastcommon-master的目录中
3. 执行 ./make.sh
4. 执行 sudo ./make.sh install

 

 

2.3安装fastdfs

1. 解压缩fastdfs-master.zip
2. 进入到 fastdfs-master目录中
3. 执行 ./make.sh
4. 执行 sudo ./make.sh install

 

 

三、FastDFS配置

3.1配置跟踪服tracker

1. sudo cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
2. 在/home/python/目录中创建目录 fastdfs/tracker      
mkdir –p /home/python/fastdfs/tracker
3. 编辑/etc/fdfs/tracker.conf配置文件    sudo vim /etc/fdfs/tracker.conf
修改 base_path=/home/python/fastdfs/tracker

 

 

3.2配置存storage

1. sudo cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
2. 在/home/python/fastdfs/ 目录中创建目录 storage
    mkdir –p /home/python/fastdfs/storage
3. 编辑/etc/fdfs/storage.conf配置文件  sudo vim /etc/fdfs/storage.conf
修改内容:
base_path=/home/python/fastdfs/storage
store_path0=/home/python/fastdfs/storage
tracker_server=自己ubuntu虚拟机的ip地址:22122

 

 

3.3tracker 和 storage

# 启动跟踪器
sudo service fdfs_trackerd start
# 启动存储器 sudo service fdfs_storaged start

 

 

3.4测试是否安装成功

 

1. sudo cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
2. 编辑/etc/fdfs/client.conf配置文件  sudo vim /etc/fdfs/client.conf
修改内容:
base_path=/home/python/fastdfs/tracker
tracker_server=自己ubuntu虚拟机的ip地址:22122
3. 上传文件测试:
fdfs_upload_file /etc/fdfs/client.conf 要上传的图片文件 
如果返回类似group1/M00/00/00/rBIK6VcaP0aARXXvAAHrUgHEviQ394.jpg的文件id则说明文件上传成功

 

 

 

 

 

3.5设置开机自启动

 

vi /etc/rc.local

# 启动跟踪器
sudo service fdfs_trackerd start
# 启动存储器
sudo service fdfs_storaged start

 

Guess you like

Origin www.cnblogs.com/yunwangjun-python-520/p/11300778.html