2017-01-13 16 views
0

私のnginx設定に問題があります。私のサーバは正常に動作しますが、1〜2日後にはハングアップして応答しなくなります。もうサーバーに接続することはできません。nginxはしばらくしてから接続を拒否します

(7) Failed to connect to XX.XX.XX.XX port 80: Connection refused 

このサーバーの主な仕事は重いPHPのタスクを実行している、私は多くのタスクのために5秒ごとにcronジョブを実行します。再起動が役立ち、nginxは今後1-2日間正しく動作します。私はエラーログを持っていない、nginxは/var/log/nginx/error.logに何も報告していない。単にすべての接続に失敗します。どのようなアイデアで問題を探し始めることができますか?

私はUbuntu 16.04で2つのCPU、4GBのRAM、PHP 7.0でnginxを実行します。 nginxのバージョン:nginxの/ 1.10.0(Ubuntuの)

ここでは、設定ファイルである:ここ

user www-data; 
worker_processes 2; 
pid /run/nginx.pid; 

events { 
    worker_connections 4096; 
    #multi_accept on; 
} 

http { 

## 
# Basic Settings 
## 

sendfile on; 
tcp_nopush on; 
tcp_nodelay on; 
keepalive_timeout 300; 
types_hash_max_size 2048; 
server_tokens off; 

# server_names_hash_bucket_size 64; 
# server_name_in_redirect off; 

include /etc/nginx/mime.types; 
default_type application/octet-stream; 

## 
# SSL Settings 
## 

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE 
ssl_prefer_server_ciphers on; 

## 
# Logging Settings 
## 

access_log /var/log/nginx/access.log; 
error_log /var/log/nginx/error.log; 

## 
# Gzip Settings 
## 

gzip on; 
gzip_disable "msie6"; 

# gzip_vary on; 
# gzip_proxied any; 
# gzip_comp_level 6; 
# gzip_buffers 16 8k; 
# gzip_http_version 1.1; 
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; 

## 
# Virtual Host Configs 
## 

include /etc/nginx/conf.d/*.conf; 
include /etc/nginx/sites-enabled/*; 
} 

がデフォルトのファイルです:

server { 
large_client_header_buffers 4 128k; 
listen XX:XX:XX:XX:80; 

set $root_path '/var/www/web/public/'; 

root $root_path; 
index index.php; 

server_name XX:XX:XX:XX; 

location/{ 
    # First attempt to serve request as file, then 
    # as directory, then fall back to displaying a 404. 
    try_files $uri $uri/ /index.php?$query_string; 
} 

location ~ \.php$ { 
    include snippets/fastcgi-php.conf; 
    fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include fastcgi_params; 
    fastcgi_read_timeout 14400; 

    proxy_set_header Connection ""; 
    proxy_http_version 1.1; 
} 

location /status { 
     stub_status on; 
     access_log off; 
     allow XX:XX:XX:XX; 
     deny all; 
} 

location ~* ^/(css|img|js|flv|swf|download)/(.+)$ { 
    root $root_path; 
} 

# deny access to .htaccess files, if Apache's document root 
# concurs with nginx's one 
location ~ /\.ht { 
    deny all; 
} 
} 

そして主なものは、私のcronジョブは、私が実行します例えば:

* * * * * sleep 5; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1 
* * * * * sleep 10; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1 
* * * * * sleep 15; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1 
* * * * * sleep 20; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1 
* * * * * sleep 25; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1 
* * * * * sleep 30; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1 
* * * * * sleep 35; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1 
* * * * * sleep 40; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1 
* * * * * sleep 45; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1 
* * * * * sleep 50; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1 

など

UPDATE:

PHP FPMステータス

* php7.0-fpm.service - The PHP 7.0 FastCGI Process Manager 
    Loaded: loaded (/lib/systemd/system/php7.0-fpm.service; enabled; vendor preset: enabled) 
    Active: active (running) since Fri 2017-01-13 10:46:41 CET; 3 days ago 
    Process: 1439 ExecStartPre=/usr/lib/php/php7.0-fpm-checkconf (code=exited, status=0/SUCCESS) 
Main PID: 1662 (php-fpm7.0) 
    Status: "Processes active: 0, idle: 25, Requests: 164215, slow: 0, Traffic: 0req/sec" 
    Tasks: 26 
    Memory: 377.3M 
     CPU: 5h 57min 32.279s 
    CGroup: /system.slice/php7.0-fpm.service 
      |- 1662 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf)      
      |- 1752 php-fpm: pool www                
      |- 8751 php-fpm: pool www                
      |-12078 php-fpm: pool www                
      |-14053 php-fpm: pool www                
      |-14338 php-fpm: pool www                
      |-14639 php-fpm: pool www                
      |-14763 php-fpm: pool www                
      |-16188 php-fpm: pool www                
      |-16212 php-fpm: pool www                
      |-16900 php-fpm: pool www                
      |-17620 php-fpm: pool www                
      |-17621 php-fpm: pool www                
      |-17766 php-fpm: pool www                
      |-18802 php-fpm: pool www                
      |-19084 php-fpm: pool www                
      |-22064 php-fpm: pool www                
      |-24245 php-fpm: pool www                
      |-24690 php-fpm: pool www                
      |-25120 php-fpm: pool www                
      |-27714 php-fpm: pool www                
      |-29415 php-fpm: pool www                
      |-30182 php-fpm: pool www                
      |-30391 php-fpm: pool www                
      |-32053 php-fpm: pool www                
      `-32358 php-fpm: pool www                

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable. 

答えて

1

私は、PHP FPMログをチェックします。 PHPのfpmプロセスが不足している可能性があります。

+0

ありがとうございます!私は多くの警告を出しています。警告:[pool www]サーバはpm.max_childrenの設定(5)に達しました。 はそれを呼び出すことを検討します.'私はデフォルト設定について忘れていました。 – Maciej

+0

それは助けにならなかった; /私はデフォルトから 'pm.max_children = 40とpm.start_servers = 15とpm.min_spare_servers = 15とpm.max_spare_servers = 25とpm.max_requests = 500'に変更した。 2日後、私は同じ問題を抱えていました。子供についてのエラーはなく、nginxのエラーもありませんでした。 – Maciej

+1

それは、その行動を引き起こすと思う唯一のことです。 NGINXとphp-fpmのアクセスログとエラーログを有効にし、失敗したリクエストをトレースすることをお勧めします。 –

関連する問題