In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to use docker to build kafka environment". In daily operation, I believe many people have doubts about how to use docker to build kafka environment. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use docker to build kafka environment". Next, please follow the editor to study!
Recently, I learned about kafka. In order to facilitate the construction of the environment, I used docker for deployment.
You need to install the environment of docker first. Requires the operating system to be a linux 64-bit system.
Installation of docker (suitable for rpm/deb installation):
Curl-fsSL https://get.docker.com/ | sh
Installation of docker-compose:
Curl-L https://github.com/docker/compose/releases/download/1.7.0/docker-compose-`uname-s`-`uname-m` > / usr/local/bin/docker-composechmod + x / usr/local/bin/docker-composeKafka Image
Dockerfile
Dockerfile is used to describe the production process of an image. Write the corresponding Dockerfile according to kafka's tutorials.
The basic image uses the version of centos6, but other versions can be used as needed.
FROM index.alauda.cn/tutum/centos:centos6RUN yum install-y wgetRUN wget-- no-check-certificate-- no-cookies-- header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.rpmRUN rpm-ivh jdk-8u91-linux-x64.rpmRUN mkdir-p / kafka & & cd / kafka & & wget http://mirrors.cnnic.cn/apache/kafka/0.9.0.0 / kafka_2.11-0.9.0.0.tgz & & tar-xzf kafka_2.11-0.9.0.0.tgz & & cd kafka_2.11-0.9.0.0WORKDIR / kafka/kafka_2.11-0.9.0.0
With such a Dockerfile, you can mirror it locally or using the public cloud. If you make it locally, you can use this command:
Docker build-t index.alauda.cn/xuxinkun/kafka.
I used Lingqueyun's mirror service for build, which can be viewed here.
Docker-Compose
Now that you have the mirror, you need to start the service. Here, docker's orchestration service docker-compose is used for choreography.
Kafka mainly includes two services, zookeeper and kafka. So you need to start two services respectively. Here the two services will directly use the host network. Write the docker-compose.yaml as follows:
Zk: image: index.alauda.cn/xuxinkun/kafka net: host stdin_open: true tty: true command: bin/zookeeper-server-start.sh config/zookeeper.propertieskafka: image: index.alauda.cn/xuxinkun/kafka net: host stdin_open: true tty: true command: bin/kafka-server-start.sh config/server.properties
Start the service
You can now start all services with one command:
[root@node1 Dockerfile] # docker-compose up-dCreating dockerfile_kafka_1Creating dockerfile_zk_1
View service status
View the status of the service.
[root@node1 Dockerfile] # docker-compose psName Command State Ports-dockerfile_kafka_1 bin/kafka-server-start.sh... Up dockerfile_zk_1 bin/zookeeper-server-start... Up
Of course, you can also use docker ps-a to view.
Out of Service
[root@node1 Dockerfile] # docker-compose stop zk kafkaStopping dockerfile_kafka_1... DoneStopping dockerfile_zk_1... Done
Delete a service
[root@node1 Dockerfile] # docker-compose rm zk kafka at this point, the study on "how to use docker to build a kafka environment" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.