FastDFS的实现

2018-02-22 20:08:09来源:cnblogs.com作者:shenxm人点击

分享

FastDFS的实现

环境

    centos7.1节点提供tracker和storage服务    centos7.2,centos7.3只提供storage服务

FastDFS的实现

    fastdfs-5.0.11-1.el7.centos.x86_64.rpm #主程序    fastdfs-debuginfo-5.0.11-1.el7.centos.x86_64.rpm #debug先关的包    fastdfs-server-5.0.11-1.el7.centos.x86_64.rpm #提供tracker和storage节点的服务    fastdfs-tool-5.0.11-1.el7.centos.x86_64.rpm #工具包    libfastcommon-1.0.36-1.el7.centos.x86_64.rpm #下面四个是依赖的包    libfastcommon-devel-1.0.36-1.el7.centos.x86_64.rpm    libfdfsclient-5.0.11-1.el7.centos.x86_64.rpm    libfdfsclient-devel-5.0.11-1.el7.centos.x86_64.rpm    nginx-1.10.2-1.el7.centos.x86_64.rpm  #使用nginx做为web界面需要用到的包    nginx-all-modules-1.10.2-1.el7.centos.noarch.rpm    nginx-filesystem-1.10.2-1.el7.centos.noarch.rpm    nginx-mod-http-geoip-1.10.2-1.el7.centos.x86_64.rpm    nginx-mod-http-image-filter-1.10.2-1.el7.centos.x86_64.rpm    nginx-mod-http-perl-1.10.2-1.el7.centos.x86_64.rpm    nginx-mod-http-xslt-filter-1.10.2-1.el7.centos.x86_64.rpm    nginx-mod-mail-1.10.2-1.el7.centos.x86_64.rpm    nginx-mod-stream-1.10.2-1.el7.centos.x86_64.rpm    1》安装        yum  localinstall ./* #安装软件        cd /etc/fdfs/ ;ls  #发现有很多示例        anti-steal.jpg  client.conf.sample  http.conf  mime.types  storage.conf.sample  storage_ids.conf.sample  tracker.conf.sample    2》在centos7.1节点上配置tracker节点        cd /etc/fdfs/        cp tracker.conf.sample tracker.conf.sample.bak        mv tracker.conf.sample tracker.conf        vim tracker.conf            base_path=/app/fastdfs/tracker #设置tracker的存储路径            store_group=shen #设置一个存储组,注意不能带任何符号,不然会出现端口启用不了        mkdir -pv /app/fastdfs/tracker #在centos7.1节点上创建tracker的数据目录        mkdir /app/fastdfs/storage #创建storage的存储目录    3》在centos7.2和7.3节点上只创建storage的存储目录        mkdir /app/fastdfs/storage -pv    4》在三个节点上对storage进行配置        cd /etc/fdfs/        cp storage.conf.sample storage.conf.sample.bak        mv storage.conf.sample storage.conf        vim storage.conf            group_name=shen            base_path=/app/fastdfs/storage #storage的基础路径,用于存储日志等            store_path0=/app/fastdfs/storage #storage的存储路径,这个必须设置,可以和上面的在同一个目录下             tracker_server=192.168.213.251:22122 #指明tracker主机        在centos7.1节点上启动tracker和storage服务            systemctl start fdfs_trackerd              systemctl start fdfs_storaged          ss  -nltp  #发现tracker监听的端口是22122,storage监听的端口是23000        在centos7.2和7.3节点上启动storage服务            systemctl start fdfs_storaged             ss -nlt #发现23000端口已经打开    5》配置客户端的配置文件,在centos7.1节点设置        cd /etc/fdfs/ ;ls            anti-steal.jpg      http.conf   storage.conf             storage_ids.conf.sample  tracker.conf.sample.bak            client.conf.sample  mime.types  storage.conf.sample.bak  tracker.conf        cp client.conf.sample client.conf.bak        mv client.conf.bak client.conf        vim client.conf            base_path=/app/fastdfs/tracker            tracker_server=192.168.213.251:22122        fdfs_monitor /etc/fdfs/client.conf #可以查看存储节点的状态信息    6》文件的上传和查看操作        cd /etc/fdfs/ ;ls            anti-steal.jpg  client.conf.sample  mime.types    storage.conf.sample.bak  tracker.conf            client.conf     http.conf           storage.conf  storage_ids.conf.sample  tracker.conf.sample.bak        fdfs_upload_file /etc/fdfs/client.conf /app/flower.jpg #注意上传时要指明客户端的配置文件            shen/M00/00/00/wKjV-1o01sOAHG17AAAN9EUC0YY902.jpg        cd /app/fastdfs/storage/data/00/00/  ;ls    #每个节点的此目录下都有这个文件,说明同步成功            wKjV-1o01sOAHG17AAAN9EUC0YY902.jpg        fdfs_file_info /etc/fdfs/client.conf shen/M00/00/00/wKjV-1o01sOAHG17AAAN9EUC0YY902.jpg #查看文件            source storage id: 0            source ip address: 192.168.213.251            file create timestamp: 2017-12-16 16:18:11            file size: 3572            file crc32: 1157812614 (0x4502D186)        fdfs_test /etc/fdfs/client.conf upload /root/anaconda-ks.cfg  #上传测试        fdfs_upload_file /etc/fdfs/client.conf  /root/anaconda-ks.cfg #上传文件            magedu/M00/00/00/rBIVB1oylFSADeGrAAAHXGXWizs514.cfg        fdfs_download_file /etc/fdfs/client.conf magedu/M00/00/00/rBIVB1oylFSADeGrAAAHXGXWizs514.cfg #下载文件到当前目录

