zookeeper 單機搭建偽集群

2021-07-26 08:40:12 字數 2754 閱讀 6704

官網:

1、建立目錄

cd /usr/local

mkdir zookeeper-cluster

cd zookeeper-cluster

mkdir server1

cd server1

將解壓的zookeeper資料夾複製到當前目錄,並在當前目錄下建立:

mkdir data

mkdir datalog

cd data

touch myid

echo 1 > myid

2、配置

cd /usr/local/zookeeper-cluster/server1/zookeeper/conf

touch zoo.cfg

內容如下

ticktime=2000 

initlimit=5

synclimit=2

datadir=/usr/local/zookeeper-cluster/server1/data

datalogdir=/usr/local/zookeeper-cluster/server1/datalog

clientport=2181

server.1=127.0

.0.1:2888:3888

server.2=127.0

.0.1:2889:3889

server.3=127.0

.0.1:2890:3890

3、複製server1為server2和server3,並修改其中的zoo.cfg和myid

3個zoo.cfg內容:

# server1

ticktime=2000

initlimit=5

synclimit=2

datadir=/usr/local/zookeeper-cluster/server1/zookeeper/data

datalogdir=/usr/local/zookeeper-cluster/server1/zookeeper/datalog

clientport=2181

server.1=127.0

.0.1:2888:3888

server.2=127.0

.0.1:2889:3889

server.3=127.0

.0.1:2890:3890

# server2

ticktime=2000

initlimit=5

synclimit=2

datadir=/usr/local/zookeeper-cluster/server2/zookeeper/data

datalogdir=/usr/local/zookeeper-cluster/server2/zookeeper/datalog

clientport=2182

server.1=127.0

.0.1:2888:3888

server.2=127.0

.0.1:2889:3889

server.3=127.0

.0.1:2890:3890

# server3

ticktime=2000

initlimit=5

synclimit=2

datadir=/usr/local/zookeeper-cluster/server3/zookeeper/data

datalogdir=/usr/local/zookeeper-cluster/server3/zookeeper/datalog

clientport=2183

server.1=127.0

.0.1:2888:3888

server.2=127.0

.0.1:2889:3889

server.3=127.0

.0.1:2890:3890

myid的內容分別為 1、2、3

分別進入三個伺服器資料夾的解壓目錄的/bin目錄下,啟動服務

cd /usr/local/zookeeper-cluster/server1/zookeeper/bin

./zkserver.sh start

cd /usr/local/zookeeper-cluster/server2/zookeeper/bin

./zkserver.sh start

cd /usr/local/zookeeper-cluster/server3/zookeeper/bin

./zkserver.sh start

4、接入客戶端

隨意進去一台server的/bin目錄下,並連線其他任一台伺服器(此處進去server3連線server1)

單機zookeeper偽集群搭建

2 zookeeper環境配置 解壓 tar zxvf zookeeper 3.4.12.tar.gz 將內容修改 zoo1.cfg檔案內容 ticktime 2000 initlimit 10 synclimit 5 datadir usr local zk data 1 clientport 2...

在單機上實現ZooKeeper偽機群 偽集群部署

zookeeper入門 1 在單機上實現zookeeper偽機群 偽集群部署 標籤 集群 server 伺服器 2011 07 26 10 22 9548人閱讀收藏 舉報 server zookeeper 2 zooker入門系列教程 1 如何在單機上實現zookeeper偽機群 偽集群部署 2 解...

Zookeeper單機偽集群

mkdir p server1 server2 server3 mkdir p data datalog logs 建立乙個myid的檔案,裡面寫入乙個數字,比如我這個是server1,那麼就寫乙個1,server2對應myid檔案就寫入2,server3對應myid檔案就寫個3 複製zoo sam...