Edge for Private Cloud v. 4.16.05
如需在安装后配置 Edge,请结合使用 .properties 文件和 Edge 实用程序。例如,如需在 Edge 界面中配置 TLS/SSL,请修改 .properties 文件以设置必要的属性。对 .properties 文件所做的更改要求您重启受影响的 Edge 组件。
Apigee 将修改 .properties 文件的技术称为包含配置的代码。从本质上讲,包含 config 的代码是一种键值对查询工具,基于 .properties 文件中的设置。在包含配置的代码中,密钥称为“令牌”。因此,要配置 Edge,请在 .properties 文件中设置令牌。
借助“包含配置的代码”,Edge 组件可以设置产品随附的默认值,让安装团队根据安装拓扑替换这些设置,然后客户可以替换他们选择的任何属性。
如果您将其视为层次结构,那么设置将按以下方式排列,其中客户设置的优先级最高,可替换安装程序团队或 Apigee 的任何设置:
- 客户
- 安装程序
- Apigee
如何使用 .properties 文件
作为客户,您只能修改 /<inst_root>/apigee/customer/application 目录中的 .properties 文件。每个组件在该目录中都有自己的 .properties 文件。例如 router.properties 和 management-server.properties。
:- 以任意用户的身份在编辑器中创建文件。
- 对文件所有者执行 chown 操作,将其分配给 apigee:apigee,或者,如果将运行 Edge 服务的用户从 apigee 用户更改为,则对运行 Edge 服务的用户进行 chown 文件 chown 操作。
要为组件设置属性,请修改相应的 .properties 文件以设置令牌,然后重启组件:
> /<inst_root>/apigee/apigee-service/bin/apigee-service component restart
例如,在修改 router.properties 后,重启路由器:
> /<inst_root>/apigee/apigee-service/bin/apigee-service edge-router restart
升级 Edge 时,系统会读取 /<inst_root>/apigee/customer/application 目录中的 .properties 文件。这意味着升级将保留您在组件上设置的所有属性。
.properties 文件的位置
Edge 组件的 .properties 文件有三个顶级目录:安装所有者和客户。默认位置如下表所示:
警告:Edge 客户只能修改 /<inst_root>/apigee/customer 下的 .properties 文件。虽然您可以查看组件和安装目录下的文件,但请勿修改任何文件。
Owner |
默认令牌根目录 |
---|---|
组件 |
<inst_root>/apigee/<prefix>-<component>/conf 其中 /<prefix>-<component> 用于标识组件,例如 Edge-router 或 apigee-cassandra。 |
安装 |
<inst_root>/apigee/token |
客户 |
<inst_root>/apigee/customer |
确定令牌的当前值
在 .properties 文件中为组件设置令牌之前,您可以先使用以下命令确定其当前值:
> /<inst_dir>/apigee/apigee-service/bin/apigee-service comp configure -search token
其中 comp 是组件的名称,token 是要检查的令牌。
此命令会搜索 .properties 文件的层次结构,以确定令牌的当前值。
例如,要检查路由器的 conf_router_HTTP.request.line.limit 令牌的当前值,请执行以下操作:
> /<inst_dir>/apigee/apigee-service/bin/apigee-service edge-router configure -search conf_router_HTTP.request.line.limit
您会在表单中看到输出:
Found key conf_router_HTTP.request.line.limit, with value, 4k, in /opt/apigee/edge-router/token/default.properties
在 .properties 文件中设置令牌
如需替换令牌的值,请执行以下操作:
- 修改组件的 .properties 文件以设置令牌值。如果该文件不存在,则创建一个。
- 重启组件。
- 检查令牌值。
例如,如需为边缘路由器设置请求行限制,请执行以下操作:
- 修改 /<inst_root>/apigee/customer/application/router.properties 文件以设置 conf_router_HTTP.request.line.limit 令牌:
conf_router_HTTP.request.line.limit=8k - 重启边缘路由器:
> /<inst_root>/apigee/apigee-service/bin/apigee-serviceedge-router restart - 请检查该令牌的值:
> /<inst_dir>/apigee/apigee-service/bin/apigee-serviceedge-router configure -search conf_router_HTTP.request.line.limit
设置接受多个值的令牌
某些标记接受以英文逗号分隔的值列表。例如,conf_security_rbac.restricted.resources 令牌接受受限的 URI 列表,以便只有系统管理员可以调用它们。如需查看 conf_security_rbac.restricted.resources 的值,请执行以下操作:
> cd /<inst_root>/apigee/edge-management-server > grep -ri "conf_security_rbac.restricted.resources" *
输出包含以下内容:
token/default.properties:conf_security_rbac.restricted.resources=/environments,/environments/*,/environments/*/virtualhosts,/environments/*/virtualhosts/*,/pods,/environments/*/servers,/rebuildindex,/users/*/status
要设置接受值列表的令牌,请在 .properties 文件中将任何新值附加到令牌的当前值。因此,要将 URI /myuri/* 添加到 conf_security_rbac.restricted.resources,请编辑 /<inst_root>/apigee/customer/application/management-server.properties 文件,如下所示:
conf_security_rbac.restricted.resources=/environments,/environments/*,/environments/*/virtualhosts,/environments/*/virtualhosts/*,/pods,/environments/*/servers,/rebuildindex,/users/*/status,/myuri/*
查找令牌
在大多数情况下,本指南中介绍了您需要设置的令牌。不过,如果需要确定用于替换属性的令牌,请在组件的 source 文件夹中执行 grep。
例如,如果您知道在之前的 Edge 版本中设置了 session.maxAge 属性,并希望知道用于设置该属性的令牌值,请在 /<inst_root>/apigee/edge-ui/source 目录中针对该属性设置 grep:
> grep -ri "session.maxAge" /<inst_root>/apigee/edge-ui/source
您应该会看到以下形式的结果:
/<inst_root>/apigee/edge-ui/source/conf/application.conf:session.maxAge={T}conf_application_session.maxage{/T}
{T}{/T} 标记之间的字符串是您在 .properties 文件中设置的令牌。
设置当前已被注释掉的令牌
某些令牌在 Edge 配置文件中已被注释掉。如果您尝试设置已被注释掉的令牌,则此设置会被忽略。
要设置被注释掉的令牌,可使用特殊语法,形式如下:
conf/file.extension+propertyName=propertyValue
例如,您希望在消息处理器上设置名为 HTTPClient.proxy.host 的属性。然后,您为该属性运行 grep 来确定其令牌:
> cd /opt/apigee/edge-message-processor > grep -ri "HTTPClient.proxy.host" *
grep 命令以包含令牌值的形式返回结果。请注意属性名称被注释掉的方式,如属性名称上的 # 前缀所示:
source/conf/http.properties:#HTTPClient.proxy.host={T}conf_http_HTTPClient.proxy.host{/T} token/default.properties:conf_http_HTTPClient.proxy.host= conf/http.properties:#HTTPClient.proxy.host=
如需设置该属性,请修改 /opt/apigee/customer/application/message-processor.properties,以便将属性设置为:
conf/http.properties+HTTPClient.proxy.host=myhost.name.com
请注意,属性名称以 conf/http.properties+ 为前缀,即包含此属性的配置文件的位置和名称,后跟“+”。
重启消息处理器后,请检查文件 /opt/apigee/edge-message-processor/conf/http.properties:
> cat /opt/apigee/edge-message-processor/conf/http.properties
在文件末尾,您会看到属性集,格式如下:
conf/http.properties:HTTPClient.proxy.host=yhost.name.com