如何設定 Edge

如要在安裝後設定 Edge,請使用 .properties 檔案和 Edge 公用程式。舉例來說,如要在 Edge UI 上設定 TLS/SSL,您可以編輯 .properties 檔案來設定必要的屬性。如果你變更 .properties 個檔案,就必須重新啟動受影響的 Edge 元件。

Apigee 是指將 .properties 檔案編輯為使用 config 程式碼的技術 (有時稱為 CwC)。基本上,含有設定的程式碼是以 .properties 檔案中的設定做為鍵/值查詢工具。在具有設定的程式碼中,索引鍵稱為權杖。因此,如要設定 Edge,請在 .properties 檔案中設定權杖。

含有 Config 的程式碼可讓 Edge 元件設定產品隨附的預設值,讓安裝團隊根據安裝拓撲覆寫這些設定,方便客戶覆寫他們選擇的任何屬性。

您可以將其視為階層,並依以下方式安排設定,其中客戶設定的優先順序將覆寫安裝程式團隊或 Apigee 中的任何設定:

  1. 客戶
  2. 安裝程式
  3. 元件

判斷權杖目前的值

.properties 檔案中為權杖設定新的值之前,請先使用下列指令決定其「目前」的值:

/opt/apigee/apigee-service/bin/apigee-service component_name configure -search token

其中的 component_name 是元件名稱,token 則是要檢查的權杖。

這個指令會搜尋元件的 .properties 檔案階層,以判斷權杖的目前值。

以下範例會檢查路由器的 conf_http_HTTPRequest.line.limit 權杖目前值:

/opt/apigee/apigee-service/bin/apigee-service edge-router configure -search conf_http_HTTPRequest.line.limit

畫面會顯示類似下列輸出內容:

Found key conf_http_HTTPRequest.line.limit, with value, 4k, in /opt/apigee/edge-router/token/default.properties

如果權杖的值以 # 開頭,則該註解已經過註解,且您必須使用特殊語法來進行變更。詳情請參閱「設定目前排除的權杖」。

如果不知道權杖的全名,請使用 grep 等工具,以屬性名稱或關鍵字詞進行搜尋。詳情請參閱「尋找權杖」。

屬性檔案

有可編輯的和編輯的設定檔設定檔。本節將說明這些檔案。

可編輯元件設定檔

下表列出了您可以編輯這些元件的 Apigee 元件和屬性檔案:

元件 元件名稱 可編輯的設定檔
Cassandra apigee-cassandra /opt/apigee/customer/application/cassandra.properties
Apigee 單一登入 apigee-sso /opt/apigee/customer/application/sso.properties
管理伺服器 edge-management-server /opt/apigee/customer/application/management-server.properties
訊息處理器 edge-message-processor /opt/apigee/customer/application/message-processor.properties
apigee-monit apigee-monit /opt/apigee/customer/application/monit.properties
傳統版 UI (不會影響新版 Edge UI) edge-ui /opt/apigee/customer/application/ui.properties
Edge UI (僅限新版 Edge UI;不會影響傳統版 UI) apigee-management-ui 不適用 (使用安裝設定檔)
開啟 LDAP apigee-openldap /opt/apigee/customer/application/openldap.properties
Postgres 伺服器 edge-postgres-server /opt/apigee/customer/application/postgres-server.properties
PostgreSQL 資料庫 apigee-postgresql /opt/apigee/customer/application/postgressql.properties
Qpid 伺服器 edge-qpid-server /opt/apigee/customer/application/qpid-server.properties
Qpidd 音樂 apigee-qpidd /opt/apigee/customer/application/qpidd.properties
路由器 edge-router /opt/apigee/customer/application/router.properties
Zookeeper apigee-zookeeper /opt/apigee/customer/application/zookeeper.properties

如果您要在上述元件設定檔中設定屬性,但該屬性不存在,可以在上述位置建立。

此外,您必須確保屬性檔案為「Apigee」使用者:

chown apigee:apigee /opt/apigee/customer/application/configuration_file.properties

無法編輯的元件設定檔

除了可編輯的元件設定檔外,您也無法編輯設定檔。

資訊 (不可編輯) 檔案包括:

擁有者 檔案名稱或目錄
安裝
/opt/apigee/token
元件
/opt/apigee/component_name/conf

