FastDFS Learning - Installation and Configuration

Keywords: github encoding socket

Download and Installation

Download and install libfast common

Introduction: Libfast common is an open source C-based library, which is a C-based library separated from the FastDFS project. This library is very simple and stable. Functions include: string, recorder, chain, hash, socket, ini file reader, base64 encoding/decoding, url encoding/decoding, fast timer, skiplist, object pool, etc. See the C header file for details.

//download
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz

tar -xvf V1.0.7.tar.gz//decompression
cd libfastcommon-1.0.7//Enter folder

//Compile and install
./make.sh
./make.sh install

//Creating Soft Links
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/libfdfsclient.so
ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so 

Download and install FastDFS

//download
wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz

tar -xvf V5.05.tar.gz //decompression
cd fastdfs-5.05   //Enter folder

//Compile and install
/make.sh
./make.sh install

To configure

After successful installation, the relevant configuration path of FastDFS is / etc/fdfs /, under which there are three. sample files, which are provided by fastDFS; tracker.conf.sample and storage.conf.sample are needed.

//tracker server tracing service configuration file
cp tracker.conf.sample tracker.conf 
//storage server storage service configuration file
cp storage.conf.sample storage.conf

Tracker configuration

vi tracker.conf

Key configuration parameters

# Whether the configuration file is not valid, false is valid
disabled=false

# Ports to provide services
port=22122

# Tracker Data and Log Directory Address
base_path=/home/fastdfs

# HTTP Service Port
http.server_port=80

After the configuration is completed:

//After configuring, you need to create the corresponding data and log directory folders, otherwise the startup will report an error.
mkidr -p /home/fastdfs

//Establishing Soft Links with Ln-S
ln -s /usr/bin/fdfs_trackerd /usr/local/bin
ln -s /usr/bin/stop.sh /usr/local/bin
ln -s /usr/bin/restart.sh /usr/local/bin

//Start up service
service fdfs_trackerd start

//View monitor
netstat -unltp|grep fdfs

Seeing the information on port 22122 represents successful startup

And the following file structure is generated under the specified path {base_path}

${base_path}
|__data
| |__storage_groups.dat: Storing grouping information
| |__storage_servers.dat: Storage server list
|__logs
| |__trackerd.log: tracker server log file

Storage configuration

vi storage.conf

Key configuration

# Whether the configuration file is not valid, false is valid
disabled=false

# Specify the group (volume) for this storage server
group_name=group1

# storage server service port
port=23000

# The interval between heartbeats in seconds (in this case, to actively send a heartbeat to tracker server)
heart_beat_interval=30

# Storage data and log directory address (root directory must exist, subdirectory will be generated automatically)
base_path=/home/data/fastdfs/storage

# storage server supports multiple paths when storing files. Here you configure the number of base paths to store files, usually with only one directory.
store_path_count=1

# Configure store_path_count paths one by one, with index numbers based on 0.
# If store_path0 is not configured, it will be the same path as base_path.
store_path0=/home/fastdfs/storage

# FastDFS uses two levels of directory to store files. Here configure the number of directories where files are stored. 
# If this parameter is only N (e.g. 256), then the storage server automatically creates N* N subdirectories of the stored files under store_path when it first runs.
subdir_count_per_path=256

# The list of tracker_server will actively connect to tracker_server
# When there are multiple tracker servers, each tracker server writes a line
tracker_server=192.168.1.190:22122

# Time period allowed for system synchronization (default is full day). It is usually set to avoid some problems caused by peak synchronization.
sync_start_time=00:00
sync_end_time=23:59

After configuring

//Create store_path0 specified address file, otherwise start error reporting
mkidr -p /home/fastdfs/storage

//Establishing Soft Links with Ln-S
ln -s /usr/bin/fdfs_storaged /usr/local/bin

//Start up service
service fdfs_storaged start

//View monitor
netstat -unltp|grep fdfs

See that fdfs_storage corresponds to port 23000 for successful startup

Check if Storage and Tracker are communicating

/usr/bin/fdfs_monitor /etc/fdfs/storage.conf

Posted by mikeyinsane on Tue, 08 Oct 2019 23:22:07 -0700