Step 1 General configuration
Perform the following operations for all trace servers and storage servers
1. Dependencies required for compilation and installation:
yum install make cmake gcc gcc-c++
Copy the code
Install libfastCommon:
Zip to /usr/local/src. Unzip libfastcommon-master.zip to /usr/local/src Libfastcommon - master (3) compile, install the/make. Sh. / make. Sh install libfastcommon default installation to the/usr/lib64 / libfastcommon. So / usr/lib64 / libfdfsclient. So (4) because FastDFS main program set the lib directory is/usr/local/lib, So you need to create 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.soCopy the code
3. Install FastDFS
(1) Upload or download the FastDFS source package (fastdfs_v5.05.tar. gz) to the /usr/local/src directory. (2) Decompress the /usr/local/src/tar -zxvf fastdfs_v5.05.tar. gz CD /make. Sh./make. Sh install Install libfastcommon in the default installation mode. D /fdfs_storaged /etc/init.d/fdfs_tracker B. The configuration file is in (example configuration file) : The/etc/FDFS/client. Conf. Sample/etc/FDFS/storage. Conf. Sample/etc/FDFS/tracker. Conf., sample C, command tool in/usr/bin/directory: Fdfs_appender_test fDFs_appender_test1 fDFs_append_file fDFs_crc32...Copy the code
(4) The bin directory configured by the FastDFS service script is /usr/local/bin, but the actual command is installed in /usr/bin and can be accessed
/ user/bin directory using the following command to see FDFS related command: CD/usr/bin/ls | grep FDFSCopy the code
Step 2 Configure the FastDFS trace server
1, Copy the FastDFS tracker sample configuration file and rename it:
# cd /etc/fdfs/
# cp tracker.conf.sample tracker.conf
Copy the code
2. Edit the tracker configuration file:
# vi /etc/fdfs/tracker.conf
Copy the code
Modified as follows:
disabled=false
port=22122
base_path=/fastdfs/tracker
Copy the code
Create basic data directory (see base_path configuration) :
# mkdir -p /fastdfs/tracker
Copy the code
Step 3 Configure the FastDFS storage server
- The group name (group_name) in the configuration of the storage server and trace server must be the same
Copy the FastDFS storage sample configuration file and rename it:
# cd /etc/fdfs/
# cp storage.conf.sample storage.conf
# vi /etc/fdfs/storage.conf
Copy the code
The modified contents are as follows:
Disabled =false Port =23000 base_path=/fastdfs/storage # Basic storage location store_path0=/fastdfs/storage # File storage location Tracker_server =192.168.4.121:22122 HTTP. server_port=8888 ## Nginx configured port numberCopy the code
Create a base data directory (refer to base directory base_path configuration) :
# mkdir -p /fastdfs/storage
Copy the code
Set FastDFS tracker startup:
# vi /etc/rc.d/rc.local
Copy the code
Add the following:
/usr/bin/fdfs_trackerd /etc/ ffs.tracker. conf /usr/bin/fdfs_storaged /etc/ ffs.storage.conf (Storage server)Copy the code
Operating instructions
/usr/bin/fdfs_trackered /etc/ ffs/tracker. Run the following command to disable the FastDFS tracker: /usr/bin/stop.sh fdfs_tracker (or restart.sh) storage: Sh fdfs_storage 3. Check the cluster status on any storage(tracker also works) /usr/bin/fdfs_monitor /etc/ffs.storage.conf /usr/bin/fdfs_monitor /etc/ fdff/storage. conf delete group2 20.12.1.73Copy the code
File upload Test
- Conf is used to connect to the tracker server (springBoot usually requires a similar configuration)
1. Modify the client configuration file in the Tracker server:
# cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf # vi /etc/fdfs/client.conf base_path=/fastdfs/tracker Tracker_server = 192.168.4.121:22122Copy the code
2. Run the following command to upload the file:
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /Copy the code
Step 4 Install the Nginx module for each storage server
Objective: To solve the problem of file uploading synchronization delay.
Upload the fastdfs-nginx-module_v1.16.tar.gz file to /usr/local/src
2, decompression
# cd /usr/local/src/
# tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
Copy the code
3. Modify the fastdfs-nginx-module config file
# cd fastdfs-nginx-module/src # vi config CORE_INCS="$CORE_INCS /usr/local/include/fastdfs / usr/local/include/fastcommon/" is amended as: CORE_INCS = "$CORE_INCS/usr/include/fastdfs/usr/include/fastcommon/" (note: This path change is very important, otherwise nginx will generate errors when compiling.Copy the code
4, Upload the current stable version of Nginx(nginx-1.8.1) to /usr/local/src
5. Install the dependency packages required to compile Nginx
# yum install gcc gcc-c++ make automake autoconf libtool pcre* zlib openssl openssl-devel
Copy the code
Install Nginx (fastdfs-nginx-module)
/usr/local # tar -zxvf nginx-1.8.1.tar.gz # CD nginx-1.8.1 #./configure --add-module=/usr/local/fastdfs-nginx-module/src # make && make installCopy the code
7. Copy the fastdfs-nginx-module configuration file to /etc/fdfs and modify it
# cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
# vi /etc/fdfs/mod_fastdfs.conf
Copy the code
Modify the following configuration:
Connect_timeout =10 base_path=/ TMP tracker_server=192.168.25.100:22122 storage_server_port=23000 group_name=group1 url_have_group_name = true store_path0=/fastdfs/storageCopy the code
8. Copy the FastDFS configuration file to /etc/fdfs
# cd /usr/local/src/FastDFS/conf
# cp http.conf mime.types /etc/fdfs/
Copy the code
9. Create a soft link in /fastdfs/storage and link it to the directory where the data is stored
# ln -s /fastdfs/storage/data/ /fastdfs/storage/data/M00
Copy the code
10, configure Nginx start: / usr/local/Nginx/sbin/Nginx – c/usr/local/Nginx/conf/Nginx. Conf concise Nginx configuration sample:
user root; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 8888; server_name localhost; location ~/group([0-9])/M00 { #alias /fastdfs/storage/data; ngx_fastdfs_module; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }}}Copy the code