Apache Zookeeper 維護工作

四個字母指令

Apache ZooKeeper 提供多個「四個字母」指令,可協助您判斷 ZooKeeper 選民和觀察者節點的目前狀態。這些指令可使用 nctelnet 或其他可傳送指令至特定通訊埠的公用程式來叫用。如要進一步瞭解四字母指令,請參閱 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