设为首页 收藏本站
查看: 473|回复: 0

[经验分享] How to Install Apache Kafka on CentOS 7

[复制链接]

尚未签到

发表于 2018-11-18 12:08:13 | 显示全部楼层 |阅读模式
  From https://www.vultr.com/docs/how-to-install-apache-kafka-on-centos-7
  Apache Kafka is a scalable and high-throughtput messaging system which is capable of efficiently handling a huge amount of data.
  You can either deploy Kafka on one server or build a distributed Kafka cluster for greater performance. As a starter, this article explains how to install Apache Kafka on one single Vultr CentOS 7 server instance.
Prerequisites:
  Before moving on, you should:

  •   Deploy a Vultr CentOS 7 server instance. Depending on your needs, you may need to increase the available memory.
  •   Use a sudo user to log in from your SSH terminal.
Step 1: Update the CentOS 7 system
  Use the command below to update your system to the latest stable status:
sudo yum update -y && sudo reboot  After the reboot has finished, use the same sudo user to log in again.
Step 2: Install OpenJDK Runtime
  You need to setup a Java virtual machine on your system before you can run Apache Kafka properly. Here, you can install OpenJDK Runtime Environment 1.8.0 using YUM:
sudo yum install java-1.8.0-openjdk.x86_64  Validate your installation with:
java -version  The output should resemble:
openjdk version "1.8.0_91"  
OpenJDK Runtime Environment (build 1.8.0_91-b14)
  
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
  You also need to setup the "JAVA_HOME" and "JRE_HOME" environment variables:
sudo vi /etc/profile  Append the following lines to the original content of the file:
export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk  
export JRE_HOME=/usr/lib/jvm/jre
  Save and quit:
:wq  Reload the profile to put your changes into effect:
source /etc/profileStep 3: Download Apache Kafka
  Download the latest stable version of Apache Kafka from the official website. At the time of writing, it's 0.9.0.1.
cd ~  
wget http://www-us.apache.org/dist/kafka/0.9.0.1/kafka_2.11-0.9.0.1.tgz
  Unzip the archive to a preferred location, such as /opt:
tar -xvf kafka_2.11-0.9.0.1.tgz  
sudo mv kafka_2.11-0.9.0.1 /opt
Step 4: Start and test Apache Kafka
  At this point, Apache Kafka is available on your system. Let's give it a test drive.
4.1: Get into the Kafka directory
cd /opt/kafka_2.11-0.9.0.14.2: Start the Zookeeper server
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties4.3: Modify the configuration of your Kafka server
vi bin/kafka-server-start.sh  Adjust the memory usage according to your specific system parameters. For example, if you are using a Vultr server instance with 768MB memory in the test environment, you need to locate the following line:
export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"  Replace it with:
export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"  Save an quit:
:wq4.4: Start the Kafka server
bin/kafka-server-start.sh config/server.properties  If everything went successfully, you will see several messages about the Kafka server's status, and the last one will read:
INFO [Kafka Server 0], started (kafka.server.KafkaServer)  This means that you have started the Kafka server.
4.5: Create a topic "test" in a new SSH connection
  Open a new SSH connection, use the following commands to create a topic "test":
cd /opt/kafka_2.11-0.9.0.1  
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
  You can view your topics with the following command:
bin/kafka-topics.sh --list --zookeeper localhost:2181  In our case, The output will read:
test4.6: Produce messages using the topic "test"
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test  Using the command above, you can input any number of messages as you wish, such as:
Welcome aboard!  
Bonjour!
  If you receive an error similar to "WARN Error while fetching metadata with correlation> while inputting a message, you'll need to update the server.properties file with the following info:
port = 9092  
advertised.host.name = localhost
4.7: Display messages
  Open a third SSH connection, and then run the following commands:
cd /opt/kafka_2.11-0.9.0.1  
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
  Ta-da! The messages you produced earlier will display in the third SSH connection. Of course, if you input more messages from the second SSH connection now, you will immediately see them on the third SSH connection.
  Finally, you can press Ctrl+C on each SSH connection to stop these scripts.
  That's it. You can learn more about Apache Kafka on the official website. Have fun!



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-636570-1-1.html 上篇帖子: apache安装、配置虚拟主机、配置日志 下篇帖子: 配置伪静态 apache+php
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表