Confluent/ZooKeeper:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
(创建页面,内容为“== 相關連結 == * Apache ZooKeeper * Confluent”)
 
(未显示同一用户的9个中间版本)
第1行: 第1行:
'''Confluent/ZooKeeper'''指的是[[Confluent]]所包裝的[[Apache ZooKeeper]],裡面有些路徑與設定檔的設法與官方版本不同。
== 設定ZooKeeper ==
修改<code>/etc/kafka/zookeeper.properties</code>,其中IP address需要填寫對應的位置:
<syntaxhighlight lang="ini">
#
tickTime=2000
dataDir=/var/lib/zookeeper/
clientPort=2181
initLimit=5
syncLimit=2
server.1=10.1.1.1:2888:3888
server.2=10.2.2.2:2888:3888
server.3=10.3.3.3:2888:3888
autopurge.snapRetainCount=3
autopurge.purgeInterval=24
</syntaxhighlight>
新增<code>/var/lib/zookeeper/myid</code>,每一台都需要不同,<code>1</code>或<code>2</code>或<code>3</code>:
<syntaxhighlight lang="ini">
1
</syntaxhighlight>
然後修改檔案擁有人:
<syntaxhighlight lang="bash">
sudo chown cp-kafka:confluent /var/lib/zookeeper/myid
</syntaxhighlight>
目前的ZooKeeper(Confluent 2.11版內的ZooKeeper)預設值是使用512 MB的記憶體,但主機有7.5 GB的記憶體,所以會想要讓ZooKeeper可以用7 GB,因此需要修改ZooKeeper的JVM參數。
另外是增加JMX的監控機制,使用Port 32181。
這兩個需要新增<code>/lib/systemd/system/confluent-zookeeper.service.d/30-options.conf</code>(目錄可能需要自己建立):
<syntaxhighlight lang="ini">
[Service]
Environment=JMX_PORT=32181
Environment=KAFKA_HEAP_OPTS="-Xmx7g -Xms7g"
Environment=KAFKA_JMX_OPTS="-Djava.rmi.server.hostname=${hostip} -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.rmi.port=32181 -Dcom.sun.management.jmxremote.port=32181 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
</syntaxhighlight>
對應的指令:
<syntaxhighlight lang="ini">
sudo mkdir /lib/systemd/system/confluent-zookeeper.service.d
echo -e '[Service]\nEnvironment=JMX_PORT=32181\nEnvironment=KAFKA_HEAP_OPTS="-Xmx7g -Xms7g"\nEnvironment=KAFKA_JMX_OPTS="-Djava.rmi.server.hostname=${hostip} -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.rmi.port=32181 -Dcom.sun.management.jmxremote.port=32181 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"' | sudo tee /lib/systemd/system/confluent-zookeeper.service.d/30-options.conf
</syntaxhighlight>
理論上就可以啟動了:
<syntaxhighlight lang="bash">
sudo systemctl daemon-reload
sudo service confluent-zookeeper start
sudo service confluent-zookeeper status
</syntaxhighlight>
可以看輸出的資訊判斷系統狀態:
<syntaxhighlight lang="bash">
echo stat | nc 127.0.0.1 2181
</syntaxhighlight>
或是直接透過指令操作測試:
<syntaxhighlight lang="bash">
zookeeper-shell 127.0.0.1:2181
</syntaxhighlight>
接下來可以將TCP Port 2181建立對應的TCP Load Balancer(像是用ELB)。
=== 認證 ===
如果需要讓ZooKeeper啟用認證,需要先建立對應的帳號與密碼字串(這個例子裡面是<code>admin</code>與<code>password</code>):
<syntaxhighlight lang="bash">
java -cp "$(echo /usr/share/java/kafka/* | sed 's/ /:/g')" org.apache.zookeeper.server.auth.DigestAuthenticationProvider admin:password
</syntaxhighlight>
會產生像是這樣的輸出,其中後面的那串值是重點:
<syntaxhighlight lang="text">
admin:password->admin:bjkZ9W+M82HUZ9xb8/Oy4cmJGfg=
</syntaxhighlight>
<code>-></code>後面是將密碼處理過的字串,直接放進設定內:
<syntaxhighlight lang="bash">
KAKFA_OPTS=-Dzookeeper.DigestAuthenticationProvider.superDigest=admin:bjkZ9W+M82HUZ9xb8/Oy4cmJGfg=
</syntaxhighlight>
這樣就可以在<code>zookeeper-shell</code>裡面認證:
<syntaxhighlight lang="bash">
addauth digest admin:password
</syntaxhighlight>
== 相關連結 ==
== 相關連結 ==


