Install and Configure Apache Kafka on Ubuntu 16.04
https://devops.profitbricks.com/tutorials/install-and-configure-apache-kafka-on-ubuntu-1604-1/
Table of Contents
- Introduction
- Features
- Requirements
- Getting Started
- Installing Java
- Install ZooKeeper
- Install and Start Kafka Server
- Testing Kafka Server
- Summary
Introduction
Apache Kafka is an open-source scalable and high-throughput messaging system developed by the Apache Software Foundation written in Scala. Apache Kafka is specially designed to allow a single cluster to serve as the central data backbone for a large environment. It has a much higher throughput compared to other message brokers systems like ActiveMQ and RabbitMQ. It is capable of handling large volumes of real-time data efficiently. You can deploy Kafka on single Apache server or in a distributed clustered environment.
Features
The general features of Kafka are as follows :
- Persist message on disk that provide constant time performance.
- High throughput with disk structures that supporting hundreds of thousands of messages per second.
- Distributed system scales easily with no downtime.
- Supports multi-subscribers and automatically balances the consumers during failure.
This tutorial shows how to install and configure Apache Kafka on a Ubuntu 16.04 server.
Requirements
- A Ubuntu 16.04 server.
- Non-root user account with sudo privilege set up on your server.
Getting Started
Let's start making sure that your Ubuntu 16.04 server is fully up to date.
You can update your server by running the following command:
sudo apt-get update -y
sudo apt-get upgrade -y
Installing Java
Before installing Kafka, you will need to install Java on your system. You can install Oracle JDK 8 using the Webupd8 team PPA repository.
To add the repository, run the following command:
sudo add-apt-repository -y ppa:webupd8team/java
You should see the following output:
gpg: keyring `/tmp/tmpkjrm4mnm/secring.gpg' created
gpg: keyring `/tmp/tmpkjrm4mnm/pubring.gpg' created
gpg: requesting key EEA14886 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpkjrm4mnm/trustdb.gpg: trustdb created
gpg: key EEA14886: public key "Launchpad VLC" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
Next, update the metadata of the new repository by running the following command:
sudo apt-get update
Once you have finished, run the following command to install JDK 8:
sudo apt-get install oracle-java8-installer -y
You can also verify that JDK 8 is installed properly by running the following command:
sudo java -version
You should see the output something like this:
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
Install ZooKeeper
Before installing Apache Kafka, you will need to have zookeeper available and running. ZooKeeper is an open source service for maintaining configuration information, providing distributed synchronization, naming and providing group services.
By default ZooKeeper package is available in Ubuntu's default repository, you can install it by running the following command:
sudo apt-get install zookeeperd
Once installation is finished, it will be started as a daemon automatically. By default ZooKeeper will run on port 2181.
You can test it by running the following command:
netstat -ant | grep :2181
If everything's fine, you should see the following Output:
tcp6 0 0 :::2181 :::* LISTEN
Install and Start Kafka Server
Now that Java and ZooKeeper are installed, it is time to download and extract Kafka from Apache website. You can use wget to download Kafka:
wget http://mirror.fibergrid.in/apache/kafka/0.10.0.1/kafka_2.10-0.10.0.1.tgz
Next, create a directory for Kafka installation:
sudo mkdir /opt/Kafka
cd /opt/Kafka
Extract the downloaded archive using tar command in /opt/Kafka:
sudo tar -xvf kafka_2.10-0.10.0.1.tgz -C /opt/Kafka/
The next step is to start Kafka server, you can start it by running kafka-server-start.sh script located at /opt/Kafka/kafka_2.10-0.10.0.1/bin/ directory.
sudo /opt/Kafka/kafka_2.10-0.10.0.1/bin/kafka-server-start.sh /opt/Kafka/kafka_2.10-0.10.0.1/config/server.properties
You should see the following output, if the server has started successfully:
[2016-08-22 21:43:48,279] WARN No meta.properties file under dir /tmp/kafka-logs/meta.properties (kafka.server.BrokerMetadataCheckpoint)
[2016-08-22 21:43:48,516] INFO Kafka version : 0.10.0.1 (org.apache.kafka.common.utils.AppInfoParser)
[2016-08-22 21:43:48,525] INFO Kafka commitId : a7a17cdec9eaa6c5 (org.apache.kafka.common.utils.AppInfoParser)
[2016-08-22 21:43:48,527] INFO [Kafka Server 0], started (kafka.server.KafkaServer)
[2016-08-22 21:43:48,555] INFO New leader is 0 (kafka.server.ZookeeperLeaderElector$LeaderChangeListener)
You can use nohup with script to start the Kafka server as a background process:
sudo nohup /opt/Kafka/kafka_2.10-0.10.0.1/bin/kafka-server-start.sh /opt/Kafka/kafka_2.10-0.10.0.1/config/server.properties /tmp/kafka.log 2>&1 &
You now have a Kafka server running and listening on port 9092.
Testing Kafka Server
Now, it is time to verify the Kafka server is operating correctly.
To test Kafka, create a sample topic with name "testing" in Apache Kafka using the following command:
sudo /opt/Kafka/kafka_2.10-0.10.0.1/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic testing
You should see the following output:
Created topic "testing".
Now, ask Zookeeper to list available topics on Apache Kafka by running the following command:
sudo /opt/Kafka/kafka_2.10-0.10.0.1/bin/kafka-topics.sh --list --zookeeper localhost:2181
You should see the following output:
testing
Now, publish a sample messages to Apache Kafka topic called testing by using the following producer command:
sudo /opt/Kafka/kafka_2.10-0.10.0.1/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testing
After running above command, enter some messages like "Hi how are you?" press enter, then enter another message like "Where are you?"
Now, use consumer command to check for messages on Apache Kafka Topic called testing by running the following command:
sudo /opt/Kafka/kafka_2.10-0.10.0.1/bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic testing --from-beginning
You should see the following output:
Hi how are you?
Where are you?
With this above testing you have successfully verified that you have a valid Apache Kafka setup with Apache Zookeeper.
Summary
At this point, we have installed, configured, and tested Kafka on a Ubuntu 16.04 server. You can adapt the setup to make use of it in your production environment. To learn more about Kafka check out the Kafka documentation.
Install and Configure Apache Kafka on Ubuntu 16.04的更多相关文章
- Ubuntu 16.04安装ROS Kinetic详细教程 | Tutorial to Install and Configure ROS Kinetic on Ubuntu 16.04
本文首发于个人博客https://kezunlin.me/post/e2780b93/,欢迎阅读! Tutorial to Install and Configure ROS Kinetic on U ...
- How To Install Apache Kafka on Ubuntu 14.04
打算学习kafka ,接触一些新的知识.加油!!! 参考:https://www.digitalocean.com/community/tutorials/how-to-install-apache- ...
- Installing Apache Spark on Ubuntu 16.04
Santosh Srinivas on 07 Nov 2016, tagged onApache Spark, Analytics, Data Minin I've finally got to a ...
- Install .NET Core Runtime on Linux Ubuntu 16.04 x64
原文链接https://www.microsoft.com/net/download/linux-package-manager/ubuntu16-04/runtime-current nstall ...
- Install and Configure Apache Kafka
I. Installation The installation environment must have JDK, verify that you enter: java -version 1. ...
- ubuntu 16.04源码编译和配置caffe详细教程 | Install and Configure Caffe on ubuntu 16.04
本文首发于个人博客https://kezunlin.me/post/b90033a9/,欢迎阅读! Install and Configure Caffe on ubuntu 16.04 Series ...
- Install LAMP Stack On Ubuntu 16.04
原文:http://www.unixmen.com/how-to-install-lamp-stack-on-ubuntu-16-04/ LAMP is a combination of operat ...
- Ubuntu 16.04环境布署小记
本系列文章记录了升级Ubuntu 16.04的布署过程 回到目录 10. 安装Mono, Xsp 当前版本16.04.1的系统源的Mono版本为4.2.1,如需使用最新版本(本文书写时稳定版本为4.6 ...
- Installation Guide Ubuntu 16.04
Beside the installation guide on the main page, here is a guide to install GenieACS off a freshly in ...
随机推荐
- iOS高效编程秘诀—坚持编程习惯
资料源于网络 习惯会影响一个人做事的方式,也会直接影响效率.我经常在项目完成后自我总结,有哪些做得好的,有哪些做得不好的?然后把一些好的流程记录下来,并且重新运用回编程中.那些能够坚持去做的流程,就变 ...
- Zookeeper实现master选举
使用场景 有一个向外提供的服务,服务必须7*24小时提供服务,不能有单点故障.所以采用集群的方式,采用master.slave的结构.一台主机多台备机.主机向外提供服务,备机负责监听主 ...
- 服务端技术进阶(一)web项目的部署(发布)流程
web项目的部署(发布)流程 在myeclipse下新建web工程abc.系统设置默认如下: 项目保存位置:workspace目录\abc.Source文件夹:src,保存所有的java类文件(.ja ...
- 解决Fragment中使用地图,切换会闪一下黑屏的问题
我用的是高德的3D地图,用2D地图无此问题. 从答案来看,大概是SurfactView与Fragment之间的问题.虽然我用的是高德,不过这方法估计对百度地图也有效. 解决方法是,在使用到地图的Act ...
- Dynamics CRM 2011 仪表盘(dashbord)中加入公告(announcement)模块
具体步骤如下: 1.将一下代码黏贴入一个取名叫"announcementsondashboard.htm"的html文件中,当然文件名你随便起无所谓. <span style ...
- Java 截取中英文混合字符串
题目: 编写一个截取字符串的函数,输入为一个字符串和字节数,输出为按字节截取的字符串. 但是要保证汉字不被截半个,如"我ABC"4,应该截为"我AB",输入&q ...
- Java深拷贝浅拷贝
首先,Java中常用的拷贝操作有三个,operator = .拷贝构造函数 和 clone()方法.由于Java不支持运算符重载,我们无法在自己的自定义类型中定义operator=.拷贝构造函数大家应 ...
- lamp 环境配置
LAMP是一个缩写Linux+Apache+MySql+PHP,它指一组通常一起使用来运行动态网站或者服务器的自由软件: * Linux,操作系统:* Apache,网页服务器:* MySQL,数据库 ...
- 深度剖析linux内核万能--双向链表,Hash链表模版
我们都知道,链表是数据结构中用得最广泛的一种数据结构,对于数据结构,有顺序存储,数组就是一种.有链式存储,链表算一种.当然还有索引式的,散列式的,各种风格的说法,叫法层出不穷,但是万变不离其中,只要知 ...
- LeetCode之“链表”:Reorder List
题目链接 题目要求: Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You ...