FastDFS安装.docx

上传人:b****2 文档编号:2327810 上传时间:2023-05-03 格式:DOCX 页数:20 大小:884.55KB
下载 相关 举报
FastDFS安装.docx_第1页
第1页 / 共20页
FastDFS安装.docx_第2页
第2页 / 共20页
FastDFS安装.docx_第3页
第3页 / 共20页
FastDFS安装.docx_第4页
第4页 / 共20页
FastDFS安装.docx_第5页
第5页 / 共20页
FastDFS安装.docx_第6页
第6页 / 共20页
FastDFS安装.docx_第7页
第7页 / 共20页
FastDFS安装.docx_第8页
第8页 / 共20页
FastDFS安装.docx_第9页
第9页 / 共20页
FastDFS安装.docx_第10页
第10页 / 共20页
FastDFS安装.docx_第11页
第11页 / 共20页
FastDFS安装.docx_第12页
第12页 / 共20页
FastDFS安装.docx_第13页
第13页 / 共20页
FastDFS安装.docx_第14页
第14页 / 共20页
FastDFS安装.docx_第15页
第15页 / 共20页
FastDFS安装.docx_第16页
第16页 / 共20页
FastDFS安装.docx_第17页
第17页 / 共20页
FastDFS安装.docx_第18页
第18页 / 共20页
FastDFS安装.docx_第19页
第19页 / 共20页
FastDFS安装.docx_第20页
第20页 / 共20页
亲,该文档总共20页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

FastDFS安装.docx

《FastDFS安装.docx》由会员分享,可在线阅读,更多相关《FastDFS安装.docx(20页珍藏版)》请在冰点文库上搜索。

FastDFS安装.docx

FastDFS安装

FastDFS安装

---jikang

简介

FastDFS是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:

文件存储、文件同步、文件访问(文件上传、文件下载)等,解决了大容量存储和负载均衡的问题。

特别适合以文件为载体的在线服务,如相册网站、视频网站等等。

 

 

 

FastDFS的Storage定时向Tracker报告心跳和状态,Tracker的数据来源于storage的报告,本身可以不存储任何数据,只有配置文件。

• 上传文件:

client先请求tracker,tracker告诉client文件存入哪个storage,然后client向相应的storage发送文件,storage返回文件名。

• 下载文件:

client先请求tracker,tracker告诉client向哪个storage去读,client向指定的storage读文件。

• 文件副本的存储:

client上传文件到storage,只写一份,然后storage会异步想同组其他storage推数据,实现文件的多副本。

• 扩容:

只要增加新的group就实现的集群的扩容,tracker默认的分配规则是那个group的剩余空间大数据就向那个group写

 •优点:

–平滑扩容

–运行稳定

–易于维护和管理(日志、管理工具)

–Trunk模式可以合并小文件(变复杂)

•缺点:

–Php的扩展依赖fastdfs的二进制程序

–Fastdfs的client和应用程序耦合

CentOS安装DFS

注:

这里traceker服务安装在10.40.138.132服务器上,

storage服务安装在10.40.138.130服务器上

准备DFS文件

tracker安装

文件上传

用ftp工具将libfastcommon-master.zip,FastDFS_v5.08.tar.gz

文件上传的服务器/home目录下

 

  

安装 libfastcommon-master.zip

1.解压libfastcommon-master.zip

   unziplibfastcommon-master.zip

2.进入libfastcommon-master目录

   cdlibfastcommon-master

3.编译  

 执行脚本./make.sh

4.安装

执行命令

./make.shinstall

 出现如上结果则安装成功

 安装 FastDFS_v5.08.tar.gz

1.解压文件

在/home目录下执行命令

 tar-zxvfFastDFS_v5.08.tar.gz

2.进入FastDFS目录 

cdFastDFS

3.编译

执行脚本./make.sh

4.安装

执行命令

./make.shinstall

出现上面结果安装成功

 

 配置tracker.conf文件

 tracker.conf默认安装在/etc/fdfs

 

1.将tracker.conf文件复制到FastDFS/conf目录下

