Apache Zookeeper 維護工作

四字母指令

Apache ZooKeeper 有許多「四字母指令」,可用於判斷 ZooKeeper 投票者和觀察者節點的目前狀態。您可以使用 nc、telnet 或其他可將指令傳送至特定通訊埠的公用程式,叫用這些指令。如要進一步瞭解四字母指令,請參閱 Apache ZooKeeper 指令參考資料。

移除舊的快照檔案

Apache ZooKeeper 會自動定期執行維護作業,移除系統更新時累積的舊快照檔案。/opt/apigee/apigee-zookeeper/conf/zoo.cfg 中的下列設定可控制這項程序:

## The number of snapshots to retain in dataDir:
autopurge.snapRetainCount=5

# Purge task interval in hours.
# Set to "0" to disable auto purge feature.
autopurge.purgeInterval=120

如要將這些屬性設為不同值,請按照下列步驟操作:

  1. 編輯 /opt/apigee/customer/application/zookeeper.properties,設定下列屬性。如果該檔案不存在,請建立檔案。
  2. 在 zookeeper.properties 中設定下列屬性:
    # Set the snapshot count. In this example set it to 10:
      conf_zoo_autopurge.snapretaincount=10
    
      # Set the purge interval. In this example, set is to 240 hours:
      conf_zoo_autopurge.purgeinterval=240
  3. 確認檔案擁有者為「apigee」使用者:
    chown apigee:apigee /opt/apigee/customer/application/zookeeper.properties
  4. 使用下列指令重新啟動 ZooKeeper:
    /opt/apigee/apigee-service/bin/apigee-service apigee-zookeeper restart

記錄檔維護

Apache Zookeeper 記錄檔會保留在 /opt/apigee/var/log/apache-zookeeper。一般來說,您不需要維護記錄檔,但如果發現 ZooKeeper 記錄檔數量過多或記錄檔過大,可以修改 ZooKeeper 的 log4j 屬性,設定檔案大小和檔案數量上限。

  1. 編輯 /opt/apigee/customer/application/zookeeper.properties 以設定下列屬性。如果該檔案不存在,請建立檔案。
  2. 在 zookeeper.properties 中設定下列屬性:
    conf_log4j_log4j.appender.rollingfile.maxfilesize=10MB
    # max file size
    conf_log4j_log4j.appender.rollingfile.maxbackupindex=50 # max open files
  3. 確認檔案擁有者為「apigee」使用者:
    chown apigee:apigee /opt/apigee/customer/application/zookeeper.properties
  4. 使用下列指令重新啟動 ZooKeeper:
    /opt/apigee/apigee-service/bin/apigee-service apigee-zookeeper restart