FastDFS实现nginx代理

    1》在centos7.1节点安装nginx的相关包,注意要安装nginx-1.10版本,不然可能没有ngx_fastdfs_module模块,如果之前已经安装nginx及相应的依赖包,最好先卸载了        cd /app        ls #将nginx-1.10.2版本的nginx及相应的依赖包下载到本地            nginx-1.10.2-1.el7.centos.x86_64.rpm #注意版本要统一都是1.10.2的版本            nginx-all-modules-1.10.2-1.el7.centos.noarch.rpm #下面这些都是nginx的依赖包            nginx-filesystem-1.10.2-1.el7.centos.noarch.rpm             nginx-mod-http-geoip-1.10.2-1.el7.centos.x86_64.rpm            nginx-mod-http-image-filter-1.10.2-1.el7.centos.x86_64.rpm            nginx-mod-http-perl-1.10.2-1.el7.centos.x86_64.rpm            nginx-mod-http-xslt-filter-1.10.2-1.el7.centos.x86_64.rpm                nginx-mod-mail-1.10.2-1.el7.centos.x86_64.rpm            nginx-mod-stream-1.10.2-1.el7.centos.x86_64.rpm        yum install ./nginx*    2》修改nginx的配置文件        vim /etc/nginx/nginx.conf            location /magedu/M00 { #表示匹配以 /magdu/M00开头的uri                      root /app/fastdfs/storage; #指明数据存储的目录                        ngx_fastdfs_module;            }        nginx            ngx_http_fastdfs_set pid=14594        ss -nlt    3》修改fastdfs_module配置文件的设置        vim /etc/fdfs/mod_fastdfs.conf             url_have_group_name = true #是否允许访问的url中包含组名            store_path0=/app/fastdfs/storage #指明storage节点存储数据的目录            tracker_server=172.18.21.107:22122 #指明tracker节点            group_name=magedu #指明组名    4》测试        fdfs_upload_file /etc/fdfs/client.conf /app/sunset.jpg #上传一个文件            magedu/M00/00/00/rBIVa1ozvNWAJLHkAAAKwLGLsZc035.jpg            访问如下网站就可以看到存储的图片            http://172.18.21.107/magedu/M00/00/00/rBIVa1ozvNWAJLHkAAAKwLGLsZc035.jpg

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台