cp/etc/fdfs/tracker.conf/home/FastDFS/conf

2.修改tracker.conf配置

●port为tracker服务的端口,默认为22122

base_path为storedata与log存放路径.根据实际情况修改.若该路径不存在请新建.这里改为/home/FastDFS/data(需要在FastDFS目录下新建data文件夹)

tracker启动

执行命令(下面分别是启动,停止,重启命令)

fdfs_trackerd/home/FastDFS/conf/tracker.confstart

fdfs_trackerd/home/FastDFS/conf/tracker.confstop

fdfs_trackerd/home/FastDFS/conf/tracker.confrestart

查看启动结果

通过ps-ef|grepfdfs命令查看启动结果

通过日志查看,tracker相关日志在上面配置的base_path目录中

storage安装

配置storager.conf文件

 tracker.conf默认安装在/etc/fdfs

3.将storage.conf文件复制到FastDFS/conf目录下

cp/etc/fdfs/storage.conf/home/FastDFS/conf

4.修改storage.conf配置

●group_name为storage的组名默认为group1

●port为storage服务的端口,默认为23000

●base_path为storedata与log存放路径.建议与tracker的base_path相同.根据实际情况修改.若该路径不存在请新建

●store_path0配置

●tracker_server配置tracker的服务地址与端口

storage启动

执行命令(下面分别是启动,停止,重启命令)

fdfs_storaged/home/FastDFS/conf/storage.confstart

fdfs_storaged/home/FastDFS/conf/storage.confstop

fdfs_storaged/home/FastDFS/conf/storage.confrestart

查看启动结果

通过ps-ef|grepfdfs可以查看

storage相关日志在上面配置的base_path目录中

上传文件测试

上传一个图片到服务器

client.conf配置

1.从/etc/fdfs中将client.conf复制到/home/FastDFS/conf目录下

命令:

cp/etc/fdfs/client.conf/home/FastDFS/conf

1.修改client.conf配置

●base_path路径为日志存放路径根据实际情况修改

●tracker_server为reacker的服务地址端口

执行上传命令

fdfs_upload_file/home/FastDFS/conf/client.conf/home/test.png

返回group1/M00/00/00/CiiKglht8AqAFH25AAAFrp2NTkE935.png

到路径/home/FastDFS/data/data/00/00下可以看到刚刚上传的图片文件

/home/FastDFS/conf/client.conf为上面修改后的client.conf文件绝对路径

/home/test.png为图片的绝对路径

Nginx-Mod安装

FastDFS4.05版本后由于作者重构了代码,不再支持HTTP服务,作提供FastDFS的Nginx模块,通过Nginx服务可以支持HTTP服务

在tracker上安装的nginx主要为了提供http访问的反向代理、负载均衡以及缓存服务。

在storage上安装的nginx主要为了提供http的访问服务,同时解决group中storage服务器的同步延迟问题。

Nginx安装

Nginx安装详见Nginx安装指南-CentOS.docx

Storage下的Ngnix模块安装

storage下ngnix安装需要使用fastdfs-nginx-module_v1.16.tar.gz包

1.上传fastdfs-nginx-module_v1.16.tar.gz至/usr/local目录下

2.解压fastdfs-nginx-module_v1.16.tar.gz

执行命令tar–zxvffastdfs-nginx-module_v1.16.tar.gz

3.配置nginx

到ngnix安装目录/usr/local/nginx-1.9.9(根据实际情况选择)下,

执行命令

./configure--prefix=/home/nginx/nginx--add-module=/usr/local/fastdfs-nginx-module/src

出现下面类容说明配置成功

4.编译执行命令make

出现下面类容说明编译成功

5.安装执行命令makeInstall

6.将FastDFS的nginx插件模块的配置文件copy到FastDFS配置文件目录

cp/usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

修改Nginx配置

1.修改nginx.conf文件

在/home/nginx/nginx/conf文件夹下

设置添加storage信息并保存

 将server段中的listen端口号改为8080:

 listen      8080; 

      在server段中添加:

 location/group1/M00{

                                   root/home/FastDFS/data/data;

                                   ngx_fastdfs_module;}

