Fastdfs is an open source lightweight Distributed File system, which manages files, including file storage, file synchronization, file access (file upload, file download), and so on, which solves the problem of large capacity storage and load balancing. It is especially suitable for document-based online services. Wikipedia
In this paper, the detailed installation process of Fastdfs on the CentOS system is described in detail, and the HTTP access request is implemented by using nginx from the machine. ( reproduced Please indicate, thank you )
Fdfs Kit http://pan.baidu.com/s/1eQHCSJw
Copy the toolkit to the server using winscp
1. Node and shutdown service (firewall off)
sudo service iptables stop
sudo chkconfig iptables off
sudo vi/etc/selinux/config modify selinux=disable
2, start to install Fastdfs, host Tracker, slave storage Installation Method
3. Check If the GCC compiler system is installed
sudo yum install-y gcc gcc-c++
4,fastdfs_v5.05 rely on Libfastcommon, no longer rely on libevent.
5, installation Libfastcommon
(1) Install the unzip package, unzip the Libfastcommon to/usr/local
sudo yum install-y unzip zip
sudo unzip libfastcommon-1.0.7.zip-d/usr/local
(2) Compile and run
cd/usr/local/libfastcommon-1.0.7
sudo./make.sh
sudo./make.sh Install
Because the Lib directory set by the FASTDFS main program is/usr/local/lib, you need to create a soft link.
sudo ln-s/usr/lib64/libfastcommon.so/usr/local/lib/libfastcommon.so
sudo ln-s/usr/lib64/libfastcommon.so/usr/lib/libfastcommon.so
sudo ln-s/usr/lib64/libfdfsclient.so/usr/local/lib/libfdfsclient.so
sudo ln-s/usr/lib64/libfdfsclient.so/usr/lib/libfdfsclient.so
6, installation Fastdfs
(1) Unzip Fastdfs to/usr/local
sudo tar-zxvf fastdfs_v5.05.tar.gz-c/usr/local
(2) Compile and install
Cd/usr/local/fastdfs
sudo./make.sh
sudo./make.sh Install
Installation is complete, if the installation fails, check the soft connection, the host slave must be configured like this
7. Configuring Tracker and Storage
(1) Tracker, creating tracker.conf
cd/etc/fdfs/
sudo cp tracker.conf.sample tracker.conf
Create a data store directory
Mkdir/mnt/fastdfs_tracker
Modifying the tracker.conf configuration file
Base_path=/mnt/fastdfs_tracker
Start the configuration file
Fdfs_trackerd/etc/fdfs/tracker.conf
(2) Storage, creating storage.conf
cd/etc/fdfs/
sudo cp storage.conf.sample storage.conf
Create a data store directory
sudo mkdir/mnt/fastdfs_storage_info
sudo mkdir/mnt/fastdfs_storage_data
Modifying the storage.conf configuration file
Base_path=/mnt/fastdfs_storage_info
Store_path0=/mnt/fastdfs_storage_data
Tracker_server= Host IP: port (default 22122)
Start the configuration file for the first time (the action is a bit slow and patient)
Fdfs_storaged/etc/fdfs/storage.conf
Note: Please check the log for errors:
Cat/mnt/fastdfs_tracker/logs/tracker.log
Cat/mnt/fastdfs_storage_info/logs/storage.log
Telnet checks whether the master/slave communicates
Http://jingyan.baidu.com/article/3c48dd34709e70e10be35835.html
Using the fdfs_test/etc/fdfs/client.conf upload 1.png test FASTDF is not working properly and is displayed correctly as:
8, the nginx installed on the storage mainly to provide http Access services, while resolving Synchronization Latency issues for storage servers in Group
(1) Decompression Nginx plugin fastdfs-nginx-module, and dependent package pcre, zlib
sudo tar-zxvf fastdfs_v5.05.tar.gz-c/usr/local
sudo tar-zxvf pcre-8.34.tar.gz-c/usr/local
sudo tar-zxvf zlib-1.2.8.tar.gz-c/usr/local
(2) Decompression and installation Nginx
sudo tar-zxvf nginx-1.7.8.tar.gz-c/usr/local
sudo./configure
--prefix=/usr/local/nginx--add-module=/usr/local/fastdfs-nginx-module/src--with-pcre=/usr/local/src/pcre-8.34/ --with-zlib=/usr/local/src/zlib-1.2.8
(If you are prompted with an error, you may be missing a dependent package, you need to install the dependent package and run it again.)/configure)
sudo make
sudo make install
9 . copy The configuration file of Fastdfs 's nginx plugin module to Fastdfs The configuration file directory.
(1) cp/usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/
(2) Copy the http.conf, mime.types two files from the Fastdfs installation package to/etc/fdfs
sudo cp/usr/local/fastdfs/conf/http.conf/etc/fdfs/
sudo cp/usr/local/fastdfs/conf/mime.types/etc/fdfs/
(3) Edit the nginx.conf in the/usr/local/nginx/conf profile directory, set the Add storage information and save it.
sudo vi/usr/local/nginx/conf/nginx.conf
Change the listen port number in the server segment to 8080:
Listen 8080;
In the server segment, add:
Location ~/GROUP1/M00 {
Root/mnt/fastdfs_storage_data;
Ngx_fastdfs_module;
}
Multiple groups can be set up with only one set of ' group1 ' depending on the specific situation
Location ~/GROUP[1-3]/M00 {
Root/mnt/fastdfs_storage_data;
Ngx_fastdfs_module;
}
(4) Edit the mod_fastdfs.conf in the/etc/fdfs profile directory, set the storage information and save it.
sudo vi/etc/fdfs/mod_fastdfs.conf
In general, you only need to change the following parameters:
Base_path=/fdfs/storage #保存日志目录
Tracker_server= host ip:22122 #tracker服务器的IP地址以及端口号
storage_server_port=23000 #storage服务器的端口号
Group_name=group1 #当前服务器的group名
Url_have_group_name = True #文件url中是否有group名
Store_path_count=1 #存储路径个数, need to match Store_path number
Store_path0=/fdfs/storage #存储路径
Http.need_find_content_type=true #从文件扩展名查找文件类型 (True when nginx)
Some versions do not have this option do not care about it
Based on the number of groups you set above
Group_count = 1 #设置组的个数
Add 1 groups at the end of the specific information: (set a few groups to add a few groups)
[Group1]
Group_name=group1
storage_server_port=23000
Store_path_count=1
Store_path0=/mnt/fastdfs_storage_data
/*[GROUP2]
Group_name=group2
storage_server_port=23000
Store_path_count=1
Store_path0=/mnt/fastdfs_storage_data
[Group3]
Group_name=group3
storage_server_port=23000
Store_path_count=1
store_path0=/mnt/fastdfs_storage_data*/
(5) Create a soft connection to the M00 to the storage directory
sudo ln-s/mnt/fastdfs_storage_data/mnt/fastdfs_storage_data/m00
Test if the soft connection has not been set successfully
Ll/fdfs/storage/data/m00
lrwxrwxrwx. 1 root root 19 March 03:44/fdfs/storage/data/m00-/fdfs/storage/data/
operation of Nginx
(1) Before running Nginx, the corresponding port in the firewall should be opened (in this case, 8080).
Not root users want sudo
[Email protected] nginx-1.4.7]# iptables-i input-p tcp-m State--state new-m TCP--dport 8080-j ACCEPT
[Email protected] nginx-1.4.7]#/etc/init.d/iptables Save
(2) Start Nginx to confirm the success of the boot. (see if the corresponding port 8080 starts listening)
[Email protected] nginx-1.4.7]#/usr/local/nginx/sbin/nginx
Ngx_http_fastdfs_set pid=40638
[Email protected] nginx-1.4.7]# NETSTAT-UNLTP | grep nginx
TCP 0 0.0.0.0:8080 0.0.0.0:* LISTEN 40639/nginx
You can also see if the Nginx logs were started successfully or if there were errors.
[Email protected] nginx-1.4.7]# Cat/usr/local/nginx/logs/error.log
Ngx_http_fastdfs_process_init pid=40640
[2014-03-26 03:47:17] Info-local_host_ip_count:2, 127.0.0.1 slave IP
[2014-03-26 03:47:17] Info-fastdfs Apache/nginx Module v1.15, Response_mode=proxy, Base_path=/tmp, url_have_group_name=1, group_count=3, con nect_timeout=2, network_timeout=30, Tracker_server_count=1, if_alias_prefix=, local_host_ip_count=2, Need_find_ Content_type=1, Default_content_type=application/octet-stream, anti_steal_token=0, token_ttl=0s, Anti_steal_secret _key length=0, Token_check_fail content_type=, Token_check_fail buff length=0, load_fdfs_parameters_from_tracker=1, storage_sync_file_max_delay=86400s, use_storage_id=0, storage server ID count=0, flv_support=1, flv_extension=flv
[2014-03-26 03:47:17] (set several groups to display several groups)
Info-group 1. Group_name=group1, storage_server_port=23000, Path_count=1, Store_path0=/mnt/fastdfs_storage_data
[2014-03-26 03:47:17]
Info-group 2. Group_name=group2, storage_server_port=23000, Path_count=1, Store_path0=/mnt/fastdfs_storage_data
[2014-03-26 03:47:17]
Info-group 3. Group_name=group3, storage_server_port=23000, Path_count=1, Store_path0=/mnt/fastdfs_storage_data
There are no errors in Error.log, both start successfully. You can open the browser and directly access http://from 8080 to see if the Nginx welcome page pops up.
To view files uploaded from a machine:
Http://10.120.20.191:8080/group1/M00/00/00/wKgAOVWsnq-AOMfVAADroWmJH48190_big.png
FASTDFS installation configuration and use on CentOS