kafka单机版安装
Posted wang_wei123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了kafka单机版安装相关的知识,希望对你有一定的参考价值。
192.168.1.183 CentOS 6.5 2.6.32-431.el6.x86_64
三部曲:jdk—zookeeper—kafka
严格的安装顺序
wget http://apache.fayea.com/kafka/0.10.0.0/kafka_2.10-0.10.0.0.tgz
wget http://apache.fayea.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
1、基本的系统操作
关闭防火墙、时间同步、相关工具..........
编辑/etc/hosts文件
[[email protected] zookeeper-3.4.6]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
192.168.1.187 nginxhttp
2、安装jdk
[[email protected] /]#cd /usr/local/src/
[[email protected] src]#tar -zxvf jdk-7u79-linux-x64.tar.gz
[[email protected] src]#mv jdk1.7.0_79 /home/jdk1.7.0_79
[[email protected] src]#vim /etc/profile (末尾添加环境变量)
JAVA_HOME=/home/jdk1.7.0_79
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
echo $JAVA_HOME
[[email protected] src]# source /etc/profile
[[email protected] src]#java -version (检查版本)
3、安装zookeeper
[[email protected] src]#tar -zxvf zookeeper-3.4.6.tar.gz
[[email protected] src]#mv zookeeper-3.4.6 /home/zookeeper-3.4.6
[[email protected] src]#cd zookeeper-3.4.6/
[[email protected] src]#cd conf/
[[email protected] conf]# cp zoo_sample.cfg zoo.cfg
[[email protected] conf]# mkdir /tmp/zookeeper (数据存放目录)
[[email protected] conf]#cd ..
[[email protected] zookeeper-3.4.6]# bin/zkServer.sh start (启动zookeeper)
[[email protected] zookeeper-3.4.6]#netstat -tunpl
tcp 0 0 :::2181 :::* LISTEN 1178/java
3、安装kafka
[[email protected] /]# cd /usr/local/src/
[[email protected] src]#tar -zxvf kafka_2.10-0.10.0.0.tgz
[[email protected] src]#mv kafka_2.10-0.10.0.0 /home/kafka_2.10-0.10.0.0
[[email protected] src]#cd /home/kafka_2.10-0.10.0.0/
[[email protected] kafka_2.10-0.10.0.0]#bin/kafka-server-start.sh config/server.properties & (启动)
[[email protected] kafka_2.10-0.10.0.0]#netstat -tunpl
tcp 0 0 :::9092 :::* LISTEN 1199/java
---------------
4、线上调整(重点关注):
[[email protected] ~]# cat /etc/hosts 末尾添加ip、主机名对应关系
192.168.1.183 kafka
[[email protected] config]# cat server.properties 修改参数
advertised.host.name=192.168.1.183
属性:advertised.host.name。官方文档里的备注信息表明,该字段的值是生产者和消费者使用的。如果没有设置,则会取host.name的值,默认情况下,该值为localhost。思考一下,如果生产者拿到localhost这个值,只往本地发消息,必然会报错(因为本地没有kafka服务器)。
以上是关于kafka单机版安装的主要内容,如果未能解决你的问题,请参考以下文章