centos7 kafka 설치 및 토픽확인
Posted by Albert 806Day 19Hour 45Min 18Sec ago [2023-02-03]
virtualBox상 centos7에서 kafka 간단히 설치하여 보았다.
1. root 계정이 아닌 kafka계정생성
adduser kafka
passwd kafka
(신규생성된 kafka계정의 비번 생성)
2. kafka 다운로드
cd /home
wget https://dlcdn.apache.org/kafka/3.3.2/kafka_2.13-3.3.2.tgz
(현재기준 최신버전다운로 https://dlcdn.apache.org/kafka/ 에서 최신 버전 확인가능하니 필요한걸로 다운하셈)
tar -xvf kafka_2.13-3.3.2.tgz
3. 앞축해제 후 생성된 kafka_2.13-3.3.2 폴더로 이동
cd kafka_2.13-3.3.2
4. zookeeper 실행
주키퍼는 kafka 앞축풀면 안에 있어서 바로 사용하면 된다.
개념이라면 간단하게 분산관리 어플리 케이션이라는것정도 즉 여러서버상 클러스터링하여 사용할때
주키퍼에서 그룹관리 동기화 등 여러모로 알아서 관리해주는 코디네이션 시스템이다.
실행방법은 아주 간단하다.
=============
zookeeper 실행
=============
./bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
=============
zookeeper 종료
=============
./bin/zookeeper-server-stop.sh
=============
실행여부 확인
=============
netstat -an | grep 2181
5. kafka 시작
=============
kafka 실행
=============
./bin/kafka-server-start.sh -daemon config/server.properties
=============
kafka
=============
./bin/kafka-server-stop.sh
=============
실행여부 확인
=============
netstat -an | grep 9092
정상적으로 9092포트 올라온걸 보면 kafka서비스가 정상 진행되고 있다고 생각해도 된다.
6 kafka 토픽 생성,삭제,토픽 리스트 확인
토픽생성
./bin/kafka-topics.sh --create --topic test-topic-1 --partitions 1 --replication-factor 1 --bootstrap-server localhost:9092
토픽 리스트 확인
./bin/kafka-topics.sh --list --bootstrap-server localhost:9092
test-topic-1
토픽 삭제
./bin/kafka-topics.sh --delete --topic test-topic-1 --bootstrap-server localhost:9092
8 topic 관련 명령어 실행시 아래와 같은 애러뜰시
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N Error while executing topic command : Replication factor: 3 larger than available brokers: 0. |
메모리 설정 문제로서 가상머신 메모리 설정이 낮아서 나타나는 문제였다.
해결방안
vi ./bin/kafka-server-start.sh
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
'메모리 할당 오류로 인한 JVM메모리 조정
'export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"
fi
vi ./bin/zookeeper-server-start.sh
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"
fi