docker 中安装 FastDFS 总结
如题,参考各资料后,安装FastDFS总结。基于已有docker镜像
https://hub.docker.com/r/luhuiguo/fastdfs/
docker pull luhuiguo/fastdfs
luhuiguo/fastdfs:latest
原:
docker run -dti --network=host --name tracker -v /var/fdfs/tracker:/var/fdfs luhuiguo/fastdfs tracker
改:
docker run -dti --privileged=true --network=host --name aps-fastdfs-trakcer -v /var/fdfs/tracker:/var/fdfs -p 22122:22122 luhuiguo/fastdfs trakcer
Ok: 跟踪器
sudo docker run -dti --privileged=true --net=host --name aps-fastdfs-trakcer -v /var/fdfs/tracker:/var/fdfs -p 22122:22122 luhuiguo/fastdfs trakcer
主:host的网络方式 相当于 宿主直接映射22122, 所以容器里面查不到ip
存储器原:
docker run -dti --network=host --name storage0 -e TRACKER_SERVER=10.1.5.85:22122 -e -v /var/fdfs/storage0:/var/fdfs luhuiguo/fastdfs storage
改:
sudo docker run -dti --privileged=true --net=host --name aps-fastdfs-storage -e TRACKER_SERVER=172.16.16.201:22122 -v /var/fdfs/storage:/var/fdfs luhuiguo/fastdfs storage
参考:
docker run -t -i --privileged=true --name="aps-fastdfs-trakcer" -p 22122:22122 john123951/fastdfs_tracker
此镜像配置:
跟踪器:
配置文件: /etc/fdfs
核心脚本: /usr/bin ls |grep fd fdfs_upload_file脚本
管理脚本: /usr/bin fdfs_storaged fdfs_trackerd
数据日志目录: /var/fdfs
lib文件:/usr/lib libfastcommon.so、libfdfsclient.so 配置nginx module时用到
/usr/lib64
include目录: /usr/include fastcommon、fastdfs 目录 配置nginx module时用到
存储器:
配置文件: /etc/fdfs
核心脚本: /usr/bin ls |grep fd fdfs_upload_file脚本
管理脚本: /usr/bin fdfs_storaged fdfs_trackerd
数据日志目录: /var/fdfs 注意没有后面的 tracker或 storage
lib文件:/usr/lib libfastcommon.so、libfdfsclient.so
/usr/lib64
include目录: /usr/include fastcommon、fastdfs 目录
测试上传:
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /home/zhanghui.txt
返回结果
group1/M00/00/00/rBAQyVk_g0aAG_iEAABEkzPAQWA637.jpg 最新测试结果
当配置好fastdfs-nginx-module之后
可以这样访问
http://172.16.16.201:8888/group1/M00/00/00/rBAQyVk_g0aAG_iEAABEkzPAQWA637.jpg
6>查看当前目录下user目录的大小,并不想看其他目录以及其子目录:
du -sh user
使用FastDFS遇到问题记录:
Q1.通过命令行上传文件时出现错误:tracker_query_storage_fail,error no:28, error info No space left on device
——2010-7-27已解决
原因:tracker.conf的配置项reserved_storage_space的值默认为4GB,而当前环境下剩余空间已不足4GB。
解决:根据实际空间情况修改配置项reserved_storage_space的值。
修改成500M已经可以
Q2.通过JavaAPI上传文件时出现错误:Java.lang.Exception: getStoreStorage fail, errno code :2
——2010-7-28已解决
原因:由于某种原因(重启或网络原因等)导致tracker认为storage服务器还没准备好。
解决:稍待片刻,等storage服务器向tracker服务器发送心跳后即可。
监控日志:
fdfs_monitor /etc/fdfs/storage.conf
正常:
Storage 1:
id = 172.16.16.201
ip_addr = 172.16.16.201 (localhost.localdomain) ACTIVE
不正常:
Storage 1:
id = 172.16.16.201
ip_addr = 172.16.16.201 (localhost.localdomain) OFFLINE
重启跟踪器:
/usr/bin/restart.sh /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
重启存储器
/usr/bin/restart.sh /usr/bin/fdfs_storaged /etc/fdfs/storage.conf
每个存储节点安装nginx模块
fastdfs-nginx-module_v1.16.tar.gz
存放目录: /usr/local/src
下载:
fastdfs-nginx-module:
http://172.16.16.201:5186/down/fastdfs-nginx-module-master.zip
换一个版本
http://172.16.16.201:5186/down/fastdfs-nginx-module_v1.15.tar.gz (这个版本可以,编译不会报错)
nginx:
http://172.16.16.201:5186/down/nginx-1.12.0.tar.gz (安装报错,应该不是这个的问题,是fastdfs-nginx-module版本的问题)
wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
#修改模块中对应的路径,要不然模块不能正确安装加载
cd fastdfs-nginx-module/src
vi config #更改如下, 去掉local,并指定lib64(64系统)
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/lib64 -lfastcommon -lfdfsclient"
添加fastdfs-nginx-module模块:
./configure --add-module=/home/soft/fastdfs-nginx-module/src
换目录
./configure --add-module=/usr/local/src/fastdfs-nginx-module/src
配置完毕,安装过程中会提示很多not found和 found,忽略
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
安装:
make && make install
检查安装:
/usr/local/nginx/sbin/nginx -V
复制 fastdfs-nginx-module 源码中的配置文件到/etc/fdfs 目录,并修改
cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
vi /etc/fdfs/mod_fastdfs.conf
复制 FastDFS 的部分配置文件到/etc/fdfs 目录
cd /usr/local/src/FastDFS/conf
cp http.conf mime.types /etc/fdfs/
在/fastdfs/storage 文件存储目录下创建软连接,将其链接到实际存放数据的目录
ln -s /var/fdfs/data/ /var/fdfs/data/M00
nginx 配置
user root;
worker_processes ; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections ;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout ;
keepalive_timeout ; #gzip on; server {
listen ;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location ~/group([-])/M00 {
ngx_fastdfs_module;
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen ;
# listen somename:;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
user root;
server {
listen 8888;
location ~/group([0-9])/M00 {
ngx_fastdfs_module;
}
启动nginx
/usr/local/nginx/sbin/nginx
注:重启 Nginx 的命令为:/usr/local/nginx/sbin/nginx -s reload
测试:
本地:
http://127.0.0.1:8888/group1/M00/00/00/rBAQyVk-OouAeQFzAAAAIpJOfic350.txt
让其他电脑能访问:开放端口 端口映射
因为这个容器的网络是 是 --network=host,所以需要对 8888端口暴露出来。
经过测试发现这种方式的端口不用特殊配置,直接给外面用。
即不用配置直接可以访问
http://172.16.16.201:8888/group1/M00/00/00/rBAQyVk-OouAeQFzAAAAIpJOfic350.txt
docker 中安装 FastDFS 总结的更多相关文章
- docker中的fastdfs
准备环节)(本文遗漏当初出现的一个问题由于是docker装的fastdfs所以tracker storage client,nginx,nginx module都在同一个容器中只需要修改配置 特别注意 ...
- 在docker中安装mysql
#!/bin/sh # 安装docker # 在docker中安装mysql # 解决了docker容器中无法输入中文的问题 ##########################安装docker # ...
- 在Docker中安装配置Oracle12c并实现数据持久化
在Docker中安装配置Oracle12c并实现数据持久化 选定镜像,并pull到系统中,一定要先配置加速,不然超级慢 eric@userver:~$ docker pull sath89/oracl ...
- 在Docker中安装.NET Core(使用命令行工具)
在Docker中安装.NET Core目前共有两种方法:1,使用命令行工具安装2,使用VS2017来安装 本文主要介绍使用命令行工具来安装: 1,安装Docker(如果本机已经有Docker环境,可以 ...
- 在Docker中安装和部署MongoDB集群
此文已由作者袁欢授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 在Docker中安装mongodb 采用的mongodb镜像:https://registry.hub.doc ...
- docker微服务部署之:四、安装docker、docker中安装mysql和jdk1.8、手动构建镜像、部署项目
docker微服务部署之:三,搭建Zuul微服务项目 1.Centos7安装Docker 详见:Centos7安装Docker 2.Docker中安装jdk1.8 详见:使用Docker构建jdk1. ...
- docker中安装宝塔面板
我的电脑是win10,安装的virtualbox其上装的ubutun14,ubutun也安装了docker,今天我补充一个完整的操作流程.怎么在docker中安装宝塔面板?先打个岔,这些命令总是记不住 ...
- docker中安装宝塔面板教程
本人电脑是win10,安装的virtualbox,装的centos7.2,在centos7.2装了docker,这个比较简单,网上一大堆教程,今天说一下装好了docker之后怎么在docker中安装面 ...
- 在Docker中安装MongoDB
在Docker中安装MongoDB docker run -p 27017:27017 -v /data/mongodb:/data/db --name mongodb -d mongo --auth ...
随机推荐
- js调用打印机 打印整体或部分
有时前端的项目中需要添加打印的功能,首先要知道打印分为整体打印和局部打印两种,而局部打印又可细分为局部打印指定的部分,和局部打印指定部分之外的部分.实例比文字看起来更清晰,下面我将用代码来描述 1.整 ...
- [Java基础]List,Map集合总结
java.util包下: Collection |--List 接口 |----ArrayList |----LinkedList |----Vector |-----Stack |---Set ...
- 使用vs远程调试iis站点
在vs安装目录下IDE文件夹下的Remote Debugger 复制到服务器运行 启动msvsmon.exe msvsmon.exe启动后设置远程连接不验证身份 vs中 调试→附加到进程 ip+端口访 ...
- 从1KW条数据中筛选出1W条最大的数
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using S ...
- Ant + ivy的安装
有了Ivy的帮忙,我们不需要为了一个库依赖管理而舍弃Ant去学那个难搞的Maven了. 基本配置步骤如下: 1.copy Ivy插件到ant_home/lib下: ivy安装 简单的安装方法: 直 ...
- cisco asa5510 配置
anyconnect 查看vpn链接 ASA版本8.4(7) anyconnect版本3.1 亲测sh vpn-sessiondb anyconnect 查看登录用户详情sh vpn-ses ...
- xjc编码
本篇文章是对jaxb xjc编码的问题进行了详细的分析介绍,需要的朋友参考下 平时喜欢根据写一个xjc批处理命令,根据xsd批量生成java类,觉得很方便也很酷.但是有时候xsd生成的java类中 ...
- Atitit. 注册表操作查询 修改 api与工具总结 java c# php js python 病毒木马的原理
Atitit. 注册表操作查询 修改 api与工具总结 java c# php js python 病毒木马的原理 1. reg 工具 这个cli工具接口有,优先使用,jreg的要调用dll了,麻烦的 ...
- springboot文件上传下载,转载的
Spring Boot入门——文件上传与下载 原文来自:https://www.cnblogs.com/studyDetail/articles/7003253.html 1.在pom.xml文件中添 ...
- C++语言基础(25)-C++格式化输出
一.使用控制符控制输出格式 #include <iostream> #include <iomanip>//不要忘记包含此头文件 using namespace std; in ...