当前位置:网站首页>Microservice architecture practice: Construction of highly available distributed file system fastdfs architecture
Microservice architecture practice: Construction of highly available distributed file system fastdfs architecture
2022-07-02 17:22:00 【Jue seconds of writing code】
The construction of high availability distributed file system
Traditional stand-alone version Web Applied document management , Such as uploading and using pictures and video files , Most of the files are stored locally on the server , However, this management method cannot be applied to microservice applications . One side , Microservice applications are published in a distributed environment , You can deploy multiple copies anytime, anywhere , So its media files must be stored in a unified place . On the other hand , Build an independent and efficient file system , Also highly available 、 An organic part of high-performance application platform .
If we rent cloud services , You can use the distributed file system provided by the cloud service provider , for example , Alibaba cloud or Tencent cloud object storage OSs.
below , In order to deepen readers' understanding of distributed file system , We use open source FastDFS Build a highly available distributed file system .
FastDFS framework
FastDFS It's a lightweight distributed file system , Use FastDFS It can build a highly available and sustainable distributed file system .
FastDFS By tracker (Tracker) And storage nodes (Storage) Two parts . The tracker is used to schedule requests from clients , And record the information of the storage server . The storage node is used to store files and their attributes , At the same time, file synchronization is carried out . The storage of files also uses grouping ( Or sub volume ) The way to organize . Building more than two trackers can form a highly available distributed file system , Pictured 14-1 Shown .

Based on graph 14-1 The architecture design shown , We will use four servers to build a highly available distributed file system , The code is as follows .
Tracker Server1: 10.10.10.22
Tracker Server2:10.10.10.32
Storagel:10.10.10.23
Storage2:10.10.10.33In this architecture design , Adding storage nodes can improve and expand file access performance . After installing the distributed file system , You can use Nginx by Web Build a load balancing service for file access on the client side .
This chapter will use the installation package shown below , Readers can download from the Internet .
libfastcommon-1.0.35.tar.gz
fastdfs-5.10.tar.gz
pcre-8.40.tar.gz
nginx-1.10.3.tar.gzFastDFS Installation
The following installation process is completed on all four servers . Suppose you put all the downloaded installation packages in the directory /opt in .
First , establish FastDFS and Nginx user :
useradd fastdfs -M -s/sbin/nologinuseradd nginx One M -s /sbin/nologinthen , Installation and compilation environment :
yum -y install gcc gcc+ gcc-c++ openssl openssl-devel pcre pcre-deveinstall libfastcommon, Execute the following commands in order :
tar -zxVf libfastcommon-1.0.35.tar.gz
cd libfastcommon-1.0.35
./make.sh
./make.sh installWhen it's done , Create the soft links shown below , So that the installer can find the relevant library files :
ln -sv /usr/include/fastcommon /usr/local/include/fastcommon
ln -sv /usr/include/fastdfs /usr/local/include/fastdfs
ln -sv /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.soExecute the following commands in order , install FastDFS:
tar -zxv fastdfs-5.10.tar.gz
cd fastdfs-5.10
./make.sh
./make.sh installAfter installation, the success flag will be output , Next, configure each service .
Tracking server configuration
stay Tracker Server On the machine , Create a data storage directory :
mkdir -p /data/fastdfs/trackerExecute the following commands in order , edit tracker.conf To configure :
cd /etc/fdfs
cp tracker.conf.sample tracker.conf
vi /etc/fdfs/tracker.confEdit the following configurations in the configuration file :
# binding IP Address , If it is empty , It means using the local IP Address bind addr=
# port
port=22122# Connection timeout
connect timeout=30# Log data path
base path=/data/fastdfs/tracker# Select... When uploading files group Methods
#0: polling ,1: Specified group ,2: Select the maximum remaining space store lookup=2
# If the above configuration is 1, Then the group name must be specified here store group-group2
# Select... When uploading files server Methods
#0: polling ,1: Press IP Address sorting ,2: Sort by weight store server=0
#storage Space reserved on
reserved storage space =10%http.server port=8080Save and exit , Then start... With the following command Tracker Server:
service fdfs trackerd startUse the following command to view Tracker Server Listening port :
netstat -unltplgrep fdfsStorage node configuration
stay Storage Server , Create a data storage directory as shown below :
mkdir -p/data/fdfs storage/base
mkdir -p /data/fdfs storage/storage0
mkdir -p /data/fdfs_storage/storage1Execute the following commands in order , Edit the storage node configuration :
cd /etc/fdfs
cp storage.conf.sample storage.conf
vi storage.confEdit the contents with the following commands :
#storage server Group name group name=group1
# binding IP Address
bind addr=
#storage server The port of port=23000
# Connection timeout
connect timeout=30# Log data path
base path=/data/fdfs storage/base#storage path The number of
store pathcount=2
store path0=/data/fdfs storage/storage0store pathl=/data/fdfs storage/storagel# Tracking server
tracker server=10.10.10.22:22122tracker server=10.10.10.32:22122After saving the edits , Start the storage node with the following command :
service fdfs_storaged startUse the following command to check the running status of the service :
/usr/bin/fdfs monitor /etc/fdfs/storage.confUpload file test
Now back to Tracker Server On the machine ( Such as IP The address is 10.10.10.22), Use the following methods to upload files .
Execute the following commands in order , Edit client configuration :
cd /etc/fdfs
cp client.conf.sample client.conf
vi /etc/fdfs/client.confModify the following items :
base path=/data/fastdfs/tracker #Tracker The file path on the server
tracker server=10.10.10.22:22122 #Tracker Server's IP Address and port number
http.tracker_server port=8080 # Tracker On the server HTTP Port number , It has to be with Tracker Of
# Same settings If be in, /opt There is a picture file named 1.png, You can use the following command to upload files :
/usr/bin/fdfs upload file /etc/fdfs/client.conf /opt/1.pngIf the upload is successful , Then the file information shown below is returned :
group1/M00/00/00/wKgBGFk3kUqACu9JAAGmMprynZs674.pngThe content of this article is the actual combat of microservice architecture : The construction of high availability distributed file system ,FastDFS Architecture and installation 、 Tracking server configuration 、 Storage node configuration 、 Upload file test
- The next article will explain the actual combat of microservice architecture :Nginx Installation and load balancing configuration of 、 Boot up ;
- Friends who think the article is good can forward this article and pay attention to Xiaobian ;
- Thank you for your support !
边栏推荐
- Youzan won the "top 50 Chinese enterprise cloud technology service providers" together with Tencent cloud and Alibaba cloud [easy to understand]
- 一文看懂:数据指标体系的4大类型
- 13、Darknet YOLO3
- Amazon cloud technology community builder application window opens
- How to transfer business data with BorgWarner through EDI?
- The difference of message mechanism between MFC and QT
- Flutter: 动作反馈
- Blog theme "text" summer fresh Special Edition
- 详细介绍scrollIntoView()方法属性
- Un an à dix ans
猜你喜欢

