zookeeper zoo.cfg配置文件
生活随笔
收集整理的這篇文章主要介紹了
zookeeper zoo.cfg配置文件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、zookeeper的配置文件? zoo.cfg ? 配置文件是我們安裝zookeeper的時候復制 重命名出來的文件 ?命令: cp zoo_smaple.cfg zoo.cfg zkServer.sh 獲取執行 進入zookeeper 查看配置文件 cd /myapp/zookeeper/conf 執行命令 查看配置文件信息 命令:vim zoo.cfg 這是基本的配置文件。 二、zoo.cfg 配置項 1. 查找配置項 zookeeper官網:http://zookeeper.apache.org/doc/r3.4.11/zookeeperAdmin.html#sc_configuration 2. 最小化配置 Minimum Configuration clientPort: client需要連接的服務器端口好 dataDir: 默認情況下,zookeeper的事務日志 和 數據快照 都會保存在 dataDir 目錄下 a. 事務日志 類似 => redis 【aof 模式】 => write,append ...【aof命令】 b. 快照 類似 => redis 【rdb】 snapcount: 事務日志達到某數量 ,生成一次快照 tickTime: zookeeper心跳時間 【2000】 檢測 dataLogDir: 用來設置事務日志的的path ? 3.修改默認的配置 dataDir=/myapp/zookeeper/log1 dataLogDir=/myapp/zookeeper/log2 新建log1 log2 文件 修改配置: dataDir=/myapp/zookeeper/log1 ,dataLogDir=/myapp/zookeeper/log2 然后重啟 zookeeper? 如果無法關閉可以通過殺死進程的方式重啟(必須要重啟才能生效配置) 命令?kill -9 4225 殺死進程 (4225?) 是進程編號; 可以通過 ??命令 netstat -tlnp 查詢; 重啟zk ./zkServer.sh ?start 為什么dataDir 沒有快照? 因為事務日志達到10W閥值 的時候才 生成一次快照(默認值是10W) 所以我們需要設置配置snapCount的值 官方原文: snapCount (Java system property:?zookeeper.snapCount) ZooKeeper records its transactions using snapshots and a transaction log (think write-ahead log).The number of transactions recorded in the transaction log before a snapshot can be taken (and the transaction log rolled) is determined by snapCount. In order to prevent all of the machines in the quorum from taking a snapshot at the same time, each ZooKeeper server will take a snapshot when the number of transactions in the transaction log reaches a runtime generated random value in the [snapCount/2+1, snapCount] range.The default snapCount is 100,000. 修改zoo.cfg文件 命令: vim zoo.cfg snapCount=2 重啟zk就可以了 minSessionTimeout maxSessionTimeout 【txp長連接 + session機制 + watcher】 默認情況下 : tickTime=2秒 min=4s max=40s maxClientCnxns : 設置為0 禁用 為了防止dos攻擊 , 一個ip默認60個長連接 (連接zookeeper) 一般的,機器 放 60個應用程序 一個程序連接一個zookeeper autopurge.snapRetainCount =3 autopurge.purgeInterval =1 【一個小時檢測一次,最多保留最近的3個事務日志 和 事務快照】 快照和事務日志的清理,如果快照個數太多, 照成空間浪費 log4j 日志 zookeeper的一些運行日志, 輸出日志 如果將zookeeper的這些日志放到指定目錄,需要修改配置文件 zkEnv.sh 命令:vim zkEnv.sh 修改上面的路徑就可以了
轉載于:https://www.cnblogs.com/dragon-L/p/8532287.html
總結
以上是生活随笔為你收集整理的zookeeper zoo.cfg配置文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 企业的公章没有备案号正常吗?
- 下一篇: linux如何挂载U盘?