docker search fastdfs
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/season/fastdfs FastDFS 39 docker.io docker.io/luhuiguo/fastdfs FastDFS is an open source high performance... 17 [OK] docker.io docker.io/morunchang/fastdfs A FastDFS image 9 docker.io docker.io/ygqygq2/fastdfs-nginx 整合了nginx的fastdfs 4 [OK] docker.io docker.io/lionheart/fastdfs-tracker just have a try on autobuilded -_-# 3 [OK] docker.io docker.io/imlzw/fastdfs-tracker fastdfs的tracker服務 2 [OK] docker.io docker.io/qbanxiaoli/fastdfs FastDFS單機版 2 [OK] docker.io docker.io/appcrash/fastdfs_nginx fastdfs with nginx 1 docker.io docker.io/delron/fastdfs 1 docker.io docker.io/evan1120/fastdfs_storage The fastdfs storage image 1 [OK] docker.io docker.io/evan1120/fastdfs_tracker The fastdfs tracker docker image, only con... 1 [OK] docker.io docker.io/imlzw/fastdfs-storage fastdfs的storage服務 1 [OK] docker.io docker.io/imlzw/fastdfs-storage-dht fastdfs的storage服務,並且集成了fastdht的服務,實現文件排重 1 [OK] docker.io docker.io/john123951/fastdfs_storage fastdfs storage 1 [OK] docker.io docker.io/lionheart/fastdfs-storage 更加規范的Dockerfile,能夠自動構建了。 1 [OK] docker.io docker.io/lionheart/fastdfs_storage the fastdfs file system's storage node 1 docker.io docker.io/lionheart/fastdfs_tracker fastdfs file system‘s tracker node 1 docker.io docker.io/ecarpo/fastdfs-storage 0 docker.io docker.io/john123951/fastdfs_tracker fastdfs tracker 0 [OK] docker.io docker.io/manuku/fastdfs-fastdht fastdfs fastdht 0 [OK] docker.io docker.io/manuku/fastdfs-storage-dht fastdfs storage dht 0 [OK] docker.io docker.io/manuku/fastdfs-storage-proxy fastdfs storage proxy 0 [OK] docker.io docker.io/manuku/fastdfs-tracker fastdfs tracker 0 [OK] docker.io docker.io/mypjb/fastdfs this is a fastdfs docker project 0 [OK] docker.io docker.io/tsl0922/fastdfs FastDFS is an open source high performance... 0 [OK]
2.下載鏡像文件
docker pull morunchang/fastdfs
3.安裝tracker跟蹤器容器
docker run -d --name tracker --restart=always --net=host morunchang/fastdfs sh tracker.sh
tracker容器使用host網絡,docker容器中的幾種網絡模式,這里就不介紹了,后面有時間進行補充。
4.進入tracker容器
docker exec -it tracker /bin/bash
修改文件 nginx.conf
vi /etc/nginx/conf/nginx.conf
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 0; keepalive_timeout 65; #gzip on; server { listen 8089; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } location ~ /M00 { root /data/fast_data/data; ngx_fastdfs_module;
...................
這里是nginx監聽tracker的端口號,即tracker的訪問端口號,不過,需要直接訪問tracker么?
修改文件client.conf
vi /etc/fdfs/client.conf . . # the base path to store log files base_path=/data/fast_data # tracker_server can ocur more than once, and tracker_server format is # "host:port", host can be hostname or ip address tracker_server=x.x.x.x:22122 #這里的這個IP是你本地/服務器的ip,端口號tracker的端口號,你需要自己指定,但是需要跟tracker.conf文件中的端口號一致。 # specify storage ids filename, can use relative or absolute path # same as tracker.conf # valid only when load_fdfs_parameters_from_tracker is false # since V4.05 storage_ids_filename = storage_ids.conf #HTTP settings http.tracker_server_port=8089 #use "#include" directive to include HTTP other settiongs ##include http.conf 這里的端口號是tracker的訪問端口號,和上面的22122不是一個。
修改文件tracker.conf
vi /etc/fdfs/tracker.conf ...... disabled=false # bind an address of this host # empty for bind all addresses of this host bind_addr= # the tracker server port port=22122 #這個端口號是tracker的端口號。 # connect timeout in seconds # default value is 30s connect_timeout=30 connection_pool_max_idle_time = 3600 # HTTP port on this tracker server http.server_port=8089 這個是tracker的監聽端口號,http訪問的端口號。好像該不該都無所謂 # check storage HTTP server alive interval seconds # <= 0 for never check # default value is 30 http.check_alive_interval=30
5.退出容器
6.安裝storage儲存器容器
現在/home下面創建文件夾
[root@0007 ~]# mkdir -p /home/docker/fastdfs/storage/
docker run -d --name storage --net=host --restart=always -e TRACKER_IP=189.215.159.153:22122 -v /home/docker/fastdfs/storage:/data/fast_data -e GROUP_NAME=group1 morunchang/fastdfs sh storage.sh #IP建議用公網ip,私網的ip網絡進入不了
注意:這里的端口號是tracker容器的ip和端口號,不是tracker的http訪問的端口號。
進入容器
docker exec -it storage /bin/bash 修改文件nginx.conf vi /etc/nginx/conf/nginx.conf
.... ... 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 0; keepalive_timeout 65; #gzip on; server { listen 8080; #######支持https########### #listen 443 ssl; #server_name xx.xxxxx.com; #ssl on; #ssl_certificate /etc/nginx/cert/211131438400047.pem; #必須得先把這兩個證書准備好 #ssl_certificate_key /etc/nginx/cert/211131438400047.key; #ssl_session_timeout 5m; #ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #ssl_prefer_server_ciphers on; #######支持https########### #這里是storage容器的監聽端口號。 #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; }
為了支持https需要在容器里面做一下操作
apt-get update git clone https://github.com/happyfish100/libfastcommon.git git clone https://github.com/happyfish100/fastdfs-nginx-module.git cd libfastcommon/ ./make.sh ./make.sh install apt-get install wget wget http://nginx.org/download/nginx-1.13.12.tar.gz tar -xvf nginx-1.13.12.tar.gz mv nginx-1.13.12 nginx cd nginx apt-get install openssl libssl-dev ./configure --prefix=/etc/nginx --add-module=/data/fastdfs-nginx-module/src --with-http_stub_status_module --with-http_ssl_module make make install /etc/nginx/sbin/nginx -v
/etc/nginx/sbin/nginx -s reload
查看是否已經監聽443端口
root@0005:/# ss -tnpl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22122 *:* LISTEN 0 128 *:6379 *:* LISTEN 0 128 *:111 *:* LISTEN 0 128 *:8080 *:* users:(("nginx",pid=6396,fd=6)) LISTEN 0 128 *:22 *:* LISTEN 0 128 *:23000 *:* users:(("fdfs_storaged",pid=13,fd=5)) LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 *:443 *:* users:(("nginx",pid=6396,fd=7)) LISTEN 0 1 127.0.0.1:32000 *:* LISTEN 0 128 :::6379 :::* LISTEN 0 128 :::111 :::* LISTEN 0 128 :::22 :::* LISTEN 0 128 :::15671 :::* LISTEN 0 128 :::15672 :::* LISTEN 0 100 ::1:25 :::* LISTEN 0 128 :::5671 :::* LISTEN 0 128 :::5672 :::* LISTEN 0 128 :::25672 :::* root@0005:/#
以上443端口已經監聽,已經支持https形式
修改文件client.conf
vi /etc/fdfs/client.conf #不再本容器測試就不用改
tracker容器的訪問端口號
修改文件storage的storage.conf
vi /etc/fdfs/storage.conf client_bind=true # the storage server port port=23000 # connect timeout in seconds # default value is 30s . . . connection_pool_max_idle_time = 3600 # use the ip address of this storage server if domain_name is empty, # else this domain name will ocur in the url redirected by the tracker server http.domain_name= # the port of the web server on this storage server
#storage的訪問端口號 #http.server_port=8888 http.server_port=8080
7.退出容器,重啟tracker和storage
docker restart storage tracker
netstat -tnlp #查看監聽的端口
cd /home/docker/fastdfs/storage/data/00/00/ #進入容器上傳圖片 [root@0007:/]# fdfs_test /etc/fdfs/client.conf upload xxxxx.jpg
8.報錯調整ERROR - file: tracker_proto.c, line: 48, server: 10.171.22.124:22122, response status 2 != 0
排查思路:
在tracker上使用fdfs_monitor /etc/fdfs/client.conf 命令查看storage的狀態是offline
fdfs_monitor /etc/fdfs/client.conf delete group1 storage的IP地址。 #先在tracker上刪除storage的信息。
rm -rf /data/fastdfs/data #刪除storage的數據目錄。
service fdfs_storaged restart #重啟storage
在tracker上再次使用fdfs_monitor查看storage的狀態,顯示active。上傳圖片,正常了。