fastdfs5.0.5+nginx安装+tracker+storage

来源:互联网 发布:阿里云大学在哪打开 编辑:程序博客网 时间:2024/06/05 07:41

服务器环境:centos6
IP:192.168.0.62
所需资源下载:http://pan.baidu.com/s/1pwOQa 密码:q63k

1、为了顺利安装可以先将防火墙关掉

service iptables stop chkconfig iptables offvi /etc/selinux/config修改 selinux=disable

2、增加gcc gcc-c++

yum install -y gcc gcc-c++

3、安装libfastcommon
解压:将安装包解压。

unzip libfastcommon-1.0.7.zipcd libfastcommon./make.sh./make.sh install

可以看到libfastcommon.so安装到了/usr/lib64/libfastcommon.so
但是FastDFS主程序设置的lib目录是/usr/local/lib
4、创建软链接

ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.soln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.soln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.soln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so 

5、安装FastDFS
解压FastDFS

tar -zxvf FastDFS_v5.05.tar.gz cd FastDFSvi ./make.shTARGET_CONF_PATH=/usr/local/FastDFS./make.sh./make.sh installcp /ust/local/FastDFS/tracker.conf.sample /etc/fdfs/tracker.confcp /ust/local/FastDFS/storage.conf.sample /etc/fdfs/storage.conf

6、配置Tracker

mkdir /data/fastdfs_trackervi /etc/fdfs/tracker.confbase_path=/data/fastdfs_tracker

运行

fdfs_trackerd /etc/fdfs/tracker.conf

7、配置Storage

mkdir /data/fastdfs_storage_infomkdir /data/fastdfs_storage_datavi /etc/fdfs/storage.confbase_path=/data/fastdfs_storage_infostore_path0=/data/fastdfs_storage_datatracker_server=192.168.0.62:22122

运行

fdfs_storaged /etc/fdfs/storage.conf

配置完成,可以在如下目录查看日志

/data/fastdfs_tracker/logs/tracker.log/data/fastdfs_storage_info/logs/storage.log

启动tracker

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

8、安装nginx
安装nginx依赖包

yum install –y openssl-devel pcre-devel zlib-devel

解压fastdfs-nginx-module

tar -zxvf fastdfs-nginx-module_v1.16.tar.gz cd fastdfs-nginx-modulecp ./fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/vi /etc/fdfs/mod_fastdfs.conf

修改如下信息

tracker_server=192.168.1.50:22122url_have_group_name= truestore_path0=/data/fastdfs_storage_data

解压、安装nginx

tar -zxvf nginx-1.7.8.tar.gzcd nginx-1.7.8./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module/srcmake make install

如果make的时候报错做如下操作
a、yum groupinstall “Development Tools”
b、修改 fastdfs-nginx-module_v1.15/src/config

vi fastdfs-nginx-module_v1.15/src/config修改成以下内容 ngx_addon_name=ngx_http_fastdfs_module HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module" NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c" CORE_INCS="$CORE_INCS /usr/local/fdfs/include/fastdfs /usr/local/fdfs/include/fastcommon/" CORE_LIBS="$CORE_LIBS -L/usr/local/fdfs/lib -lfastcommon -lfdfsclient" CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/usr/local/fdfs/conf/mod_fastdfs.conf\"'" 

9、配置nginx

vi /usr/local/nginx/conf/nginx.conflocation /group1/M00 {            root /data/fastdfs_storage_data;            ngx_fastdfs_module;}location / {    if ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){        add_header Content-Disposition: 'attachment;';    }}

运行

ldd $(which /usr/local/nginx/sbin/nginx)

Tracker server启动

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf

Storage server启动

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf

查看是否启动成功

netstat -ntpl | grep fdfs

启动nginx
首先拷贝FastDFS目录下conf目录下得http.conf,mime.types

cp http.conf mime.types /etc/fdfs/cd /usr/loca/nginx/sbin./nginx

10、测试

cp /ust/local/FastDFS/client.conf.sample /etc/fdfs/client.confvi /etc/fdfs/client.cofbase_path=/tmptracker_server=192.168.0.62:22122

创建测试文件

vi test.txt

输入内容: hello,this is my first fastdfs test
运行

 /usr/bin/fdfs_test /etc/fdfs/client.conf upload test.txt

打印如下内容,说明上传成功

This is FastDFS client test program v3.06Copyright (C) 2008, Happy Fish / YuQingFastDFS may be copied only under the terms of the GNU GeneralPublic License V3, which may be found in the FastDFS source kit.Please visit the FastDFS Home Page http://www.csource.org/for more detail.[2012-06-13 17:58:25] INFO - base_path=/tmp, connect_timeout=30, network_timeout=60, tracker_server_count=2, anti_steal_token=0, anti_steal_secret_key length=0tracker_query_storage_store_list_without_group:        server 1. group_name=group1, ip_addr=192.168.68.114, port=23000group_name=group1, ip_addr=192.168.0.62, port=23000storage_upload_by_filenamegroup_name=group1, remote_filename=M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607.txtsource ip address: 192.168.0.62file timestamp=2012-06-13 17:58:25file size=37file crc32=3584975788file url: http://192.168.0.62/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607.txtstorage_upload_slave_by_filenamegroup_name=group1, remote_filename=M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txtsource ip address: 192.168.68.114file timestamp=2012-06-13 17:58:25file size=37file crc32=3584975788file url: http://192.168.0.62/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txt

使用浏览器打开上传的文件

http://192.168.0.62/group1/M00/00/00/wKhEck_YZEHqsZRSAAAAJdWuY6w607_big.txt

如果看到文件内容,说明配置成功!

0 0
原创粉丝点击