Docker安装部署FastDFS详细过程

您所在的位置:网站首页 kali镜像文件的安装过程 Docker安装部署FastDFS详细过程

Docker安装部署FastDFS详细过程

2023-06-28 08:24| 来源: 网络整理| 查看: 265

FastDFS分布式文件存储的由来: 在我们的项目中有很多需要存储的内容出现,比如图片,视频,文件等等,在早期的时候用户量不大,产生的文件也不是很多,这时我们可以把文件和服务程序放在一个服务器中。随着文件越来越多,服务器的资源会被文件资源大量占据,从而影响到服务器的稳定,这时我们可以单独的把文件服务器拆出来。拆解出来后,文件服务的使用不会影响到我们的系统服务的稳定,但是当用户量越来越大,存储的文件就会越来越多,这时如果还是单台的文件服务,比如1000T的文件,这时是存储不下去的,这时就产生了我们将的分布式文件存储。也就是我们解决如何将这1000T的文件分散的存储到各个节点上,然后当我们需要读取文件的时候又能非常快的帮我们把文件找到。这个就是分布式文件系统帮我们解决的问题了。 1.先去docker hub寻找镜像文件 docker search fastdfs

在这里插入图片描述

2.拉取镜像文件 docker pull delron/fastdfs 3.通过Docker命令来创建Tracker服务 # 先创建文件夹 mkdir /mydata/fastdfs/tracker cd /mydata/fastdfs/tracker # 执行docker命令 docker run -d --name tracker --network=host -v /mydata/fastdfs/tracker:/var/fdfs delron/fastdfs tracker # 注意:tracker服务默认的端口为22122 4.通过Docker命令构建构建Storage服务 # 创建文件夹 mkdir /mydata/fastdfs/storage cd /mydata/fastdfs/storage # 执行命令 docker run -d --name storage --network=host -e TRACKER_SERVER=x.x.x.x:22122 -v /mydata/fastdfs/storage:/var/fdfs -e GROUP_NAME=group1 delron/fastdfs storage # 注意:其中TRACKER_SERVER中的ip要修改为你的Tracker服务所在的服务IP地址

默认情况下在Storage服务中是帮我们安装了Nginx服务的,相关的端口为:

服务 默认端口 tracker 22122 storage 23000 Nginx 8888 5.配置文件的查看&根据要求自行修改(比如端口冲突)

注意:如果要修改端口或者端口冲突了,下面这俩个配置文件都要修改。

[root@VM-4-9-centos ~]# docker exec -it storage /bin/bash [root@VM-4-9-centos nginx-1.12.2]# ls CHANGES CHANGES.ru LICENSE Makefile README auto conf configure contrib html man objs src [root@VM-4-9-centos nginx-1.12.2]# cd / [root@VM-4-9-centos /]# ls anaconda-post.log bin dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var [root@VM-4-9-centos /]# cd etc/fdfs/ [root@VM-4-9-centos fdfs]# ls client.conf http.conf mod_fastdfs.conf storage.conf.sample storage_ids.conf.sample tracker.conf.sample client.conf.sample mime.types storage.conf storage_ids.conf tracker.conf [root@VM-4-9-centos fdfs]# cat storage.conf

在这里插入图片描述

[root@VM-4-9-centos fdfs]# cd /usr/local/nginx [root@VM-4-9-centos nginx]# ll total 36 drwx------ 2 nobody root 4096 Oct 25 14:47 client_body_temp drwxr-xr-x 1 root root 4096 Apr 29 2018 conf drwx------ 2 nobody root 4096 Oct 25 14:47 fastcgi_temp drwxr-xr-x 2 root root 4096 Apr 29 2018 html drwxr-xr-x 1 root root 4096 Oct 25 14:47 logs drwx------ 2 nobody root 4096 Oct 25 14:47 proxy_temp drwxr-xr-x 2 root root 4096 Apr 29 2018 sbin drwx------ 2 nobody root 4096 Oct 25 14:47 scgi_temp drwx------ 2 nobody root 4096 Oct 25 14:47 uwsgi_temp [root@VM-4-9-centos nginx]# cd conf/ [root@VM-4-9-centos conf]# ls fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params win-utf fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_params.default [root@VM-4-9-centos conf]# cat nginx.conf

在这里插入图片描述

6.测试图片上传 6.1 首先在虚拟机的/mydata/fastdfs/storage下保存一张图片,通俗xftp直接上传

在这里插入图片描述

6.2 进入storage 容器,执行上传文件的命令 [root@VM-4-9-centos storage]# docker exec -it storage bash [root@VM-4-9-centos nginx-1.12.2]# cd /var/fdfs/ [root@VM-4-9-centos fdfs]# ls 1.jpg logs data [root@VM-4-9-centos fdfs]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf 1.jpg group1/M00/00/00/CgoMS2SaUPKASQSrAAFSK1nBHGM554.png 上传文件的指令 /usr/bin/fdfs_upload_file /etc/fdfs/client.conf 1.jpg上传成功后根据返回的地址在浏览器中进行访问返回的路径 group1/M00/00/00/CgoMS2SaUPKASQSrAAFSK1nBHGM554.png 6.3 浏览器地址栏中输入地址,直接访问

http://ip地址:8888/group1/M00/00/00/CgoMS2SaUPKASQSrAAFSK1nBHGM554.png 成功访问:

在这里插入图片描述



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3