Nginx 跳转fastdfs存储图片地址报错问题分析过程汇总

1,问题描述

上传压缩图片报错:org.csource.common.MyException: getStoreStorage fail, errno code: 2

原因是dns域名ping不通traker,改成ip地址OK了,如下所示:

[root@localhost logs]# vim/etc/fdfs/storage_group2.conf

#tracker_server=tracker.mytest.com:22122

tracker_server=192.168.121.219:22122

然后重启storeage服务

/usr/local/bin/fdfs_storaged/etc/fdfs/storage_group2.conf &

2,check,进去/home/plocc/fastdfs_group2目录下面有logs目录

再进去看日志信息,一切正常,如下所示:

[root@localhost ~]# ll/home/plocc/fastdfs_group2/

total 8

drwxr-xr-x. 259 root root 4096 May 4 2014data

drwxr-xr-x. 2 root root 4096 May 4 2014logs

[root@localhost ~]#

cd /home/plocc/fastdfs_group2/logs

[root@localhost logs]# tail -f storaged.log

……

[2015-03-30 09:41:07] INFO – file:storage_param_getter.c, line: 187, use_storage_id=0, id_type_in_filename=ip,storage_ip_changed_auto_adjust=1, store_path=0, reserved_storage_space=20.00%,use_trunk_file=0, slot_min_size=256, slot_max_size=16 MB, trunk_file_size=64MB, 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,store_slave_file_use_link=0

[2015-03-30 09:41:07] INFO – file:storage_func.c, line: 174, tracker_client_ip: 192.168.121.220,my_server_id_str: 192.168.121.220, g_server_id_in_filename: -596006720

[2015-03-30 09:41:07] INFO -local_host_ip_count: 2, 127.0.0.1 192.168.121.220

[2015-03-30 09:41:08] INFO – file:tracker_client_thread.c, line: 308, successfully connect to tracker server192.168.121.219:22122, as a tracker client, my ip is 192.168.121.220

[2015-03-30 09:41:08] INFO – file:tracker_client_thread.c, line: 1124, tracker server 192.168.121.219:22122, settracker leader: 192.168.121.219:22122

3,新问题来了,然后图片下载的时候,报错如下:

下载图片group2/M00/00/B4/wKh53FUYq1eAPeAWAABs0PIXl7w885.jpg 时出错.

先去查下fastdfs服务器上是否有这个文件,查询到确实有这个文件的

[root@localhost data]# find . -namewKh53FUYq1eAPeAWAABs0PIXl7w885.jpg

./00/B4/wKh53FUYq1eAPeAWAABs0PIXl7w885.jpg

[root@localhost data]# pwd

/home/plocc/fastdfs_group2/data

[root@localhost data]#

问题在哪里呢?,我们通过网站上一个能访问的图片地址,来检查判断。随意打开网站一个图片,在图片上面右键点击,选择“复制图片地址”,得到如下信息:

4,ping下static.mytest.com,去上面检查nginx配置

ping一下这个static.mytest.com,去看下是在哪一台服务器上面:

[root@localhost ~]# ping static.mytest.com

PING static.mytest.com (192.168.121.221)56(84) bytes of data.

64 bytes from 192.168.121.221: icmp_seq=1ttl=64 time=0.251 ms

64 bytes from 192.168.121.221: icmp_seq=2ttl=64 time=0.326 ms

64 bytes from 192.168.121.221: icmp_seq=3ttl=64 time=0.305 ms

64 bytes from 192.168.121.221: icmp_seq=4ttl=64 time=0.299 ms

^C

— static.mytest.com ping statistics —

4 packets transmitted, 4 received, 0%packet loss, time 3762ms

rtt min/avg/max/mdev =0.251/0.295/0.326/0.030 ms

[root@localhost ~]#

然后进去192.168.121.221里面去查看里面的nginx配置,进入

[root@localhost ~]# cd/usr/local/nginx/conf

[root@localhost conf]# vim nginx.conf #进去检索/group2或者group1

会发现如下配置:

location ~* ^/group1/.*$ {

proxy_pass ;

}

location ~* ^/group2/.*$ {

proxy_pass ;

}

然后再继续在nginx.cnf里面需找filebackend的配置,会看到如下配置:

upstream filebackend{

server dfs.mytest.com:8090;

}

5,去检查nginx里面filebackend所对应的dfs.mytest.com

去ping下dfs.mytest.com,看看去访问那个地址

[root@localhost ~]# ping dns.mytest.com

PING dns.mytest.com (192.168.121.212)56(84) bytes of data.

64 bytes from 192.168.121.212: icmp_seq=1ttl=64 time=0.081 ms

64 bytes from 192.168.121.212: icmp_seq=2ttl=64 time=0.110 ms

64 bytes from 192.168.121.212: icmp_seq=3ttl=64 time=0.104 ms

^C

— dns.mytest.com ping statistics —

3 packets transmitted, 3 received, 0%packet loss, time 2275ms

rtt min/avg/max/mdev =0.081/0.098/0.110/0.014 ms

[root@localhost ~]#

然后去192.168.121.212里面去看下nginx配置,需找/group1或者group2,发现有group1没有group2

location ~* ^/group1/.*$ {

proxy_pass ;

include proxy.conf;

error_log logs/file_error.loginfo;

access_loglogs/file_access.log main;

}

所以追加一个group2

location ~* ^/group2/.*$ {

proxy_pass ;

include proxy.conf;

error_log logs/file_error.loginfo;

access_loglogs/file_access.log main;

}

我们在继续在nginx.conf里面检索filebackend,看看指向哪里

upstream filebackend{

server 192.168.121.220:8090;

}

6,,去upstream服务器121.220上面查看nginx服务8090

看到指向192.168.121.220,然后我们去192.168.121.220上找fastdfs文件服务器,先去查看下后台进程找到fastdfs的配置文件路径

[root@localhost bin]# ps -eaf|grepfdfs_storaged

root25036 1 0 09:41 ? 00:00:00 /usr/local/bin/fdfs_storaged/etc/fdfs/storage_group2.conf

root25176 25121 0 11:00 pts/2 00:00:00 grep fdfs_storaged

[root@localhost bin]#

然后再去配置文件里面/etc/fdfs/storage_group2.conf去查看图片文件存放路径

[root@localhost bin]# vim /etc/fdfs/storage_group2.conf

# the base path to store data and log files

base_path=/home/plocc/fastdfs_group2

然后去/home/plocc/fastdfs_group2路径下面查找下载图片保存的图片是否存在这里:

[root@localhost fastdfs_group2]# find .-name wKh53FUYq1eAPeAWAABs0PIXl7w885.jpg

./data/00/B4/wKh53FUYq1eAPeAWAABs0PIXl7w885.jpg

[root@localhost fastdfs_group2]#

文件是存在的,所以然后需要在fastdfs本地提供的服务 server 192.168.121.220:8090;去找8090端口

[root@localhost conf]# netstat -anp |grep8090

有理想在的地方,地狱就是天堂

Nginx 跳转fastdfs存储图片地址报错问题分析过程汇总

相关文章:

你感兴趣的文章:

标签云: