【问题标题】:Varnish stoped working and dies after start OK清漆停止工作并在启动后死亡
【发布时间】:2018-03-19 18:47:35
【问题描述】:

我在 centos 上运行 varnish whit drupal。 它只是文件,突然停止工作。 开:

服务清漆开始

我明白了:

启动 varnish HTTP 加速器:[OK]

但是当我检查状态时,我得到:

varnishd 已死,但 pid 文件存在

这是我的 deaflt.vcl:

# This is a basic VCL configuration file for varnish.  See the vcl(7)
# man page for details on VCL syntax and semantics.
# 
# Default backend definition.  Set this to point to your content
# server.
# 
backend default {
  .host = "mydomain.com";
  .port = "port_num";
  .connect_timeout = 3600s;
  .first_byte_timeout = 3600s;
  .between_bytes_timeout = 3600s;
}

# 
# Below is a commented-out copy of the default VCL logic.  If you
# redefine any of these subroutines, the built-in logic will be
# appended to your code.
# 
 sub vcl_recv {
 
	  # Add a unique header containing the client address
		remove req.http.X-Forwarded-For;
		set    req.http.X-Forwarded-For = client.ip;
 
	  # set the custom header
	  if (req.http.Cookie ~ "ABtesting=B") {
		set req.http.X-ABtesting = "B";
	  } else {
		set req.http.X-ABtesting = "A";
	  }
 
	# do this only once per request
	if (req.restarts == 0) {
	  # normalize Accept-Encoding to reduce vary
	  if (req.http.Accept-Encoding) {
		if (req.http.User-Agent ~ "MSIE 6") {
		  unset req.http.Accept-Encoding;
		} elsif (req.http.Accept-Encoding ~ "gzip") {
		  set req.http.Accept-Encoding = "gzip";
		} elsif (req.http.Accept-Encoding ~ "deflate") {
		  set req.http.Accept-Encoding = "deflate";
		} else {
		  unset req.http.Accept-Encoding;
		}
	  }
	}
	
	if (req.http.User-Agent ~ "(Mobile|Android|iPhone|iPad)") {
	  set req.http.User-Agent = "mobile";
	} else {
	  set req.http.User-Agent = "desktop";
	}
	
	
     if (req.request != "GET" &&
       req.request != "HEAD" &&
       req.request != "PUT" &&
       req.request != "POST" &&
       req.request != "TRACE" &&
       req.request != "OPTIONS" &&
       req.request != "DELETE") {
         /* Non-RFC2616 or CONNECT which is weird. */
         return (pipe);
     }
     if (req.request != "GET" && req.request != "HEAD") {
         /* We only deal with GET and HEAD by default */
         return (pass);
     }
	// Remove has_js and Google Analytics __* cookies.
	set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;]*", "");
	// Remove a ";" prefix, if present.
	set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");
     if (req.http.Authorization /*|| req.http.Cookie*/) {
         /* Not cacheable by default */
         return (pass);
     }
     return (lookup);
 }

# 
# sub vcl_pipe {
#     # Note that only the first request to the backend will have
#     # X-Forwarded-For set.  If you use X-Forwarded-For and want to
#     # have it set for all requests, make sure to have:
#     # set bereq.http.connection = "close";
#     # here.  It is not set by default as it might break some broken web
#     # applications, like IIS with NTLM authentication.
#     return (pipe);
# }
# 
# sub vcl_pass {
#     return (pass);
# }
# 
# sub vcl_hash {
#     set req.hash += req.url;
#     if (req.http.host) {
#         set req.hash += req.http.host;
#     } else {
#         set req.hash += server.ip;
#     }
#     return (hash);
# }
# 
# sub vcl_hit {
#     if (!obj.cacheable) {
#         return (pass);
#     }
#     return (deliver);
# }
# 
# sub vcl_miss {
#     return (fetch);
# }
# 
 sub vcl_fetch {
			if (beresp.ttl > 0s) {
			/* Remove Expires from backend, it's not long enough */
			unset beresp.http.expires;

			/* Set the clients TTL on this object */
			set beresp.http.cache-control = "max-age=900";

			/* Set how long Varnish will keep it */
			set beresp.ttl = 1w;

			/* marker for vcl_deliver to reset Age: */
			set beresp.http.magicmarker = "1";
            }
 
	   # vary on the custom header
	  if (beresp.http.Vary) {
		set beresp.http.Vary = beresp.http.Vary ", X-ABtesting";
	  } else {
		set beresp.http.Vary = "X-ABtesting";
	  }
     if (!beresp.cacheable) {
         return (pass);
     }
     if (beresp.http.Set-Cookie) {
         return (pass);
     }
     return (deliver);
 }
 
 
 
# 
 sub vcl_deliver {
	if (resp.http.Vary) {
    set resp.http.Vary = regsub(resp.http.Vary, "X-ABtesting", "Cookie");
	}
	 if (resp.http.magicmarker) {
		/* Remove the magic marker */
		unset resp.http.magicmarker;

		/* By definition we have a fresh object */
		set resp.http.age = "0";
	}

	
     return (deliver);
 }
# 
# sub vcl_error {
#     set obj.http.Content-Type = "text/html; charset=utf-8";
#     synthetic {"
# <?xml version="1.0" encoding="utf-8"?>
# <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
#  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
# <html>
#   <head>
#     <title>"} obj.status " " obj.response {"</title>
#   </head>
#   <body>
#     <h1>Error "} obj.status " " obj.response {"</h1>
#     <p>"} obj.response {"</p>
#     <h3>Guru Meditation:</h3>
#     <p>XID: "} req.xid {"</p>
#     <hr>
#     <p>Varnish cache server</p>
#   </body>
# </html>
# "};
#     return (deliver);
# }

请注意,apache 正在侦听 varnish 的端口,并且它正在工作但没有问题。

【问题讨论】:

  • 在应用程序和/或系统级别没有日志、错误消息,什么都没有?
  • 我希望。当我尝试“tail -f”时,我得到“没有这样的文件或目录”。我有较旧的清漆日志 - 所以他们工作过一次。而且没有错误,还可以。也许还有其他日志或地方我可以查看,但我没有找到。
  • 谢谢,但那没有用。 varnishncsa (pid 2205) 正在运行...但日志中没有任何内容,不是 varnish.log 或 varnishncsa.log。

标签: linux apache caching centos varnish


【解决方案1】:

要了解它死亡的原因,您可以查看 dmesg 输出并查找“die”或“kill”,或者查看“varnishadm panic.show”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-13
    • 2013-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多