参考jdk的安装,需要jdk1.6+。
成都创新互联专注于管城企业网站建设,响应式网站设计,商城网站建设。管城网站建设公司,为管城等地区提供建站服务。全流程定制网站设计,专业设计,全程项目跟踪,成都创新互联专业和态度为您提供的服务下载地址:http://mirrors.hust.edu.cn/apache/kafka/0.10.0.1/kafka_2.11-0.10.0.1.tgz
$ tar zvxf kafka_2.11-0.10.0.1.tgz
$ cp -r kafka_2.11-0.10.0.1 /software/
$ ln -s /software/kafka_2.11-0.10.0.1/software/kafka
修改/etc/profile文件内容:
export KAFKA_HOME=/software/kafka
export PATH=$KAFKA_HOME/bin:$FLUME_HOME/bin:$ZOOKEEPER_HOME/bin:$HBASE_HOME/bin:
$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH
export CLASSPATH=.:$KAFKA_HOME/libs/*:$FLUME_HOME/lib/*:$HBASE_HOME/lib/*:$JAVA_
HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
1)、启动kafka前要先启动zookeeper
$ zookeeper-server-start.sh /software/kafka/config/zookeeper.properties &
2)、启动kafka
$ kafka-server-start.sh /software/kafka/config/server.properties &
$ kafka-topics.sh --create --zookeeperlocalhost:2181 --replication-factor 1 --partitions 1 --topic test
查询创建的topic
$ kafka-topics.sh --list --zookeeperlocalhost:2181
$ kafka-console-producer.sh --broker-listlocalhost:9092 --topic test
This is a message
This is another message
$ kafka-console-consumer.sh --bootstrap-serverlocalhost:9092 --zookeeper localhost:2181 --topic test --from-beginning
This is a message
This is another message
$ cd /software/kafka/config/
$ cp server.properties s1.properties
$ cp server.properties s2.properties
$ cp server.properties s3.properties
config/s1.properties:
broker.id=1
listeners=PLAINTEXT://:9093
log.dir=/tmp/kafka-logs-1
config/s2.properties:
broker.id=2
listeners=PLAINTEXT://:9094
log.dir=/tmp/kafka-logs-2
config/s3.properties:
broker.id=3
listeners=PLAINTEXT://:9095
log.dir=/tmp/kafka-logs-3
$ kafka-server-start.sh /software/kafka/config/s1.properties &
$ kafka-server-start.sh /software/kafka/config/s2.properties &
$ kafka-server-start.sh /software/kafka/config/s3.properties&
$ kafka-topics.sh --create--zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic my-replicated-topic
查看topic描述
$ kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic
$ kafka-console-producer.sh --broker-listlocalhost:9093 --topic my-replicated-topic
my test msg 1
my test msg 2
my test msg 3
$ kafka-console-consumer.sh--zookeeper localhost:2181 --from-beginning --topic my-replicated-topic
$ ps -ef| grep s1.properties
kill pid
$>kafka-topics.sh --describe --zookeeperlocalhost:2181 --topic my-replicated-topic
Topic:my-replicated-topic PartitionCount:1 ReplicationFactor:3 Configs:
Topic: my-replicated-topic Partition: 0 Leader: 2 Replicas:1,2,0 Isr: 2,0
$>kafka-console-consumer.sh--zookeeper localhost:2181 --from-beginning --topic my-replicated-topic
my test message 1
my test message 2
$ xsync kafka_2.11-0.10.0.1/
$ xsync kafka
#xsync /etc/profile
broker.id=203 #修改broker的id
log.dirs=/home/hadoop/kafka/logs #修改日志的存放路径
zookeeper.connect=s201:2181,s202:2181,s203:2181 #修改zookeeper的连接路径
到部署kafka每台服务器上面启动kafka集群
$ kafka-server-start.sh /software/kafka/config/server.properties &
$ kafka-server-start.sh /software/kafka/config/server.properties &
$ kafka-server-start.sh /software/kafka/config/server.properties &
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网站标题:Kafka安装部署-创新互联
分享链接:https://www.cdcxhl.com/article26/jecjg.html
成都网站建设公司_创新互联,为您提供网站内链、网站策划、外贸网站建设、全网营销推广、网站改版、网站收录
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联