智能垃圾桶(五)——点亮OLED

linux安装postgresql + patroni 集群问题

Listing of chaozhuo Aviation Technology Co., Ltd.: raising 900million yuan, with a market value of more than 6billion yuan, becoming the first science and technology innovation board enterprise in Xia

What if the default browser cannot be set?

ThreadLocal
![[fluent] dart data type map type (create map set | initialize map set | traverse map set)](/img/02/75d21470ea0ae4cd3d17696a93d1ca.jpg)
[fluent] dart data type map type (create map set | initialize map set | traverse map set)

Qwebengineview crash and alternatives

A case study of college entrance examination prediction based on multivariate time series

Understand one article: four types of data index system

871. Minimum refueling times
随机推荐
福元医药上交所上市:市值105亿 胡柏藩身价超40亿
Configure MySQL under Linux to authorize a user to access remotely, which is not restricted by IP
[fluent] dart data type map type (create map set | initialize map set | traverse map set)
How to transfer business data with BorgWarner through EDI?
TCP拥塞控制详解 | 2. 背景
【征文活动】亲爱的开发者,RT-Thread社区喊你投稿啦
Interpretation of key parameters in MOSFET device manual
伟立控股港交所上市:市值5亿港元 为湖北贡献一个IPO
简单介绍BASE64Encoder的使用
Nexus簡介及小白使用IDEA打包上傳到Nexus3私服詳細教程
人生的开始
Introduction to nexus and detailed tutorial of Xiaobai using idea to package and upload to nexus3 private server
Nexus简介及小白使用IDEA打包上传到Nexus3私服详细教程
Timing / counter of 32 and 51 single chip microcomputer
智能垃圾桶(五)——点亮OLED
Usage of sprintf() function in C language
[web technology] 1233 seconds understand web component
如何与博格华纳BorgWarner通过EDI传输业务数据?
【Leetcode】13. Roman numeral to integer
Chmod command principle and usage details [easy to understand]