zookeeper本機偽集群模式配置,坑人的配置。

2021-06-25 22:39:43 字數 4124 閱讀 2193

1.zookeeper解壓的路徑由以下可知:

/home/doctor/opt/zookeeper-3.4.6/conf

本地設定3個zookeeper,配置檔案為:

zoo2.cfg  zoo3.cfg  zoo.cfg。

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.

datadir=/home/doctor/zookeeper/d_1

# the port at which the clients will connect

clientport=2181

# the maximum number of client connections.

# increase this if you need to handle more clients

#maxclientcnxns=60

## be sure to read the maintenance section of the 

# administrator guide before turning on autopurge.

## ## 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

server.1=localhost:2887:3887

server.2=localhost:2888:3888

server.3=localhost:2889:3889

zoo2.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.

datadir=/home/doctor/zookeeper/d_2

# the port at which the clients will connect

clientport=2182

# the maximum number of client connections.

# increase this if you need to handle more clients

#maxclientcnxns=60

## be sure to read the maintenance section of the 

# administrator guide before turning on autopurge.

## ## 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

server.1=localhost:2887:3887

server.2=localhost:2888:3888

server.3=localhost:2889:3889

zoo3.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.

datadir=/home/doctor/zookeeper/d_3

# the port at which the clients will connect

clientport=2183

# the maximum number of client connections.

# increase this if you need to handle more clients

#maxclientcnxns=60

## be sure to read the maintenance section of the 

# administrator guide before turning on autopurge.

## ## 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

server.1=localhost:2887:3887

server.2=localhost:2888:3888

server.3=localhost:2889:3889

注意:大家都知道,關鍵是clientport 不能相同。

其次,讓我啟動失敗的配置那就是:datadir=/home/doctor/zookeeper/d_x (d_1,d_2,d_3)

裡面的配置。

大家應該知道在此檔案下需要建立myid檔案,裡面的內容就是對應server.1=localhost:2887:3887  裡面的server.1中的1.例如:

[doctor@localhost d_1]$ pwd

/home/doctor/zookeeper/d_1

[doctor@localhost d_1]$ ls

myid  version-2  zookeeper_server.pid

[doctor@localhost d_1]$ 

[doctor@localhost d_1]$ cat myid 

1內容是1,

問題根源:我寫入的內容為1,不後面加了空格,就報錯,啟動不了。

所以,。。。。應該程式讀取配置檔案時候,就應該trim一下吧。。

偽集群模式zookeeper

安裝 tar zxvf zookeeper 3.4.6.tar.gz 複製三份 zookeeper 副本作為偽集群 cp r zookeeper 3.4.6 usr local zookeeper01 cp r zookeeper 3.4.6 usr local zookeeper02 cp r z...

搭建zookeeper偽集群

搭建zookeeper偽集群 2 將zookeeper壓縮包進行解壓 3 在zookeeper根目錄下新建data資料夾 4 在data資料夾內新建myid檔案,並在myid檔案內寫入1 5 將conf zoo sample.cfg檔案複製乙份,重新命名為zoo.cfg 6 開啟zoo.cfg檔案,...

Zookeeper偽集群搭建

搭建要求 真實的集群是需要部署在不同的伺服器上的,但是在我們測試時同時啟動十幾個虛擬機器記憶體會吃不消,所以我們通常會搭建偽集群,也就是把所有的服務都搭建在一台虛擬機器上,用埠進行區分。我們這裡要求搭建乙個三個節點的zookeeper集群 偽集群 在zookeeper集群中,每個節點都會投票,如果某...