Confluent/ZooKeeper:修订间差异
跳到导航
跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
(→相關連結) |
|||
(未显示同一用户的6个中间版本) | |||
第1行: | 第1行: | ||
'''Confluent/ZooKeeper'''指的是[[Confluent]]所包裝的[[Apache ZooKeeper]],裡面有些路徑與設定檔的設法與官方版本不同。 | |||
== 設定ZooKeeper == | == 設定ZooKeeper == | ||
第10行: | 第12行: | ||
initLimit=5 | initLimit=5 | ||
syncLimit=2 | syncLimit=2 | ||
server.1=1. | server.1=10.1.1.1:2888:3888 | ||
server.2= | server.2=10.2.2.2:2888:3888 | ||
server.3= | server.3=10.3.3.3:2888:3888 | ||
autopurge.snapRetainCount=3 | autopurge.snapRetainCount=3 | ||
autopurge.purgeInterval=24 | autopurge.purgeInterval=24 | ||
第29行: | 第31行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
目前的ZooKeeper(Confluent 2.11版內的ZooKeeper)預設值是使用512 MB的記憶體,但主機有7.5 GB的記憶體,所以會想要讓ZooKeeper可以用7 GB,因此需要修改ZooKeeper的JVM參數。這 | 目前的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"> | <syntaxhighlight lang="ini"> | ||
[Service] | [Service] | ||
Environment=JMX_PORT=32181 | |||
Environment=KAFKA_HEAP_OPTS="-Xmx7g -Xms7g" | 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> | ||
第72行: | 第87行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<code>-></code> 後 面是將密碼處理過的字串, 直接放進設定內: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> |
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
,每一台都需要不同,1
或2
或3
:
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启用认证,需要先建立对应的账号与密码字串(这个例子里面是admin
与password
):
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
相关连结
外部链接
- ZooKeeper Operations (英文)