FastDFS cluster deployment

FastDFS cluster deployment
official website https://github.com/happyfish100
FastDFS is an open source, high-performance distributed file system (DFS). The main functions: file storage, file synchronization and file access, as well as high-capacity and load balancing. Mainly to solve the problem of mass data storage, especially for small and medium file (recommended range: 4KB <file_size <500MB) as the carrier online services.

FastDFS system has three roles: Tracking server (Tracker Server), Storage Server (Storage Server) and client (Clinet).

Tracker Server: tracking server, to do major role in regulating work, play and balanced; responsible for managing all of the storage server and the group, each storage after starting connects Tracker, inform the group they belong to other information, and to maintain a periodic heartbeat.

Storage Server: storage server. Providing primary and backup server capacity; in group units in each group can have more than one storage server, data redundancy.

Client: The client, upload and download data server, which is our own projects in server deployment.

Installation package
FastDFS_v5.08.tar.gz: FastDFS Source
libfastcommon-master.zip: basic environmental
fastdfs-nginx-module.zip:storage node http service module nginx
nginx-1.tar.gz: Nginx installation package
ngx_cache_purge-2.3.tar .gz: Clear image cache Nginx modules (clustered environment will be used)
to download libfastcommon, FastDFS, fastdfs-nginx- module, nginx, nginx image cache module
wget https://github.com/happyfish100/libfastcommon/archive/master.zip
wget https://github.com/happyfish100/fastdfs/archive/master.zip
wget http://nginx.org/download/nginx-1.15.12.tar.gz
wget http://labs.frickle.com/files /ngx_cache_purge-2.3.tar.gz
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip

1. Install dependencies
yum install gcc-c ++ pcre pcre -devel zlib zlib-devel openssl openssl-devel -y

2.安装libfastcommon
tar xf V1.0.7.tar.gz
cd libfastcommon-1.0.7/
./make.sh
./make.sh install

3.安装FastDFS
tar -zxvf V5.05.tar.gz
cd fastdfs-5.05
./make.sh
./make.sh install

After the installation is complete, you can see / etc / generate three files fdfs catalog:

5, configuration tracker node

mkdir / data / fastdfs -p // create tracker data and log file storage directory

cd / etc / FDF /

mv tracker.conf.sample tracker.conf

vim tracker.conf

base_path = / data / fastdfs // set the tracker data files and log directory
http.server_port = 6666 // Set http port number, the default is 8080

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

service fdfs_trackerd start // node startup tracker

After a successful start, in / data / fastdfs directory data and logs created under the two directories

Sixth, the storage node configuration

mkdir / data / fastdfs-storage // create data files and log storage directory

cd / etc / FDF /

mv storage.conf.sample storage.conf

vim storage.conf

group_name = group1 // the name of the group, may be modified according to the actual situation
base_path = / data / fastdfs-storage // set the storage directory file and log data
store_path_count = 1 // number of storage paths, and the need to match the number of store_path
store_path0 = / data / fastdfs-storage // store path
tracker_server = 192.168.19.6: IP 22122 // tracker server and port
http.server_port = 8888 // http port provided

ln -s /usr/bin/fdfs_storaged /usr/local/bin

service fdfs_storaged start // Start storage, start automatically creates multi-level storage directory according to the settings configuration file

View Log:

cat /data/fastdfs-storage/logs/storaged.log

After confirming a successful run fdfs_monitor see if the storage server has been registered to the tracker

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

See 192.168.19.6 (localhost.localdomain) ACTIVE to confirm storage operating normally.
Seven, to the storage configuration and install nginx

tar -zxvf fastdfs-nginx-module_v1.16.tar.gz -C /usr/local/

cd /usr/local/fastdfs-nginx-module/

vim src/config


FIG i.e., modified as follows :( removed "local")

Copy mod_fastdfs.conf in fastdfs-nginx-module / src to / etc / fdfs / under,

cp src / mod_fastdfs.conf / etc / FDF /

Modify / etc / fdfs / under mod_fastdfs.conf content:

vim /etc/fdfs/mod_fastdfs.conf

base_path = / data / fastdfs-storage // save the log directory
tracker_server = 192.168.19.6: IP 22122 // tracker server and port
url_have_group_name = true // whether there is group name in the file url
store_path0 = / data / fastdfs-storage // storage path
group_count = 1 // set the number of groups, one time only
adding the following to the end of the file:
[named group1]
GROUP_NAME = named group1
storage_server_port = 23000
store_path_count = 1
store_path0 = / Data / storage-FastDFS

M00 to establish a symbolic link to a storage directory

ln -s /data/fastdfs-storage/data /data/fastdfs-storage/data/M00

Copy the relevant files to the / etc under / fdfs catalog:

/usr/local/FastDFS/conf/mime.types cp / etc / FDF /

/usr/local/FastDFS/conf/http.conf cp / etc / FDF /

/usr/local/FastDFS/conf/anti-steal.jpg cp / etc / FDF /

To the storage installation nginx

mkdir /data/nginx

tar -zxvf nginx-1.12.0.tar.gz -C /opt/

cd /opt/nginx-1.12.0/

./configure --prefix=/data/nginx/ --add-module=/usr/local/fastdfs-nginx-module/src/

make

make install

Modify the file nginx.conf

vim /data/nginx/conf/nginx.conf

listen 9999;

    location ~/group[1-3]/M00 {
        root /data/fastdfs-storage/data;
        ngx_fastdfs_module;
    }

Start nginx:

/data/nginx/sbin/nginx

Eight tracker to install and configure nginx

mkdir /data/nginx2

cd /opt/nginx-1.12.0/

./configure --prefix=/data/nginx2/ --add-module=/usr/local/fastdfs-nginx-module/src/

make

make install

Nginx.conf modify the file:

vim /data/nginx2/conf/nginx.conf

upstream fdfs_group1 {
server 127.0.0.1:9999;
}

location /group1/M00 {
proxy_pass http://fdfs_group1;
}

Start nginx:

/data/nginx2/sbin/nginx

Nine, the client configuration file, test

cd / etc / FDF /

mv client.conf.sample client.conf

vim client.conf

base_path = / data / fastdfs-storage // log storage path
tracker_server = 192.168.19.6: 22122 // tracker server IP and port
http.tracker_server_port = 6666 // tracker http port number of the server, and must be provided in association with the front tracker

Test file upload:

/ Usr / bin / fdfs_upload_file /etc/fdfs/client.conf /data/Snipaste_2019-01-24_09-11-23.png

You can see the file upload stored by the figure path: group1 / M00 / 00/00 / wKgTBlxJESWAJocIAAz71mFDjBw797.png

By nginx visit:

Guess you like

Origin www.cnblogs.com/sunshinea121/p/10929917.html