1.Zoo.cfgの構成
前の記事を見ると、3つの仮想マシン上に3つの仮想マシンを構築し
su zookeeper
、zookeeperアカウントに切り替え
、3つの仮想マシン/usr/local/zookeeper-3.4.14/conf/zoo.cfg
ファイルを変更し、次の構成を追加したと思います。
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
# zk 数据目录
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
# 配置每个示例的IP
server.1=192.168.56.101:2888:3888
server.2=192.168.56.102:2888:3888
server.3=192.168.56.103:2888:3888
各ポート番号の役割:
2181:クライアントにサービスを提供するポート、
2888:クラスター内の通信に
使用されるポート、3888:クラスター内で選択されたリーダーによって使用されるポート。
このコマンドを使用して、zookeeper-3.4.14アプリケーションディレクトリを他の2つのインスタンスに転送できます。
scp -r zookeeper 192.168.56.102:`pwd`
scp -r zookeeper 192.168.56.103:`pwd`
2. myid
3つの仮想マシンのzookeeperデータディレクトリを入力します。/tmp/zookeeper
それぞれ、以下を実行します。
echo 1 > myid
echo 2 > myid
echo 3 > myid
zoo.cfgの構成に対応しますserver.1、server.2、server.3
。
3.ファイアウォールをオフにします
クラスタ間の通信を容易にするために、ファイアウォールを直接オフにします。
systemctl stop firewalld.service
最終
各仮想マシンのzookeeperを順番に起動します。
./zkServer.sh start
3つの例のステータスを見てみ
ましょう。驚いたかどうか尋ねてください。