问题排查及解决

在整合fastdfs+nginx的时候,我按照教程配置好了nginx.conf文件,拷贝并配置好mod_fastdfs.conf文件以及拷贝了http.conf和mime.types文件后(配置教程网上很多,可以自己搜一下),按理说我的nginx应该可以正常启动了,但我的worker还是启动失败了,问题如下:

  1. 启动nginx后,通过ps -aux | grep nginx查看nginx是否正常启动,显示信息如下:

    1
    2
    3
    root       2771  0.0  0.1  32596  2508 ?        Ss   14:43   0:00 nginx: master process ./nginx
    nobody 2776 0.0 0.1 33444 3608 ? S 14:43 0:00 nginx: master process ./nginx
    ccy 2778 0.0 0.0 15984 968 pts/4 S+ 14:43 0:00 grep --color=auto nginx

    可以看到worker并没有启动起来,反而多了一个nobody启动的master,而且它的进程号还会一直变。

  2. 既然出错了就去查看日志信息,在logs/error.log中看到如下信息:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    2020/08/21 14:46:48 [alert] 2771#0: worker process 2934 exited on signal 11 (core dumped)
    ngx_http_fastdfs_process_init pid=2936
    2020/08/21 14:46:51 [alert] 2771#0: worker process 2936 exited on signal 11 (core dumped)
    ngx_http_fastdfs_process_init pid=2938
    2020/08/21 14:46:54 [alert] 2771#0: worker process 2938 exited on signal 11 (core dumped)
    ngx_http_fastdfs_process_init pid=2940
    2020/08/21 14:46:57 [alert] 2771#0: worker process 2940 exited on signal 11 (core dumped)
    ngx_http_fastdfs_process_init pid=2944
    2020/08/21 14:47:00 [alert] 2771#0: worker process 2944 exited on signal 11 (core dumped)
    ngx_http_fastdfs_process_init pid=2946
    2020/08/21 14:47:03 [alert] 2771#0: worker process 2946 exited on signal 11 (core dumped)
    ngx_http_fastdfs_process_init pid=2948
    2020/08/21 14:47:06 [alert] 2771#0: worker process 2948 exited on signal 11 (core dumped)
    ngx_http_fastdfs_process_init pid=2950
    2020/08/21 14:47:09 [alert] 2771#0: worker process 2950 exited on signal 11 (core dumped)
    ngx_http_fastdfs_process_init pid=2953

    反正就是循环打印这些信息,进程号不断变化的原因就是进程启动出错并退出了,于是master进程很快就重新启动了新的worker进程,如此循环。

  3. 于是我又用dmesg|grep nginx查看了一下错误信息,显示:

    1
    2
    3
    4
    5
    6
    7
    [ 1265.795384] nginx[3250]: segfault at 4 ip 00007feab5165416 sp 00007fff258a0780 error 4 in libfdfsclient.so[7feab515e000+1a000]
    [ 1268.880476] nginx[3256]: segfault at 4 ip 00007feab5165416 sp 00007fff258a0780 error 4 in libfdfsclient.so[7feab515e000+1a000]
    [ 1271.938227] nginx[3258]: segfault at 4 ip 00007feab5165416 sp 00007fff258a0780 error 4 in libfdfsclient.so[7feab515e000+1a000]
    [ 1275.014353] nginx[3260]: segfault at 4 ip 00007feab5165416 sp 00007fff258a0780 error 4 in libfdfsclient.so[7feab515e000+1a000]
    [ 1278.123135] nginx[3264]: segfault at 4 ip 00007feab5165416 sp 00007fff258a0780 error 4 in libfdfsclient.so[7feab515e000+1a000]
    [ 1281.200925] nginx[3266]: segfault at 4 ip 00007feab5165416 sp 00007fff258a0780 error 4 in libfdfsclient.so[7feab515e000+1a000]
    [ 1284.280982] nginx[3268]: segfault at 4 ip 00007feab5165416 sp 00007fff258a0780 error 4 in libfdfsclient.so[7feab515e000+1a000]

    其中提到了libfdfsclient.so,我就突然想到了一开始配置的mod_fastdfs.conf文件中我是有配置到tracker的IP和端口的,会不会是因为我的fastdfs的tracker没开啊,打开一下试试,
    fdfs_trackerd /etc/fdfs/tracker.conf start
    然后sudo ./nginx -s stop退出刚刚出错的nginx,
    再启动nginx,sudo ./nginx,然后ps -aux | grep nginx,打印如下:

    1
    2
    3
    root       3373  0.0  0.0  32596   460 ?        Ss   14:56   0:00 nginx: master process ./nginx
    nobody 3374 0.0 0.1 33444 3620 ? S 14:56 0:00 nginx: worker process
    ccy 3377 0.0 0.0 15984 1028 pts/4 R+ 14:56 0:00 grep --color=auto nginx

    可以看到,worker启动起来了,配置成功了!

评论