1リソース
リソース情報 | バージョンナンバー | 備考 |
---|---|---|
サーバ | Centos7 | IP: 192.168.51.4 |
JRE | 1.8 | インストールされているかどうかは無視してください |
動物園の飼育係 | 3.4.10 |
2JDKのインストール
ZookeeperはJDK環境に依存する必要があります。インストールされていない場合は、次のブログ投稿を参照できます。
3zookeeperのインストールと構成
3.1アップロードサーバー
サーバーの/opt/module/software
ディレクトリにファイルをアップロードするには
[root@localhost ~]# cd /opt/module/software/
[root@localhost software]# ll
总用量 323500
-rw-r--r--. 1 root root 34961231 3月 23 14:43 zookeeper-3.4.10.tar.gz.zip
3.2インストール
3.2.1指定されたディレクトリに解凍します
[root@localhost software]# unzip zookeeper-3.4.10.tar.gz.zip
Archive: zookeeper-3.4.10.tar.gz.zip
inflating: zookeeper-3.4.10.tar.gz
[root@localhost software]# tar -zxvf zookeeper-3.4.10.tar.gz -C /opt/module/
3.2.2構成の変更
[root@localhost software]# cd /opt/module/zookeeper-3.4.10/conf/
[root@localhost conf]# mv zoo_sample.cfg zoo.cfg
[root@localhost conf]# vi /opt/module/zookeeper-3.4.10/conf/zoo.cfg
修改内容
dataDir=/opt/module/zookeeper-3.4.10/zkData
创建目录
[root@localhost conf]# mkdir /opt/module/zookeeper-3.4.10/zkData -p
3.2.3構成パラメーターの解釈
# The number of milliseconds of each tick
# 心跳 2000ms
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
# Leader和Follow刚开始通信的时候,初始化最大的延迟时间:10个心跳,一个心跳2000毫秒,20秒,超过说明连接不上
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
# 集群正常启动后,Leader和Follow通信的最大延迟时间: 5 * 2000 毫秒
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
# 日志和数据存储路径
dataDir=/opt/module/zookeeper-3.4.10/zkData
dataLogDir=/opt/module/zookeeper-3.4.10/zkData/log
# the port at which the clients will connect
# 客户端访问服务的端口号 IP + clientPort
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
# 限制连接到zk客户端的数量,根据IP来区分不同的客户端。默认不开启,不限制连接数量
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
# 保留多少个快照文件
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
# 快照和事务日志清理的频率,单位小时
#autopurge.purgeInterval=1
## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
# Jetty使用的端口号
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
1.1。clientPort = 2181:クライアント接続ポート
クライアントがサーバーに接続するポート、つまり外部サービスポート。デフォルトのポートは2181です。
2.2。dataDir:スナップショットファイルが保存されているディレクトリ
簡単に言えば数据文件目录+数据持久化路径
、デフォルトでは、トランザクションログもここに保存されます。同時にパラメーターdataLogDirを構成することをお勧めします。トランザクションログの書き込みパフォーマンスは、zkのパフォーマンスに直接影響します。
3.3。dataLogDir:トランザクションログ出力ディレクトリ
トランザクションログ出力用に別のディスクまたはマウントポイントを構成してみてください。これにより、ZKのパフォーマンスが大幅に向上します。
4.initLimit = 10
リーダーとフォローが最初に通信を開始すると、最大遅延時間(10ハートビート、1ハートビートは2000ミリ秒、20秒)が初期化されます。それを超えると、接続できなくなります。
5.5。tickTime = 2000:通信ハートビートの数
Zookeeperサーバーとクライアント間のハートビート時間(ミリ秒単位)。
Zookeeperが使用する基本的な時間は、ハートビートを維持するためのサーバー間またはクライアントとサーバー間の時間間隔です。つまり、ハートビートはtickTimeごとに送信され、時間単位はミリ秒です。
ハートビートメカニズムに使用され、最小セッションタイムアウト時間をハートビート時間の2倍に設定します。(セッションの最小タイムアウトは2 * tickTimeです)
** 6.syncLimit = 5 **
クラスター内のリーダーとフォロワー間の最大応答時間単位。応答がsyncLimit * tickTimeを超えると、リーダーはフォロワーが停止していると見なし、サーバーリストからフォロワーを削除します。現在の構成は、リーダーとフォローの通信の最大遅延時間です:5 * 2000ミリ秒
3.4テスト開始
3.4.1Zookeeperを起動します
[root@localhost software]# cd /opt/module/zookeeper-3.4.10/bin
[root@localhost bin]# ./zkServer.sh start
3.4.2プロセスの表示
[root@localhost bin]# jps
72935 QuorumPeerMain
72955 Jps
3.4.3ステータスの表示
[root@localhost bin]# /opt/module/zookeeper-3.4.10/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: standalone
3.4.4クライアント
[root@localhost zookeeper-3.4.10]# /opt/module/zookeeper-3.4.10/bin/zkCli.sh
[zk: localhost:2181(CONNECTED) 0]
退出
[zk: localhost:2181(CONNECTED) 0] quit
3.4.5Zookeeperの停止
[root@localhost zookeeper-3.4.10]# /opt/module/zookeeper-3.4.10/bin/zkServer.sh stop
4関連情報
- ブログ投稿は簡単ではありません、注意と賞賛に一生懸命働いたすべての人、ありがとう