Install FastDFS 5.05 on CentOS7

#!/bin/bash


# https://sourceforge.net/projects/fastdfs/files/  
# 》FastDFS Server Source Code 》FastDFS_v5.08.tar.gz #This
tutorial download: FastDFS_v5.05.tar.gz
#set env That is, the installation dependent software
#libfastcommon is officially provided by FastDFS, https://github.com/happyfish100/libfastcommon
#libfastcommon contains some basic libraries required for FastDFS to run.
#mkdir /home/FastDFSPackage && cd /home/FastDFSPackage
#Xftp upload ①FastDFS_v5.05.tar.gz, ②libfastcommonV1.0.7.tar.gz,
#③fastdfs-nginx-module_v1.16.tar.gz, ④nginx-1.10.3. tar.gz to /home/FastDFSPackage
yum -y install zlib pcre pcre-devel zlib-devel
yum -y install gcc gcc-c++ libstdc++-devel wget make
yum -y groupinstall 'Development Tools'
yum install -y unzip zip
yum install -y libevent
tar -zxvf libfastcommonV1.0.7.tar.gz
cd libfastcommon-1.0.7
./make.sh
./make.sh install
#Note: After libfastcommon is installed, it will automatically copy the library files to /usr/lib64 Next, since the FastDFS program references the /usr/lib directory, it is necessary to copy or reference the library files under /usr/lib64 to /usr/lib.
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






#tracker compile and install
tar -zxvf FastDFS_v5.05.tar.gz -C /usr/local
cd /usr/local/FastDFS
./make.sh
./make.sh install


[root@ localhost FastDFS]# ./make.sh install
mkdir -p /usr/bin
mkdir -p /etc/fdfs
cp -f fdfs_trackerd / usr / bin
if [! -f /etc/fdfs/tracker.conf.sample]; then cp -f ../conf/tracker.conf /etc/fdfs/tracker.conf.sample; fi
mkdir -p / usr / bin
mkdir -p / etc / fdfs
cp -f fdfs_storaged / usr / bin
if [! -f /etc/fdfs/storage.conf.sample]; then cp -f ../conf/storage.conf /etc/fdfs/storage.conf.sample; fi
mkdir -p / usr / bin
mkdir -p / etc / FDF
mkdir -p / usr / lib64
cp f fdfs_monitor fdfs_test fdfs_test1 fdfs_crc32 fdfs_upload_file fdfs_download_file fdfs_delete_file fdfs_file_info fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_upload_appender / usr / bin
IF [0 EQ 1]; then cp -f libfdfsclient.a / usr / lib64; fi
if [ 1 -eq 1 ]; then cp -f libfdfsclient.so /usr/lib64; fi
mkdir -p /usr/include/fastdfs
cp -f ../common/fdfs_define.h ../common/fdfs_global.h . ./common/mime_file_parser.h ../common/fdfs_http_shared.h ../tracker/tracker_types.h ../tracker/tracker_proto.h ../tracker/fdfs_shared_func.h ../storage/trunk_mgr/trunk_shared.h tracker_client .h storage_client.h storage_client1.h client_func.h client_global.h fdfs_client.h /usr/include/fastdfs
if [ ! -f /etc/fdfs/client.conf.sample ]; then cp -f ../conf/client .conf /etc/fdfs/client.conf.sample; fi
uses the default installation method. Script file description: The service script is in: cd /etc/init.d/ && ls |grep fdfs
/etc/init.d/fdfs_storaged
/etc/ The init.d/fdfs_trackerd
configuration file is in:
/etc/fdfs/client.conf.sample
/etc/fdfs/storage.conf.sample
/etc/fdfs/tracker.conf.sample
command-line tool in / usr / bin / directory: cd / usr / bin / && LS | grep FDFS
fdfs_appender_test
fdfs_appender_test1
fdfs_append_file
fdfs_crc32
fdfs_delete_file
fdfs_download_file
fdfs_file_info
fdfs_monitor
fdfs_storaged
fdfs_test
fdfs_test1
fdfs_trackerd
fdfs_upload_appender
fdfs_upload_file
FastDFS service script settings The bin directory is under /usr/local/bin/,
but we actually installed it under /usr/bin/.
So we need to modify the path in the FastDFS configuration file, that is, we need to modify two configuration files:
command: vim /etc/init.d/fdfs_storaged
for global replacement command: %s+/usr/local/bin+/usr/bin
command: vim /etc/init.d/fdfs_trackerd
for global replacement command: %s+/usr/local/bin+/usr/bin


