Kafka 0.8.1.1에서 주제 삭제
test
Apache Kafka 0.8.1.1에서 주제를 삭제해야합니다 .
여기 문서에 표현 된대로 다음을 실행했습니다.
bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic test
그러나 이로 인해 다음 메시지가 표시됩니다.
Command must include exactly one action: --list, --describe, --create or --alter
이 주제를 어떻게 삭제할 수 있습니까?
항목 삭제가 0.8.1.1에서 항상 작동하는 것은 아닙니다.
다음 릴리스 0.8.2에서 삭제가 작동합니다.
kafka-topics.sh --delete --zookeeper localhost:2181 --topic your_topic_name
Topic your_topic_name is marked for deletion.
Note: This will have no impact if delete.topic.enable is not set to true.
삭제 명령은 알려진 버그 ( https://issues.apache.org/jira/browse/KAFKA-1397 )로 인해 Kafka 0.8.1.x에서 공식적으로 문서화되지 않은 것 같습니다 .
그럼에도 불구하고 명령은 여전히 코드에 포함되어 있으며 다음과 같이 실행할 수 있습니다.
bin/kafka-run-class.sh kafka.admin.DeleteTopicCommand --zookeeper localhost:2181 --topic test
그 동안 버그가 수정되었으며 이제 Kafka 0.8.2.0에서 다음과 같이 삭제 명령을 공식적으로 사용할 수 있습니다.
bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic test
$ {kafka_home} /config/server.properties에 아래 줄을 추가합니다.
delete.topic.enable=true
새 구성으로 kafka 서버를 다시 시작하십시오.
${kafka_home}/bin/kafka-server-start.sh ~/kafka/config/server.properties
원하는 주제를 삭제하십시오.
${kafka_home}/bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic daemon12
Andrea가 맞습니다. 명령 줄을 사용하여 할 수 있습니다.
그리고 우리는 여전히 그것을 프로그램 할 수 있습니다.
ZkClient zkClient = new ZkClient("localhost:2181", 10000);
zkClient.deleteRecursive(ZkUtils.getTopicPath("test2"));
실제로 Kafka 0.8.1.1에서 주제를 삭제하지 않는 것이 좋습니다. 이 방법으로이 토픽을 삭제할 수 있지만 사육사 로그를 확인하면 삭제가 엉망이됩니다.
test
zookeeper 셸 명령 ( zookeeper-shell.sh
) 에서 특정 kafka 주제 (예 :)를 삭제할 수 있습니다 . 아래 명령을 사용하여 주제를 삭제하십시오.
rmr {path of the topic}
예:
rmr /brokers/topics/test
Kafka에서 하나 이상의 주제를 삭제하는 단계
kafka에서 토픽을 삭제하려면 Kafka 서버에서 삭제 옵션을 활성화해야합니다.
1. Go to {kafka_home}/config/server.properties
2. Uncomment delete.topic.enable=true
Kafka에서 하나의 주제를 삭제하려면 다음 명령을 입력하십시오.
kafka-topics.sh --delete --zookeeper localhost : 2181 --topic
kafka에서 둘 이상의 주제를 삭제하려면
(테스트 목적에 적합합니다. 여러 주제를 만들고 다른 시나리오에서 삭제해야했습니다)
- Stop the Kafka Server and Zookeeper
- go to /tmp folder where the logs are stored and delete the kafkalogs and zookeeper folder manually
- Restart the zookeeper and kafka server and try to list topics,
bin/kafka-topics.sh --list --zookeeper localhost:2181
if no topics are listed then the all topics have been deleted successfully.If topics are listed, then the delete was not successful. Try the above steps again or restart your computer.
This steps will delete all topics and data
- Stop Kafka-server and Zookeeper-server
- Remove the tmp data directories of both services, by default they are C:/tmp/kafka-logs and C:/tmp/zookeeper.
- then start Zookeeper-server and Kafka-server
The command:
bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic test
unfortunately only marks topic for deletion.
Deletion does not happen.
That makes troubles, while testing any scripts, which prepares Kafka configuration.
Connected threads:
- Purge Kafka Queue
- Is there a way to delete all the data from a topic or delete the topic before every run?
Adding to above answers one has to delete the meta data associated with that topic in zookeeper consumer offset path.
bin/zookeeper-shell.sh zookeeperhost:port
rmr /consumers/<sample-consumer-1>/offsets/<deleted-topic>
Otherwise the lag will be negative in kafka-monitoring tools based on zookeeper.
As mentioned in doc here
Topic deletion option is disabled by default. To enable it set the server config delete.topic.enable=true Kafka does not currently support reducing the number of partitions for a topic or changing the replication factor.
Make sure delete.topic.enable=true
bin/kafka-topics.sh –delete –zookeeper localhost:2181 –topic <topic-name>
If you have issues deleting the topics, try to delete the topic using:
$KAFKA_HOME/bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic your_topic_name
command. Then in order to verify the deletion process, go to the kafka logs directory which normally is placed under /tmp/kafka-logs/
, then delete the your_topic_name
file via rm -rf your_topic_name
command.
Remember to monitor the whole process via a kafka management tool like Kafka Tool
.
The mentioned process above will remove the topics without kafka server restart.
Step 1: Make sure you are connected to zookeeper and Kafka running
Step 2: To delele the Kafka topic run Kafka-topic (Mac) or Kafka-topic.sh if use (linux/Mac) add the port and --topic with name of your topic and --delete it just delete the topic with success.
# Delete the kafka topic
# it will delete the kafka topic
kafka-topics --zookeeper 127.0.0.1:2181 --topic name_of_topic --delete
# or
kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic name_of_topic --delete
First, you run this command to delete your topic:
$ bin/kafka-topics.sh --delete --bootstrap-server localhost:9092 --topic <topic_name>
List active topics to check delete completely:
$ bin/kafka-topics.sh --list --bootstrap-server localhost:9092
참고URL : https://stackoverflow.com/questions/24287900/delete-topic-in-kafka-0-8-1-1
'development' 카테고리의 다른 글
CrudRepository # findOne 메서드 누락 (0) | 2020.09.17 |
---|---|
경고 : 헤더 정보를 수정할 수 없습니다. 헤더는 이미 ERROR [duplicate]에 의해 전송되었습니다. (0) | 2020.09.17 |
Thymeleaf : 조건문을 사용하여 CSS 클래스를 동적으로 추가 / 제거하는 방법 (0) | 2020.09.17 |
PHP 시스템의 로컬 IP를 얻는 방법 (0) | 2020.09.17 |
파이썬에서 "역전 된"목록을 만드는 가장 좋은 방법은 무엇입니까? (0) | 2020.09.17 |