阿里云centos7下安裝偽集群kafka

1、新建kafka目錄及下載解壓

mkdir /usr/local/kafka

wget https://mirrors.cnnic.cn/apache/kafka/1.0.0/kafka_2.12-1.0.0.tgz

tar -zxvf?kafka_2.12-1.0.0.tgz

2、到config目錄下復(fù)制兩個(gè)server.properties

cd config/

cp server.properties server1.properties

cp server.properties server2.properties

3、修改三個(gè)properties里的內(nèi)容


注意:

kafka 標(biāo)識(shí) id : 1~3

kafka 端口號(hào)范圍:9001~9003

log.dirs 目錄名稱: log1~log3

zookeeper.connect 三臺(tái)一樣。

4、啟動(dòng) Kafka 集群

bin/kafka-server-start.sh?config/server.properties?&???

bin/kafka-server-start.sh?config/server1.properties?&?

bin/kafka-server-start.sh?config/server2.properties?&??

5、啟動(dòng)可能會(huì)報(bào)錯(cuò):

錯(cuò)誤提示:

Java Hotspot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error='Cannot allocate memory' (errno=12)

#

# There is insufficient memory for the Java Runtime Environment to continue.

# Native memory allocation (malloc) failed to allocate 986513408 bytes for committing reserved memory.

# An error report file with more information is saved as:

# hs_err_pid5535.log

解決辦法:

將 kafka-server-start.sh的

export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"

修改為

export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"

因?yàn)槲业膬?nèi)存是2G

6、測(cè)試

創(chuàng)建一個(gè)topic

bin/kafka-topics.sh --create --zookeeper 172.16.59.150:2181 --replication-factor 3 --partitions 1 --topic test-replicated-topic??

查看topic

bin/kafka-topics.sh --list --zookeeper 172.16.59.150:2183

ps:172.16.59.150是我zookeeper偽集群ip


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容