ygqygq2 / fastdfs-nginx

修改 https://github.com/luhuiguo/fastdfs-docker 整合nginx
78 stars 44 forks source link

Host 模式试试的错误。 #16

Closed piaohailin closed 7 months ago

piaohailin commented 7 months ago

环境Mac Desktop Docker,镜像版本:ygqygq2/fastdfs-nginx:V6.11.0 在容器内测试成功,可以上传文件,可以用127.0.0.1浏览

因为容器内无法用应用程序链接,采用network_mode: host模式。 容器内报错如下: 1、tracker容器 [2024-02-28 01:05:19] INFO - FastDFS v6.11.0, base_path=/var/fdfs, max_connections=1024, connect_timeout=5, network_timeout=60, thread_stack_size=256 KB, max_pkg_size=256 KB, min_buff_size=8 KB, max_buff_size=256 KB, tcp_quick_ack=1, log_level=INFO, run_by_group=, run_by_user=, error-log: {sync_log_buff_interval=1, rotate_everyday=1, rotate_time=00:00, rotate_on_size=0, compress_old=0, compress_days_before=1, keep_days=0, delete_old_time=01:30}, port=22122, bind_addr=, address_family=auto, accept_threads=1, work_threads=4, store_lookup=2, store_group=, store_server=0, store_path=0, reserved_storage_space=20.00%, download_server=0, allow_ip_count=-1, check_active_interval=120s, storage_ip_changed_auto_adjust=1, storage_sync_file_max_delay=86400s, storage_sync_file_max_time=300s, use_trunk_file=0, slot_min_size=256, slot_max_size=1024 KB, trunk_alloc_alignment_size=256, trunk_file_size=64 MB, trunk_create_file_advance=0, trunk_create_file_time_base=02:00, trunk_create_file_interval=86400, trunk_create_file_space_threshold=20 GB, trunk_init_check_occupying=0, trunk_init_reload_from_binlog=0, trunk_free_space_merge=1, delete_unused_trunk_files=0, trunk_compress_binlog_min_interval=86400, trunk_compress_binlog_interval=86400, trunk_compress_binlog_time_base=03:00, trunk_binlog_max_backups=7, use_storage_id=0, id_type_in_filename=ip, trust_storage_server_id=1, storage_id/ip_count=0 / 0, store_slave_file_use_link=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s kill pid: 18 fail, errno: 3, error info: No such process 2、storage容器 ngx_http_fastdfs_set pid=14 pid file: /var/fdfs/data/fdfs_storaged.pid not exist! try to start the storage node... [2024-02-28 01:05:06] ERROR - file: fdfs_shared_func.c, line: 496, host "tracker" is invalid, error info: Unknown host [2024-02-28 01:05:06] CRIT - exit abnormally!

ygqygq2 commented 7 months ago

给你个示例,因为使用 host 网络,就无法解析 tracker 这种service 名,所以要添加 hosts,ports 映射就会失效,所以可以不用添加。

version: '3'
#networks:
#  fastdfs-net:
#    external: true
#networks:
#  fastdfs-net:
#    driver: bridge
services:
  tracker:
    container_name: tracker
    image: ygqygq2/fastdfs-nginx:latest
    command: tracker
    network_mode: host
    #networks:
    #  - fastdfs-net
    volumes:
      - /var/fdfs/tracker:/var/fdfs
    ports:
      - 22122:22122
  storage0:
    container_name: storage0
    image: ygqygq2/fastdfs-nginx:latest
    command: storage
    network_mode: host
    extra_hosts:
      - "tracker:内网IP(别用127.0.0.1)"
    #networks:
    #  - fastdfs-net
    environment:
      - TRACKER_SERVER=tracker:22122
    volumes:
      - /var/fdfs/storage0:/var/fdfs
    ports:
      - 28080:8080
    depends_on:
      - tracker
piaohailin commented 7 months ago

environment:

目前还在失败中。。。应用程序无法从 宿主机IP 连接

piaohailin commented 7 months ago

fastdfs一开始没有考虑云原生,后续在docker的项目。感觉问题很多啊。。

求一个 network_mode: host 好用的 配置文件。。。

ygqygq2 commented 7 months ago

fastdfs一开始没有考虑云原生,后续在docker的项目。感觉问题很多啊。。

求一个 network_mode: host 好用的 配置文件。。。

我上面给的就是测试过,ok 的,只不过我是单机测试。这个出来很早,那时候还没 docker 呢。我 wx 也是这个 id,可以远程给你看看。

piaohailin commented 7 months ago

我用测试程序可以连接公司环境,不过这个环境没有docker物理机安装。排出应用部分没有问题。

我的Mac 是 m2 pro。安装vm diaben 12(与宿主机正常通讯) docker安装fastdfs,标准的网桥模式。 应用程序ip是vm主机ip

Java应用测试库采用org.csource,fastdfs-client-java。这个库,在访问vm中 docker报错 Exception in thread "main" java.io.IOException: recv body length: 70 is not correct, expect length: 40 at org.csource.fastdfs.ProtoCommon.recvHeader(ProtoCommon.java:188) at org.csource.fastdfs.ProtoCommon.recvPackage(ProtoCommon.java:203)

这个错误说明找到网络服务,内部报错了。

我怀疑是不是这个docker版本的 在Mac环境下有问题?m芯片带来的问题?

ygqygq2 commented 7 months ago

那可以换个 amd64 的试试。m2 的不清楚 docker 最新的支持程度。

piaohailin commented 7 months ago

加入platform: linux/amd64 Error response from daemon: image with reference ygqygq2/fastdfs-nginx:V6.11.0 was found but does not match the specified platform: wanted linux/amd64, actual: linux/arm64

猝死中。。。

ygqygq2 commented 7 months ago

image 我测试是可以的。最新这个我是基于 ubuntu 构建的了。centos7 都不维护了

ygqygq2 commented 7 months ago

m2 还是很新的,你这个算是应用问题了,可以去问问 fastdfs 作者。我在他的群中,要不要拉你进去

piaohailin commented 7 months ago

应用成功访问了。 环境说明:Mac m系列,应用程序宿主机,Mac vm(debain)+ fastdfs + host模式(必须) 问题分析:原来使用的官方客户端版本1.29太老旧,与fastdfs版本是有匹配关系的。所以一直无法连接上。 客户端官方没有把1.31-SNAPSHOT推送中央仓库,可以手工下载编译一个版本,在JDK 21下通过编译。

在Mac Desktop Docker环境下失败,不折腾了。。。

piaohailin commented 7 months ago

还是认为不住再问一下。没有办法才用网桥模式,是不是与fastdfs内部机制有关?docker的镜像怎么折腾也无法改变这种方式吧?

ygqygq2 commented 7 months ago

是的,docker 只是提供一个运行环境,具体代码里面的报错,那是应用问题了。

piaohailin commented 7 months ago

感谢!