* [[Apache ZooKeeper]]
* [[Apache ZooKeeper]]
* [[Confluent]]
* [[Confluent]]
== 外部連結 ==
* [https://docs.confluent.io/current/zookeeper/operations.html ZooKeeper Operations] {{en}}
[[Category:軟體]]

2019年5月2日 (四) 07:39的版本

Confluent/ZooKeeper指的是Confluent所包裝的Apache ZooKeeper,裡面有些路徑與設定檔的設法與官方版本不同。

設定ZooKeeper

修改/etc/kafka/zookeeper.properties,其中IP address需要填寫對應的位置:

#
tickTime=2000
dataDir=/var/lib/zookeeper/
clientPort=2181
initLimit=5
syncLimit=2
server.1=10.1.1.1:2888:3888
server.2=10.2.2.2:2888:3888
server.3=10.3.3.3:2888:3888
autopurge.snapRetainCount=3
autopurge.purgeInterval=24

新增/var/lib/zookeeper/myid,每一台都需要不同,123

1

然後修改檔案擁有人:

sudo chown cp-kafka:confluent /var/lib/zookeeper/myid

目前的ZooKeeper(Confluent 2.11版內的ZooKeeper)預設值是使用512 MB的記憶體,但主機有7.5 GB的記憶體,所以會想要讓ZooKeeper可以用7 GB,因此需要修改ZooKeeper的JVM參數。

另外是增加JMX的監控機制,使用Port 32181。

這兩個需要新增/lib/systemd/system/confluent-zookeeper.service.d/30-options.conf(目錄可能需要自己建立):

[Service]
Environment=JMX_PORT=32181
Environment=KAFKA_HEAP_OPTS="-Xmx7g -Xms7g"
Environment=KAFKA_JMX_OPTS="-Djava.rmi.server.hostname=${hostip} -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.rmi.port=32181 -Dcom.sun.management.jmxremote.port=32181 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"

對應的指令:

sudo mkdir /lib/systemd/system/confluent-zookeeper.service.d
echo -e '[Service]\nEnvironment=JMX_PORT=32181\nEnvironment=KAFKA_HEAP_OPTS="-Xmx7g -Xms7g"\nEnvironment=KAFKA_JMX_OPTS="-Djava.rmi.server.hostname=${hostip} -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.rmi.port=32181 -Dcom.sun.management.jmxremote.port=32181 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"' | sudo tee /lib/systemd/system/confluent-zookeeper.service.d/30-options.conf

理論上就可以啟動了:

sudo systemctl daemon-reload
sudo service confluent-zookeeper start
sudo service confluent-zookeeper status

可以看輸出的資訊判斷系統狀態:

echo stat | nc 127.0.0.1 2181

或是直接透過指令操作測試:

zookeeper-shell 127.0.0.1:2181

接下來可以將TCP Port 2181建立對應的TCP Load Balancer(像是用ELB)。

認證

如果需要讓ZooKeeper啟用認證,需要先建立對應的帳號與密碼字串(這個例子裡面是adminpassword):

java -cp "$(echo /usr/share/java/kafka/* | sed 's/ /:/g')" org.apache.zookeeper.server.auth.DigestAuthenticationProvider admin:password

會產生像是這樣的輸出,其中後面的那串值是重點:

admin:password->admin:bjkZ9W+M82HUZ9xb8/Oy4cmJGfg=

->後面是將密碼處理過的字串,直接放進設定內:

KAKFA_OPTS=-Dzookeeper.DigestAuthenticationProvider.superDigest=admin:bjkZ9W+M82HUZ9xb8/Oy4cmJGfg=

這樣就可以在zookeeper-shell裡面認證:

addauth digest admin:password

相關連結

外部連結