当前位置:网站首页>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.33
In 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.gz
FastDFS 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/nologin
then , Installation and compilation environment :
yum -y install gcc gcc+ gcc-c++ openssl openssl-devel pcre pcre-deve
install libfastcommon, Execute the following commands in order :
tar -zxVf libfastcommon-1.0.35.tar.gz
cd libfastcommon-1.0.35
./make.sh
./make.sh install
When 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.so
Execute the following commands in order , install FastDFS:
tar -zxv fastdfs-5.10.tar.gz
cd fastdfs-5.10
./make.sh
./make.sh install
After 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/tracker
Execute the following commands in order , edit tracker.conf To configure :
cd /etc/fdfs
cp tracker.conf.sample tracker.conf
vi /etc/fdfs/tracker.conf
Edit 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=8080
Save and exit , Then start... With the following command Tracker Server:
service fdfs trackerd start
Use the following command to view Tracker Server Listening port :
netstat -unltplgrep fdfs
Storage 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/storage1
Execute the following commands in order , Edit the storage node configuration :
cd /etc/fdfs
cp storage.conf.sample storage.conf
vi storage.conf
Edit 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:22122
After saving the edits , Start the storage node with the following command :
service fdfs_storaged start
Use the following command to check the running status of the service :
/usr/bin/fdfs monitor /etc/fdfs/storage.conf
Upload 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.conf
Modify 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.png
If the upload is successful , Then the file information shown below is returned :
group1/M00/00/00/wKgBGFk3kUqACu9JAAGmMprynZs674.png
The 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 !
边栏推荐
- Domestic relatively good OJ platform [easy to understand]
- 宝宝巴士创业板IPO被终止:曾拟募资18亿 唐光宇控制47%股权
- IP地址转换地址段
- 871. Minimum refueling times
- 人生的开始
- executescalar mysql_ ExecuteScalar()
- Linux Installation PostgreSQL + Patroni cluster problem
- The difference of message mechanism between MFC and QT
- 什么是敏捷开发流程
- 【Leetcode】14. 最长公共前缀
猜你喜欢
Qstype implementation of self drawing interface project practice (II)
Error when uploading code to remote warehouse: remote origin already exists
关于我
[leetcode] 14. Préfixe public le plus long
伟立控股港交所上市:市值5亿港元 为湖北贡献一个IPO
剑指 Offer 25. 合并两个排序的链表
Eth data set download and related problems
TCP congestion control details | 2 background
Changwan group rushed to Hong Kong stocks: the annual revenue was 289million, and Liu Hui had 53.46% voting rights
The computer comes with software to make the background color of the picture transparent (matting white background)
随机推荐
Nexus Introduction and Xiaobai use idea Packaging and Upload to Nexus 3 private service detailed tutoriel
Qwebengineview crash and alternatives
Weili holdings listed on the Hong Kong Stock Exchange: with a market value of HK $500million, it contributed an IPO to Hubei
远程办公对我们的各方面影响心得 | 社区征文
Seven charts, learn to do valuable business analysis
海思Hi3798MV100机顶盒芯片介绍[通俗易懂]
简单介绍BASE64Encoder的使用
Learning Weekly - total issue 60 - 25th week of 2022
ThreadLocal
Tech talk activity preview | building intelligent visual products based on Amazon kVs
VScode知识点——常见报错
【Leetcode】13. 罗马数字转整数
Goodbye, shucang. Alibaba's data Lake construction strategy is really awesome!
一文看懂:数据指标体系的4大类型
13、Darknet YOLO3
绿竹生物冲刺港股:年期内亏损超5亿 泰格医药与北京亦庄是股东
Linux Installation PostgreSQL + Patroni cluster problem
Usage of sprintf() function in C language
linux安装postgresql + patroni 集群问题
简单线性规划问题