FastDFS installation and deployment, FastDFS installation and deployment
(1) download the dependent library libevent (no matter where it is extracted, it must be installed in the/usr directory; otherwise, FastDFS cannot be found)
Wget https://github.com/downloads/libevent/libevent/libevent-1.4.14b-stable.tar.gz
Tar zvxf libevent-1.4.14b-stable.tar.gz
./Configure -- prefix =/usr
Make clean;
Make
Make install
(2) download the FastDFS installation package and nginx dependent components
FastDFS official forum: http://www.csource.org
Download 1: http://sourceforge.net/projects/fastdfs/files/
Download 2: https://code.google.com/p/fastdfs/downloads/list
The packages to be downloaded include:
FastDFS source code: FastDFS_v5.01.tar.gz
Nginx Server Source: nginx-1.4.7.tar.gz
Nginx extension source code: fastdfs-nginx-module_v1.15.tar.gz
Nginx cache plug-in source code: ngx_cache_purge-2.1.tar.gz
Nginx dependent pcre Library source code: pcre-8.34.tar.gz
Nginx dependent zlib library source code: zlib-1.2.8.tar.gz
Nginx dependent openssl Library source code: openssl-fips-2.0.9.tar.gz
-- Disable Firewall
Service iptables stop
(3) Installation
Cp FastDFS_v5.01.tar.gz/usr/local/src/
Cd/usr/local/src/
Tar-zxvf FastDFS_v5.01.tar.gz
Cd FastDFS
./Make. sh
./Make. sh install
Note:
(1) installation error during./make. sh. The dependent software package may be missing. After installation, run./make. sh again.
(2) installed
The source file directory is/usr/local/src/
The executable file directory is:/usr/local/bin.
The directory of all configuration files is/etc/fdfs (tracker. conf, storage. conf, and client. conf will be generated under this directory)
FastDFS is successfully installed now ....
(4) configure and start the Tracker Server
Vim/etc/fdfs/tracker. conf
-- Modify the file:
Disabled = false # enable the configuration file (this does not know how to handle it for the time being)
Port = 22122 # Set the tracker port number
Base_path =/fdfs/tracker # Set the tracker data file and log directory (which must be created in advance)
Http. server_port = 8090 # Set the http port number
# Include http. conf
Note that the above is 1 #, and the default is 2 #. Just remove 1.
-- Enable port
Iptables-I INPUT-p tcp-m state -- state NEW-m tcp -- dport 22122-j ACCEPT
-- Save the firewall rule to/etc/sysconfig/iptables (if iptables does not exist, manually create and authorize it)
/Etc/init. d/iptables save
-- Start tracker and check whether the start is successful.
/Usr/local/bin/fdfs_trackerd/etc/fdfs/tracker. conf restart
-- Check whether the Listening Starts on port 22122.
Netstat-unltp | grep fdfs
-- Check whether the tracker log is incorrect.
Cat/fdfs/tracker/logs/trackerd. log
-- Set automatic start upon startup
Vim/etc/rc. d/rc. local
Add:/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker. conf restart
(5) configure and start the Storage Server
Vim/etc/fdfs/storage. conf
-- Modify the file:
Group_name = group1 # group name, which can be modified as needed
Port = 23000 # Set the storage port number
Base_path =/fdfs/storage # Set the storage log directory (which must be created in advance)
Store_path_count = 1 # Number of storage paths, which must match the number of store_path
Store_path0 =/fdfs/storage # storage path
Tracker_server = 192.168.1.103: 22122 # ip address and port number of the tracker server (if the tracker is a separate server, the ip address is written separately)
Http. server_port = 8888 # Set the http port number
# Include http. conf
-- Enable port
Iptables-I INPUT-p tcp-m state -- state NEW-m tcp -- dport 23000-j ACCEPT
-- Save the firewall rule to/etc/sysconfig/iptables (if iptables does not exist, manually create and authorize it)
/Etc/init. d/iptables save
-- Start tracker and check whether the start is successful.
/Usr/local/bin/fdfs_storaged/etc/fdfs/storage. conf restart
-- Check whether the Listening Starts on port 23000.
Netstat-unltp | grep fdfs
-- Check whether the tracker log is incorrect.
Cat/fdfs/storage/logs/storaged. log
-- Set automatic start upon startup
Vim/etc/rc. d/rc. local
Add:/usr/local/bin/fdfs_storaged/etc/fdfs/storage. conf restart
-- After the startup is successful, run fdfs_monitor to check whether the storage server has been registered with the tracker server. The ip address of the tracker is normal in the first few lines.
/Usr/local/bin/fdfs_monitor/etc/fdfs/storage. conf
So far, non-nginx FastDFS file system has been installed
(6) Verify FastDFS upload and download (the local client configuration can be omitted for upload and download)
Vim/etc/fdfs/client. conf
-- Modify client. conf
Base_path =/fdfs/client
Tracker_server = 192.168.1.103: 22122
Http. tracker_server_port = 8090 # Set the tracker port number
-- Upload
Fdfs_test/etc/fdfs/client. conf upload/data/monk.jpg
Http: // 192.168.1.103: 8090/group1/M00/00/00/OlPQG1Db6jWAFmbTAAADqdgNsks5096460_big.jpg
-- Delete
Fdfs_test/etc/fdfs/client. conf delete group1 M00/00/00/OlPQG1Db6jWAFmbTAAADqdgNsks5096460_big.jpg
Http: // 192.168.1.103: 8090/group1/M00/00/00/wKgBZ1UX8tGACWOJAACdM6nw92I711_big.jpg
(7) FastDFS and nginx Integration
(1) install the extension plug-in nginx
Cp fastdfs-nginx-module_v1.15.tar.gz/usr/local/src
Tar-zxvf fastdfs-nginx-module_v1.15.tar.gz
Cd/usr/local/src
Cd nginx-1.4.7
. /Configure -- prefix =/usr/local/nginx -- add-module =/usr/local/src/fastdfs-nginx-module/src -- with-pcre =/usr/local/ src/pcre-8.34/-- with-zlib =/usr/local/src/zlib-1.2.8
Make
Make install
-- Copy the extension configuration file to/etc/fdfs.
Cp/usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/
(2) Configure mod_fastdfs.conf
Vim/etc/fdfs/mod_fastdfs.conf
-- Modify the file:
Base_path =/fdfs/storage # Save the log directory
Tracker_server = 192.168.1.103: 22122 # IP address and port number of the tracker server
Storage_server_port = 23000 # storage server port number
Group_name = group1 # Name of the group on the current server
Url_have_group_name = true # Whether the File url contains a group name
Store_path_count = 1 # Number of storage paths, which must match the number of store_path
Store_path0 =/fdfs/storage # storage path
Http. need_find_content_type = true # Find the file type from the file extension (true for nginx)
Group_count = 1 # set the number of groups
-- Establish a soft connection
Ln-s/fdfs/storage/data/M00
(3) Configure nginx. conf
Vim/usr/local/nginx/conf/nginx. conf
-- Modify the file:
Server {
Listen 8888;
Location /{
Root html;
Index index.html index.htm;
}
Location/group1/M00 {
Root/fdfs/storage/data;
Ngx_fastdfs_module;
}
}
-- Restart tracker
/Usr/local/bin/fdfs_trackerd/etc/fdfs/tracker. conf restart
-- Restart storage
/Usr/local/bin/fdfs_storaged/etc/fdfs/storage. conf restart
-- Restart nginx
/Usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx. conf
/Usr/local/nginx/sbin/nginx-s reload
-- View the startup log:
Cat/fdfs/tracker/logs/trackerd. log
Cat/fdfs/storage/logs/storaged. log
Cat/usr/local/nginx/logs/error. log
-- Access nginx
Http: // 192.168.1.103: 8888/
-- View port usage:
Netstat-lnp -- tcp
Tcp 0 0 0.0.0.0: 23000 0.0.0.0: * LISTEN 1761/fdfs_storaged
Tcp 0 0 0.0.0.0: 8888 0.0.0.0: * LISTEN 1718/nginx
Tcp 0 0 0.0.0.0: 8090 0.0.0.0: * LISTEN 1809/fdfs_trackerd
Tcp 0 0 0.0.0.0: 22122 0.0.0.0: * LISTEN 1809/fdfs_trackerd
The default port 8888 is originally stored and is now replaced by nginx
(8) upload and download
-- Make sure that/etc/fdfs/client. conf is correctly configured before uploading
Base_path =/fdfs/tracker # log storage path
Tracker_server = 192.168.1.103: 22122 # tracker server IP address and port number
Http. tracker_server_port = 8090 # http port number of the tracker server
-- Use/usr/local/bin/fdfs_upload_file to upload a file. The program will automatically return the File URL
/Usr/local/bin/fdfs_upload_file/etc/fdfs/client. conf/data/8.jpg
-- Return:
Group1/M00/00/00/wKgBZ1UX_7WAQTFPAACdM6nw92I838.jpg
-- Browser access:
Http: // 192.168.1.103: 8888/group1/M00/00/00/wKgBZ1UX_7WAQTFPAACdM6nw92I838.jpg
-- View the access. log of nginx. You can see that 200 is returned for successful access
Tail-n 10-f/usr/local/nginx/logs/access. log
Http://nonfu.me/p/4843.html