Linux installation file storage FastDFS construction process

Introduction to FastDFS

FastDFS Architecture

FastDFS is an open source lightweight distributed file system. It manages files. Its functions include: file storage, file synchronization, file access (file upload, file download), etc. It solves the problems of large-capacity storage and load balancing. It is especially suitable for online services with files as the carrier, such as photo album websites, video websites and so on.

FastDFS is tailor-made for the Internet, fully considers redundant backup, load balancing, linear expansion and other mechanisms, and pays attention to high availability, high performance and other indicators. Using FastDFS is easy to build a set of high-performance file server clusters to provide file upload and download and other services.

The FastDFS architecture includes Tracker server and Storage server. The client requests the Tracker server to upload and download files, and the Tracker server schedules and finally the Storage server completes the file upload and download.

The function of Tracker server is load balancing and scheduling. When files are uploaded through Tracker server, Storage server can be found to provide file upload service according to some policies. A tracker can be called a tracking server or a scheduling server. The role of the Storage server is to store files. The files uploaded by the client are finally stored on the Storage server. The Storage server does not implement its own file system but uses the file system of the operating system to manage files. Storage can be referred to as a storage server.

 FastDFS build

pull image

docker pull morunchang/fastdfs

 run tracker 

docker run -d --name tracker --net=host morunchang/fastdfs sh tracker.sh

 run storage

使用的网络模式是–net=host, 192.168.216.130是宿主机的IP
group1是组名,即storage的组
如果想要增加新的storage服务器,再次运行该命令,注意更换 新组名

docker run -d --name storage --net=host -e TRACKER_IP=192.168.216.130:22122 -e GROUP_NAME=group1 morunchang/fastdfs sh storage.sh

Configure Nginx 

Nginx here mainly provides support for FastDFS image access. Nginx has been integrated in the Docker container. We need to modify the configuration of nginx, enter the storage container, and modify nginx.conf

docker exec -it storage  /bin/bash

after entering

vi /etc/nginx/conf/nginx.conf

 Add the following

location ~ /M00 {
     root /data/fast_data/data;
     ngx_fastdfs_module;
}

 Disable caching:

add_header Cache-Control no-store;

exit container

exit

Restart the storage container

docker restart storage

View start container docker ps

```bash
9f2391f73d97 morunchang/fastdfs "sh storage.sh" 12 minutes ago Up 12 seconds storage
e22a3c7f95ea morunchang/fastdfs "sh tracker.sh" 13 minutes ago Up 13 minutes tracker

Turn on startup settings

docker update --restart=always tracker
docker update --restart=always storage

Here Linux build FastDFS has been completed

Guess you like

Origin blog.csdn.net/qq_55629923/article/details/129923813