其中 component_name 代表元件。可用的值包括:

  • apigee-cassandra (Cassandra)
  • apigee-openldap (OpenLDAP)
  • apigee-postgresql (PostgreSQL 資料庫)
  • apigee-qpidd (魁北克)
  • apigee-sso (邊緣單一登入)
  • apigee-zookeeper (ZooKeeper)
  • edge-management-server (管理伺服器)
  • edge-management-ui (新版 Edge UI)
  • edge-message-processor (訊息處理器)
  • edge-postgres-server (Postgres 伺服器)
  • edge-qpid-server (快速伺服器)
  • edge-router (邊緣路由器)
  • edge-ui (傳統版 UI)

設定權杖值

您只能修改 /opt/apigee/customer/application 目錄中的 .properties 檔案。每個元件在該目錄中都有專屬的 .properties 檔案。例如 router.propertiesmanagement-server.properties。如需屬性檔案的完整清單,請參閱「 屬性檔案的位置」

如何建立 .properties 檔案:

  1. 在編輯器中建立新的文字檔案。檔案名稱必須與上表中所列的客戶檔案清單相符。
  2. 將檔案擁有者變更為「apigee:apigee」,如以下範例所示:
    chown apigee:apigee /opt/apigee/customer/application/router.properties

    如果您變更了「Apigee」使用者執行 Edge 服務的使用者,請使用 chown 將擁有權變更為執行 Edge 服務的使用者。

升級 Edge 時,系統會讀取 /opt/apigee/customer/application 目錄中的 .properties 檔案。也就是說,升級將保留您在元件上設定的所有屬性。

如何設定權杖值:

  1. 編輯元件的 .properties 檔案。
  2. 新增或變更權杖值。以下範例將 conf_http_HTTPRequest.line.limit 屬性的值設為「10k」:
    conf_http_HTTPRequest.line.limit=10k

    如果符記使用多個值,請以半形逗號隔開各個值,如以下範例所示:

    conf_security_rbac.restricted.resources=/environments,/environments/*,/environments/*/virtualhosts,/environments/*/virtualhosts/*,/pods,/environments/*/servers,/rebuildindex,/users/*/status,/myuri/*

    如要在這類清單中新增值,您通常會將新值附加至清單結尾。

  3. 重新啟動元件:
    /opt/apigee/apigee-service/bin/apigee-service component_name restart

    其中 component_name 是下列任一值:

    • apigee-cassandra (Cassandra)
    • apigee-openldap (OpenLDAP)
    • apigee-postgresql (PostgreSQL 資料庫)
    • apigee-qpidd (魁北克)
    • apigee-sso (邊緣單一登入)
    • apigee-zookeeper (ZooKeeper)
    • edge-management-server (管理伺服器)
    • edge-management-ui (新版 Edge UI)
    • edge-message-processor (訊息處理器)
    • edge-postgres-server (Postgres 伺服器)
    • edge-qpid-server (快速伺服器)
    • edge-router (邊緣路由器)
    • edge-ui (傳統版 UI)

    舉例來說,編輯 router.properties 後,重新啟動路由器:

    /opt/apigee/apigee-service/bin/apigee-service edge-router restart
  4. (選用) 使用 configure -search 選項,確認權杖值是否設為新的值。例如:
    /opt/apigee/apigee-service/bin/apigee-service edge-router configure -search conf_http_HTTPRequest.line.limit

    如要進一步瞭解 configure -search,請參閱決定權杖的目前值

找出權杖

在大多數情況下,需要設定的權杖都可以在本指南中找到。但是,如果您需要覆寫現有全名或位置的現有權杖值,請使用 grep 搜尋元件的 source 目錄。

舉例來說,如果您知道先前在 Edge 的版本中,就可以設定 session.maxAge 屬性,且想要知道用來設定該權杖的權杖值,然後對 /opt/apigee/edge-ui/source 目錄中的屬性使用 grep

grep -ri "session.maxAge" /opt/apigee/edge-ui/source

您應該會看到以下結果:

/opt/apigee/component_name/source/conf/application.conf:property_name={T}token_name{/T}

以下範例顯示 UI 權杖 session.maxAge 的值:

/opt/apigee/edge-ui/source/conf/application.conf:session.maxAge={T}conf_application_session.maxage{/T}

{T}{/T} 標記之間的字串是可在使用者介面的 .properties 檔案中設定權杖的名稱。

設定目前排除的權杖

部分權杖已在 Edge 設定檔中加上註解。如果您嘗試設定在安裝或元件設定檔中加註的權杖,系統會忽略您的設定。

若要設定在 Edge 設定檔中加註的權杖值,請使用下列特殊語法:

conf/filename+propertyName=propertyValue

舉例來說,如要在訊息處理器中設定名為 HTTPClient.proxy.host 的屬性,請先讓 grep 為屬性判斷其權杖:

grep -ri /opt/apigee/edge-message-processor/ -e "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=myhost.name.com