配置文件错误

您正在查看的是 Apigee Edge 文档。
转到 Apigee X 文档
信息

问题

边缘路由器是使用 NGINX 实现的。在边缘升级过程中或更改路由器配置时,您可能会看到 NGINX 配置错误。发生这些错误时,Edge 会标记导致 /opt/nginx/conf.d 问题的所有 NGINX 配置文件:

-rw-r--r-- 1 apigee apigee 522 Jul 20 08:41 0-default.conf.bad 
-rw-r--r-- 1 apigee apigee 577 Jul 20 08:42 0-fallback.conf 
-rw-r--r-- 1 apigee apigee 1062 Jul 20 08:18 0-map.conf 
-rw-r--r-- 1 apigee apigee 1887 Jul 20 08:42 custorg_test_default.conf.bad

错误消息

您不会看到任何错误消息。但是,由于配置文件有问题,您可能无法执行 API 代理。

可能的原因

通常,NGINX 配置文件会被标记为错误,原因可能是 /opt/apigee/customer/application/router.properties 文件中设置为 NGINX 属性不正确或对虚拟主机进行了错误更改。

诊断

  1. /opt/nginx/conf.d 目录中的文件名中移除 .bad 后缀,使其以 .conf 结尾。
  1. 运行 NGINX configtest 工具以确定失败原因:
    /opt/nginx/scripts/apigee-nginx configtest
    

分辨率

  1. 如果配置测试确定了配置文件错误的原因,请通过对 /opt/apigee/customer/application/router.properties 文件或虚拟主机中的特定属性进行适当更改来解决问题。
  1. 移除 /opt/nginx/conf.d 目录:
    rm -rf /opt/nginx/conf.d
    
  1. 重启路由器:
    /opt/apigee/apigee-service/bin/apigee-service edge-router restart
    
  1. 您应该不会再在 /opt/nginx/conf.d 目录中看到不良配置文件。

如果问题仍然存在,请与 Apigee Edge 支持团队联系。

以下示例说明了如何根据 NGINX 配置测试提供的信息解决问题。

示例 1:为 NGINX 属性设置的值不正确

  1. 假设您将 /opt/apigee/customer/application/router.properties 文件中的属性“proxy_busy_buffers_size”更新为 128K,如下所示:
    conf_load_balancing_load.balancing.driver.proxy.busy.buffer.size=128k 
    

这会导致配置文件在 /opt/apigee/nginx/conf.d 目录中被标记为错误。

  1. 运行 NGINX configtest 命令以确定失败原因:
    /opt/nginx/scripts/apigee-nginx configtest
    nginx: [emerg] "proxy_busy_buffers_size" must be equal to or greater than the maximum of the value of "proxy_buffer_size" and one of the "proxy_buffers" in /opt/nginx/conf/nginx.conf:47
    nginx: configuration file /opt/nginx/conf/nginx.conf test failed
    

configtest 结果表明,属性 proxy_busy_buffers_size 的值应等于或大于 proxy_busy_buffers_size,但设置的值似乎不正确。

  1. 检查 0-default.conf 文件中为 proxy_buffer_sizeproxy_buzz_buffers_size 属性设置的值:
    proxy_buffer_size 512k;
    proxy_busy_buffers_size 128k;
    
  1. /opt/apigee/customer/application/router.properties 文件中的 Proxy_bulk_buffers_size 值更新为 512K:
    conf_load_balancing_load.balancing.driver.proxy.busy.buffer.size=512k
    
  1. 移除 /opt/nginx/conf.d 文件夹:
    rm -rf /opt/nginx/conf.d
    
  1. 重启路由器:
    /opt/apigee/apigee-service/bin/apigee-service edge-router restart
    

该问题已解决,错误配置文件也已被移除。

示例 2:此过程无法升级 NGINX(仅限 Private Cloud 18.01)

假设您运行 configtest 并返回以下响应:

/apigee-nginx configtest

 nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
 nginx: [emerg] zero size shared memory zone "perclient"
 nginx: configuration file /opt/nginx/conf/nginx.conf test failed

此失败表示进程未能将 NGINX 从 1.10.x 升级到 1.12.x。存在一个与将 Edge Private Cloud 升级到版本 18.01 相关的已知 bug。

如需正确诊断此问题(仅适用于 Private Cloud 18.01),请执行以下操作:

rpm -aq | grep apigee-nginx

此命令应返回已安装的 rpm 作为版本 1.12.x。如果没有,请按照以下步骤操作:

  1. 停止边缘路由器组件。
  2. 备份边缘路由器组件。
  3. 运行以下命令以升级到 apigee-nginx 1.2.x:
  4. sudo yum update apigee-nginx
  5. 删除 /opt/apigee/nginx/conf.d. 下的所有 *.bad 文件
  6. 重启边缘路由器组件。