#Installation is successful Copy the files under conf in the installation directory to /etc/fdfs/.
[root@localhost FastDFS]# ll /usr/local/FastDFS/conf/
total usage 84
-rw-r--r--. 1 8980 users 23981 Dec 2 2014 anti-steal.jpg
-rw-r--r --. 1 8980 users 1461 Dec 2 2014 client.conf
-rw-r--r--. 1 8980 users 858 Dec 2 2014 http.conf
-rw-r--r--. 1 8980 users 31172 12 Dec 2 2014 mime.types
-rw-r--r--. 1 8980 users 7829 Dec 2 2014 storage.conf
-rw-r--r--. 1 8980 users 105 Dec 2 2014 storage_ids.conf
-rw -r--r--. 1 8980 users 7102 Dec 2 2014 tracker.conf
[root@localhost fdfs]# ll /etc/fdfs
total usage 20
-rw-r--r--. 1 root root 1461 Apr 18 19:05 client.conf.sample
-rw-r--r--. 1 root root 7829 Apr 18 19:05 storage.conf.sample
-rw-r--r--. 1 root root 7102 4月  18 19:05 tracker.conf.sample
cp  /usr/local/FastDFS/conf/*  /etc/fdfs/
[root@localhost FastDFS]# ll  /etc/fdfs/
总用量 84
-rw-r--r--. 1 8980 users 23981 12月  2 2014 anti-steal.jpg
-rw-r--r--. 1 8980 users  1461 12月  2 2014 client.conf
-rw-r--r--. 1 8980 users   858 12月  2 2014 http.conf
-rw-r--r--. 1 8980 users 31172 12月  2 2014 mime.types
-rw-r--r--. 1 8980 users  7829 12月  2 2014 storage.conf
-rw-r--r--. 1 8980 users   105 12月  2 2014 storage_ids.conf
-rw-r--r--. 1 8980 users  7102 12月  2 2014 tracker.conf
[root@localhost fdfs]# ll  /etc/fdfs/
总用量 104
-rw-r--r--. 1 root root 23981 4月  18 19:19 anti-steal.jpg
-rw-r--r--. 1 root root 1461 Apr 18 19:19 client.conf
-rw-r--r--. 1 root root 1461 Apr 18 19:05 client.conf.sample
-rw -r--r--. 1 root root 858 Apr 18 19:19 http.conf
-rw-r--r--. 1 root root 31172 Apr 18 19:19 mime.types
-rw-r-- r--. 1 root root 7829 Apr 18 19:19 storage.conf
-rw-r--r--. 1 root root 7829 Apr 18 19:05 storage.conf.sample
-rw-r--r- -. 1 root root 105 Apr 18 19:19 storage_ids.conf
-rw-r--r--. 1 root root 7102 Apr 18 19:19 tracker.conf
-rw-r--r--. 1 root root 7102 April 18 19:05 tracker.conf.sample




#tracker configuration
mkdir -p /fastdfs/tracker #create directory
vim /etc/fdfs/tracker.conf #modify tracker.conf
base_path=/home/yuqing/FastDFS Change to: base_path=/fastdfs/tracker
For the explanation of the parameters of the tracker.conf configuration file, you can find the official document, the address is:
http://bbs.chinaunix.net/thread-1941456-1-1.html  firewall-cmd --permanent --zone=public --add-port=22122/tcp firewall-cmd --reload #tracker start|stop|restart ll /fastdfs/tracker/ #View folder  /etc/init.d/fdfs_trackerd start|stop|restart |status #Start |Stop|Restart, tracker ps -el|grep fdfs #View fdfs process ll /fastdfs/tracker/ #View folder: logs folder, data folder vim /etc/rc.d/rc.local # Set boot start /etc/init.d/fdfs_trackerd start #storage configuration mkdir -p /fastdfs/storage #Create directory vim /etc/fdfs/storage.conf #Modify storage.conf



















base_path=/home/yuqing/FastDFS is changed to: base_path=/fastdfs/storage
store_path0=/home/yuqing/FastDFS is changed to: store_path0=/fastdfs/storage #If
there are multiple mounted disks, define multiple store_paths, as follows
# store_path1=.....
#store_path2=......
tracker_server=192.168.0.3:22122 #Configure tracker server: IP #If
there are multiple, configure multiple trackers
#tracker_server=192.168.0.4:22122
http.server_port =8888 firewall-cmd --permanent --zone=public --add-port=23000/tcp firewall-cmd --reload #storage start ll /fastdfs/storage #View folder /etc/init.d/fdfs_storaged start| stop|restart|status #Start |Stop|Restart, tracker ps -el|grep fdfs #View fdfs process ll /fastdfs/storage/








#View folder: logs folder, data folder
vim /etc/rc.d/rc.local #Set the boot start
/etc/init.d/fdfs_storaged start




#Test, use /usr/bin/fdfs_test to test
vim /etc /fdfs/client.conf
base_path=/fastdfs/tracker
tracker_server=192.168.0.3:22122
ls /fastdfs/storage/data/00/00 #View folder, nothing.
#Use format: /usr/bin/fdfs_test client configuration file address upload Upload file #For
example: upload the picture under /home to FastDFS:
①/usr/bin/fdfs_test /etc/fdfs/client.conf upload /etc /fdfs/anti-steal.jpg 
example file url: 
http://192.168.0.3/group1/M00/00/00/wKgAA1rXMjCAPrqTAABdrZgsqUU599.jpg
http://192.168.0.3/group1/M00/00/00/wKgAA1rXMjCAPrqTAABdrZgsqUU599_big.jpg
②/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /etc/fdfs/anti-steal.jpg 


ls /fastdfs/storage/data/00/00 #View folder
[root@localhost data]# ls /fastdfs / Storage / the Data /
00/00 wKgAA1rXMjCAPrqTAABdrZgsqUU599_big.jpg wKgAA1rXMjCAPrqTAABdrZgsqUU599.jpg wKgAA1rXMjCAPrqTAABdrZgsqUU599_big.jpg
wKgAA1rXMjCAPrqTAABdrZgsqUU599.jpg-m-m


# access http://192.168.0.3/group1/M00/00/00/wKgAA1rW_kmAT7woAAAClw10KCA106_big.png  
Not Found at
The requested the URL of /group1/M00/00/00/wKgAA1rW_kmAT7woAAAClw10KCA106_big.png was not found on this server. #Cannot
use http download because it has not yet integrated with nginx.




#FastDFS and nginx integration
# Install nginx on the tracker. For installation details, refer to the nginx documentation.
#Install nginx on each tracker, the main purpose is to do load balancing and achieve high availability.
#If there is only one tracker server, nginx can not be configured.
#Install nginx on Storage
#Xftp upload fastdfs-nginx-module_v1.16.tar.gz to /home/FastDFS
cd /home/FastDFSPackage/
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz -C /usr/ local/
cd /usr/local/fastdfs-nginx-module/src
vim /usr/local/fastdfs-nginx-module/src/config
Modify the config file and change the /usr/local/ path to /usr/, only modify the fourth OK, the fifth line does not need to be modified.
old CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"
new CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"


rm -rf /usr/ local/nginx/
cd /home/FastDFSPackage
tar -zxvf nginx-1.10.3.tar.gz 
cd /home/FastDFSPackage/nginx-1.10.3
./configure --add-module=/usr/local/fastdfs-nginx-module/src/
make && make install


#Copy mod_FastDFS.conf under FastDFS-nginx-module/src to /etc/fdfs/ under cp / usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/ vim /etc/fdfs/mod_fastdfs.conf #Modification : such as connection timeout, tracker path configuration, url group configuration, base_path=/ temp connect_timeout=10 tracker_server=192.168.0.3:22122 #tracker_server=192.168.0.4:22122 (multiple trackers are configured with multiple lines) url_have_group_name = true #url contains group name store_path0=/fastdfs/storage #specify file storage path cp /usr /lib64/libfdfsclient.so /usr/lib/ #Copy libfdfsclient.so to /usr/lib #Create nginx/client directory mkdir -p /var/temp/nginx/client



 










#nginx configuration file
vim /usr/local/nginx/conf/nginx.conf
The modified content is:
listen 8888;
server_name localhost;
location ~/group([0-9])/M00 {
root /fastdfs/storage/data;
ngx_fastdfs_module ;
}
Note: The port in nginx should be the same as the storage.conf file configuration in FastDFS storage, http.server_port=8888
ln -s /fastdfs/storage/data/ /fastdfs/storage/data/M00


firewall-cmd -- permanent --zone=public --add-port=8888/tcp
firewall-cmd --reload


/usr/local/nginx/sbin/nginx


Start command:
start tracker command: /etc/init.d/fdfs_trackerd start
View process command : ps -el | grep fdfs
start storage command: /etc/init.d/fdfs_storaged start
View process command: ps -el | grep fdfs
Start nginx command: /usr/local/nginx/sbin/nginx


Stop command:
stop tracker command: /etc/init.d/fdfs_trackerd stop
Close storage command: /etc/init.d/fdfs_storaged stop
Close nginx command: /usr/ local/nginx/sbin/nginx -s stop


delete uploaded files:
/usr/bin/fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/wK
gBe1iEcGOAafHdALSFS-ifSIk.tar.gz #Reference


: https:/ /www.cnblogs.com/tc520/p/6822412.html 

Guess you like

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