2.修改mod_fastdfs.conf文件

编辑/etc/fdfs配置文件目录下mod_fastdfs.conf文件,设置storage信息并保存

base_path=/home/FastDFS/data               #保存日志目录 

tracker_server=10.40.138.132:

22122  #tracker服务器的IP地址以及端口号

storage_server_port=23000                          #storage服务器的端口号

group_name=group1                                                   #当前服务器的group名 

url_have_group_name=true       #文件url中是否有group名 

store_path_count=1               #存储路径个数,需要和store_path个数匹配

store_path0=/home/FastDFS/data       #存储路径 

group_count=1                #设置组的个数 在末尾增加组的具体信息:

 

[group1]

      group_name=group1 

      storage_server_port=23000

      store_path_count=1

      store_path0=/fdfs/storage   

启动Ngnix

进入/home/nginx/nginx/sbin

执行./nginx

浏览器中打开http:

//10.40.138.130:

8080/地址,出现下图则启动成功

上传文件Http访问测试

参考上面storage上传文件,获取到文件ID

浏览器中可以成功打开

http:

//10.40.138.130:

8080/group1/M00/00/00/CiiKglhvDqSAcHisAPuztEDxNhY272.mp4

tracker下的Ngnix模块安装

注意trackernginx插件是nginx cache purge不是storage那里的model模块

1.将nginx cache purge上传至tracker服务器/usr/local,解压

2.进入Nginx目录安装目录

3.执行命令

运行./configure进行安装前的设置,主要设置安装路径、nginx cache purge件模块

./configure --prefix=/home/nginx/nginx --add-module=/usr/local/ngx_cache_purge-2.3

make

makeinstall

4.配置:

 nginx.conf,/home/nginx/nginx下设置负载均衡和缓存:

worker_processes 4;

 

#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;

       server_names_hash_bucket_size128;

        client_header_buffer_size32k;     

        large_client_header_buffers432k;

        client_max_body_size300m;

        sendfile       on;

        tcp_nopush                   on;

        proxy_redirectoff; 

        proxy_set_headerHost$http_host;

        proxy_set_headerX-Real-IP$remote_addr; 

        proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;    

        proxy_connect_timeout90;    

        proxy_send_timeout90;    

        proxy_read_timeout90;

        proxy_buffer_size16k;    

        proxy_buffers464k;

       proxy_busy_buffers_size128k;

        proxy_temp_file_write_size128k; 

 

       proxy_cache_path /var/cache/nginx/proxy_cache levels=1:

2 keys_zone=http-cache:

500mmax_size=10ginactive=30d;    

        proxy_temp_path/var/cache/nginx/proxy_cache/tmp;

       

   upstreamfdfs_group1{

           server10.40.138.130:

8080weight=1max_fails=2fail_timeout=30s;

    }

  

 

   server{

       listen      8080;

       server_name localhost;

 

    location/group1/M00{            

       proxy_next_upstreamhttp_502http_504errortimeoutinvalid_header;proxy_cachehttp-cache;             

       proxy_cache_valid 20030412h;           

       proxy_cache_key$uri$is_args$args;           

            proxy_passhttp:

//fdfs_group1;

            expires30d;

       }

 

      

        location~/purge(/.*){

            allow127.0.0.1; 

            denyall;

             proxy_cache_purgehttp-cache $1$is_args$args;

        }

   

    }

 

}

 

5.启动nginx ,测试服务

浏览器打开http:

//10.40.138.132:

8080/group1/M00/00/00/CiiKglhvDqSAcHisAPuztEDxNhY272.mp4

FAQ

问题一:

安装nginx-modle时,会报错,需要修改modle的config文件:

            cd/usr/local/fastdfs-nginx-module/src

            将CORE_INCS="$CORE_INCS/usr/include/fastdfs/usr/include/fastcommon/" 中的local去掉。

 

问题二:

 启动nginx时会出现http.conf或者mime.type无法找到,需要复制FastDFS这2个文件到/etc/fdfs下:

cp/home/FastDFS/conf/mime.types/etc/fdfs/

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2