FastDFS distributed file system installation

http://www.ahlinux.com/nginx/7033.html performance test address
 
1. Introduction to FastDFS distributed file system
FastDFS is an open source distributed file system. It manages files. Its functions include: file storage, file synchronization, file access (file upload, file download), etc., which solves the problem of mass 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.
The FastDFS server has two roles: tracker and storage node. The tracker mainly does scheduling work and plays the role of load balancing in access.
The storage node stores files and completes all the functions of file management: storage, synchronization and providing access interfaces. FastDFS also manages the meta data of files. The so-called meta data of a file is the relevant attributes of the file, which is represented by a key value pair, such as width=1024, where the key is width and the value is 1024. File meta data is a list of file attributes, which can contain multiple key-value pairs.
The structure of the FastDFS system is shown in the following figure:
 
2. Distributed file system installation and deployment:
1. Determine the installation location, set the tracker and storage log and data storage location:
1), create /usr/local/fastdfs directory to install fastdfs
2), create /usr/local/nginx directory to install nginx
2), create the /home/fastdfs/tracker directory tracker to use
3), create /home/fastdfs/storage directory to store storage exchange log files
2. Install libfastcommon-1.0.7:
1) Unzip V1.0.7.tar.gz, the first installation may prompt that some software is not installed, just install it once.
2) Enter the decompression directory and execute ./make.sh and ./make.sh install once. The execution command is as follows:
Execute ./make.sh If the above error occurs, install gcc
Execute ./make.sh again, and then execute ./make.sh install after completion, and the following result appears: the installation is successful
3) Note that the above installation path is in /usr/lib64, but the lib directory set by the FastDFS main program is /usr/local/lib, so you need to create a soft link as follows:
ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfscommon.so
ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfscommon.so
2. Install libevent()
3. Install FastDFS:
1), decompress fastdfs-5.05.tar.gz to /usr/local/fastdfs directory
2) Execute make.sh and make.sh to install fastdfs. After installation, tracker.conf, storage.conf, client.conf will be generated in the /etc/fdfs directory
3), configure tracker
# is this config file disabled
# false for enabled
# true for disabled
disabled=false
 
# bind an address of this host
# empty for bind all addresses of this host
bind_addr=192.168.2.111
 
# the tracker server port
port=22122
 
# connect timeout in seconds
# default value is 30s
connect_timeout=30
 
# network timeout in seconds
# default value is 30s
network_timeout=60
 
# the base path to store data and log files here is the directory created earlier
base_path=/home/fastdfs/tracker #Set tracker log file location
 
# max concurrent connections this server supported
max_connections=256
 
# accept thread count
# default value is 1
# since V4.07
accept_threads=1
 
# work thread count, should <= max_connections
# default value is 4
# since V2.00
work_threads=4
 
# the method of selecting group to upload files
# 0: round robin
# 1: specify group
# 2: load balance, select the max free space group to upload file
store_lookup=2
 
# which group to upload file
# when store_lookup set to 1, must set store_group to the group name
store_group=group1
 
# which storage server to upload file
# 0: round robin (default)
# 1: the first server order by ip address
# 2: the first server order by priority (the minimal)
store_server=0
. . . . . Others do not require configuration
 
4), configure storage.conf and tracker.conf to be similar, bind ip to modify port, configure tracker_server, configure storage location, etc., mainly configure the following information:
disabled=false
group_name=group1
bind_addr=192.168.2.111 #ip is the local ip address
port=23000
base_path=/home/fastdfs/storage #The file directory is used here to store log file information for the previously created directory
store_path0=/home/fastdfs #The data directory will be generated in this directory
tracker_server=192.168.2.111:22122 #tracker address can be more than one tracker_server address to start
5), configure client.conf, configure the following two items
base_path=/home/fastdfs/client
tracker_server=192.168.2.111:22122
6), start tracker and storage
Start the tracker:
Start storage:
Test whether the startup is successful and the following interface appears, that is, the startup is successful:
4. Configure FastDFS environment Linux support:
1), install fastdfs-nginx-module
 
tar -xvf fastdfs-nginx-module_v1.16.tar.gz
cd fastdfs-nginx-module/src
 
Modify the following configuration, my original here is
CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"
change to
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
This is very important, otherwise, an error will be reported when nginx is compiled. I see that many plug-ins that install nginx's fastdfs on the Internet report errors. This is the reason, not the version mismatch.
 
cp mod_fastdfs.conf / etc / fdfs
 
Modify the configuration as follows:
group_name=group1
tracker_server=192.168.2.111:22122 #Can be multiple
store_path0=/home/fastdfs
base_path=/home/fastdfs/nginx # run data file
url_have_group_name = true
2), configure the soft connection of the file server
ln -s /home/fastdfs/data /home/fastdfs/data/M00 (the path where stoage stores data in the configuration file)
 
 
Also copy the following two files to /etc/fdfs/
cp /usr/local/fastdfs/http.conf / etc / fdfs /
cp /usr/local/fastdfs/mime.types / etc / fdfs /
3), install nginx, install nginx on each storage server:
Unzip the nginx installation package and enter:
Execute the command to install
./configure --prefix=/usr/local/nginx/ --add-module=/root/fastdfs-nginx-module/src --without-http_rewrite_module --without-http_gzip_module 模块解压位置
make
make install
 
cd /usr/local/nginx/conf
vi nginx.conf
 
Add the following:
location /group1/M00{
    root /home/fastdfs/data;
    ngx_fastdfs_module;
}
Note: There may be dependencies that are not installed during the installation process, and you can install more prompts
start up:
/usr/local/nginx/sbin/nginx
5. Multi-tracker, multi-storage, multi-group implementation, the following two nodes are used to achieve cluster configuration:
1), multi-tracker configuration
Multiple trackers are equal and independent of each other, and are implemented by configuring multiple tracker_servers in storage
2), over group configuration
A group is equivalent to grouping different groups with the same group_name. Each group can have multiple storage settings. The group_name value in the storage.conf configuration file is the same.
3) Implementation of multiple storage configurations in a group
When building storage, configure the storage.conf file to set the same group_name, then multiple storages belong to the same group
nginx configuration to access the storage location of this storage service
6. Use the configuration in the actual production environment:
Install nginx on each storage node to provide file access, then install a separate nginx server as the balancing and reverse proxy service, and configure different upstreams for each different group_name
3. Use of distributed file system (java):
Access downloads are implemented using Apache and nginx extensions,
The upload function is implemented through the FastDFS java client client
First install Fastdfs-java-client into the local warehouse, and add the following dependencies to the project:
 
 
4. Remarks (problems seen from some data during the installation process):
1. The nginx extension can solve the problem of data synchronization. If the file is not found at the specified address, it will be redirected to the source storage
2. Storage comes with its own web server function, but generally do not use extended Apache and nginx
5. Problems to be solved:
1. Use of web server in tracker
2. Use of web server in storage
 
 
 
 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326864162&siteId=291194637