准备安装包
https://github.com/happyfish100
https://sourceforge.net/projects/fastdfs/files/
libfastcommon-master.zip
FastDFS_v5.05.tar.gz
fastdfs_client_java._v1.25.tar.gz
nginx-1.6.2.tar.gz
fastdfs-nginx-module_v1.16.tar.gz
2.简介
3.跟踪服务器和存储服务器环境准备
(1)编绎和安装工具准备
[root@server ~]#yum install make cmake gcc gcc-c++
(2)安装libfastcommon
[root@server ~]#cd /usr/local/src/ [root@server src]#ll -rw-r--r--. 1 root root 42656 Mar 25 2015 fastdfs_client_java._v1.25.tar.gz -rw-r--r--. 1 root root 17510 Mar 25 2015 fastdfs-nginx-module_v1.16.tar.gz -rw-r--r--. 1 root root 345400 Mar 25 2015 FastDFS_v5.05.tar.gz -rw-r--r--. 1 root root 102378 Mar 25 2015 libfastcommon-master.zip -rw-r--r--. 1 root root 804164 Mar 29 2015 nginx-1.6.2.tar.gz [root@server src]#unzip libfastcommon-master.zip [root@server src]#cd libfastcommon-master [root@server libfastcommon-master]#./make.sh [root@server libfastcommon-master]#./make.sh install [root@server libfastcommon-master]#find /usr -name "libfast*.so" /usr/local/src/libfastcommon-master/src/libfastcommon.so /usr/lib64/libfastcommon.so [root@server libfastcommon-master]cd [root@server ~]#ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so [root@server ~]#ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
(3)安装fastDFS
[root@server ~]#cd /usr/local/src [root@server src]#tar -zxvf FastDFS_v5.05.tar.gz [root@server src]#cd FastDFS [root@server FastDFS]#./make.sh [root@server FastDFS]#./make.sh install [root@server FastDFS]#find / -path "/usr/local/src" -prune -o -path "*fdfs*" /*fdfs配置文件*/ /etc/fdfs /etc/fdfs/tracker.conf.sample /etc/fdfs/storage.conf.sample /etc/fdfs/client.conf.sample /*fdfs服务服本,/etc/init.d是/etc/rc.d/init.d的软链接*/ /etc/rc.d/init.d/fdfs_trackerd /etc/rc.d/init.d/fdfs_storaged /*fdfs头文件*/ /usr/include/fastdfs/fdfs_http_shared.h /usr/include/fastdfs/fdfs_client.h /usr/include/fastdfs/fdfs_global.h /usr/include/fastdfs/fdfs_define.h /usr/include/fastdfs/fdfs_shared_func.h /*fdfs命令行工具*/ /usr/bin/fdfs_test1 /usr/bin/fdfs_appender_test1 /usr/bin/fdfs_append_file /usr/bin/fdfs_appender_test /usr/bin/fdfs_trackerd /usr/bin/fdfs_storaged /usr/bin/fdfs_file_info /usr/bin/fdfs_delete_file /usr/bin/fdfs_download_file /usr/bin/fdfs_test /usr/bin/fdfs_upload_appender /usr/bin/fdfs_crc32 /usr/bin/fdfs_upload_file /usr/bin/fdfs_monitor /*fdfs共享库文件*/ /usr/lib64/libfdfsclient.so [root@server ~]#ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so [root@server ~]#ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so [root@server ~]#vi /etc/init.d/fdfs_trackerd :%s+/usr/local/bin+/usr/local /**整体替换**/ :wq [root@server ~]#vi /etc/init.d/fdfs_storaged :%s+/usr/local/bin+/usr/local /**整体替换**/ :wq
4.配置跟踪服务器
(1)复制并重命名跟踪器配置文件
[root@server ~]#cd /etc/fdfs/ [root@server fdfs]#ll -rw-r--r--. 1 root root 1461 Nov 2 16:51 client.conf.sample -rw-r--r--. 1 root root 7829 Nov 2 16:51 storage.conf.sample -rw-r--r--. 1 root root 7102 Nov 2 16:51 tracker.conf.sample [root@server fdfs]#cp tracker.conf.sample tracker.conf [root@server fdfs]#vi tracker.conf /**修改以下内容,其它默认**/ disabled=false port=22122 base_path=/fastdfs/tracker [root@server fdfs]#mkdir -p /fastdfs/tracker
(2)打开防火墙端口
[root@server fdfs]#vi /etc/sysconfig/iptables /**添加一行**/ -A INPUT -m state --state NEW -m tcp -p tcp --dport 2202 -j ACCEPT [root@server fdfs]#service iptables restart
(3)启动tracker
[root@server fdfs]#/etc/init.d/fdfs_trackerd start [root@server fdfs]#ps -ef | grep fdfs root 4211 1 0 19:18 ? 00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf [root@server fdfs]#/etc/init.d/fdfs_trackerd stop
(4)加入开机启动
[root@server fdfs]#vi /etc/rc.local /**文件最后加一行**/ /etc/init.d/fdfs_trackerd start
4.配置存储器
(1)复制并重命名存储器配置文件
[root@server ~]#cd /etc/fdfs/ [root@server fdfs]#ll -rw-r--r--. 1 root root 1461 Nov 2 16:51 client.conf.sample -rw-r--r--. 1 root root 7829 Nov 2 16:51 storage.conf.sample -rw-r--r--. 1 root root 7102 Nov 2 16:51 tracker.conf.sample [root@server fdfs]#cp storage.conf.sample storage.conf [root@server fdfs]#vi storage.conf /**修改以下内容,其它默认**/ disabled=false port=23000 base_path=/fastdfs/storage store_path0=/fastdfs/storage tracker_server=192.168.31.3:22122 http.server_port=8888 [root@server fdfs]#mkdir -p /fastdfs/storage
(2)打开防火墙端口
[root@server fdfs]#vi /etc/sysconfig/iptables /**添加一行**/ -A INPUT -m state --state NEW -m tcp -p tcp --dport 23000-j ACCEPT [root@server fdfs]#service iptables restart
(3)启动storage
[root@server fdfs]#/etc/init.d/fdfs_storaged start [root@server fdfs]#ps -ef | grep fdfs root 2647 1 72 19:41 pts/0 00:00:08 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf [root@server fdfs]#/etc/init.d/fdfs_storaged stop
(4)加入开机启动
[root@server fdfs]#vi /etc/rc.local /**文件最后加一行**/ /etc/init.d/fdfs_storaged start
4.客户端上传文件
(1)复制并重命名客户端配置文件
[root@server ~]#cd /etc/fdfs/ [root@server fdfs]#ll -rw-r--r--. 1 root root 1461 Nov 2 16:51 client.conf.sample -rw-r--r--. 1 root root 7829 Nov 2 16:51 storage.conf.sample -rw-r--r--. 1 root root 7102 Nov 2 16:51 tracker.conf.sample [root@server fdfs]#cp client.conf.sample client.conf [root@server fdfs]#vi client.conf port=192.168.31.3:22122 base_path=/fastdfs/tracker :wq
(2)测试上传
[root@server fdfs]#/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /usr/local/src/libfastcommon-master.zip /**返回一个id号说明成功**/ group1/M00/00/00/wKgfA1gZ1TeAdnNQAAGP6hUWM6I769.zip
5.在存储器上安装nginx
(1)解压fastdfs-nginx-module_v1.16.tar.gz
[root@server ~]#cd /usr/local/src [root@server src]#ls /usr/local/src fastdfs-nginx-module_v1.16.tar.gz [root@server src]#tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
(2)修改fastdfs-nginx-module的config文件
[root@server src]#cd fastdfs-nginx-module/src [root@server src]#vi config CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/" 修改为 CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
(3)编绎和安装所需工具包
[root@server src]#yum install gcc gcc-c++ make automake autoconf libtool pcre* zlib openssl openssl-devel
(4)编绎安装nginx
[root@server src]#cd /usr/local/src [root@server src]#ls nginx-1.6.2.tar.gz [root@server src]#tar -zxvf nginx-1.6.2.tar.gz [root@server src]#cd nginx-1.6.2 [root@server src]#./configure --add-module=/usr/local/src/fastdfs-nginx-module/src [root@server src]#make & make install
(5)复制fastdfs-nginx-module源码中的配置文件到/etc/fdfs目录,并修改。
[root@server src]#cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs [root@server src]#vi /etc/fdfs/mod_fastdfs.conf connect_timeout=10 base_path=/tmp tracker_server=192.168.31.3:22122 storage_server_port=23000 group_name=group1 url_have_group_name = true store_path0=/fastdfs/storage
(6)复制FastDFS源码中的一些配置文件到/etc/fdfs目录。
[root@server src]#cd /usr/local/src/FastDFS/conf [root@server conf]#cp http.conf mime.types /etc/fdfs
(7)在/fastdfs/storage/data目录下建立软连接。
[root@server conf]#ln -s /fastdfs/storage/data /fastdfs/storage/data/M00
(8)配置nginx
[root@server conf]#vi /usr/local/nginx/conf/nginx.conf
/**修改红色字部分**/
user root;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
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{
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
(9)打开防火墙端口
[root@server conf]#vi /etc/sysconfig/iptables /**添加一行**/ -A INPUT -m state --state NEW -m tcp -p tcp --dport 8888 -j ACCEPT [root@server conf]#service iptables restart
(10) 启动nginx
[root@server conf]#/usr/local/nginx/sbin/nginx ngx_http_fastdfs_set pid=7536 /**重启采用/usr/local/nginx/sbin/nginx -s reload**/
(11)添加开机启动
[root@server conf]#vi /etc/rc.local /**添加一句**/ /usr/local/nginx/sbin/nginx
(12)下载前面上传的文件
http://192.168.31.3:8888/group1/M00/00/00/wKgfA1gZ1TeAdnNQAAGP6hUWM6I769.zip