Skip to content

Commit

Permalink
优化,增加start.sh 测试脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
supermy committed Apr 12, 2015
1 parent 73f82e0 commit f7f93ef
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
16 changes: 10 additions & 6 deletions common/mykafka/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
FROM myjre7_base
FROM jamesmo/jre:7

MAINTAINER jamesmo

RUN apt-get update; apt-get install -y unzip wget git
RUN apt-get update && apt-get install -y unzip

RUN wget -q http://mirror.gopotato.co.uk/apache/kafka/0.8.2.0/kafka_2.11-0.8.2.0.tgz -O /tmp/kafka_2.11-0.8.2.0.tgz
RUN tar xfz /tmp/kafka_2.11-0.8.2.0.tgz -C /opt
RUN wget http://mirrors.cnnic.cn/apache/kafka/0.8.2.1/kafka_2.11-0.8.2.1.tgz -O /tmp/kafka_2.11-0.8.2.1.tgz
RUN tar xfz /tmp/kafka_2.11-0.8.2.1.tgz -C /opt

RUN rm /tmp/kafka_2.11-0.8.2.0.tgz
RUN rm /tmp/kafka_2.11-0.8.2.1.tgz

VOLUME ["/kafka"]

ENV KAFKA_HOME /opt/kafka_2.11-0.8.2.0
ENV KAFKA_HOME /opt/kafka_2.11-0.8.2.1

ADD shell/start-kafka.sh /usr/bin/start-kafka.sh
ADD shell/broker-list.sh /usr/bin/broker-list.sh

RUN chmod a+x /usr/bin/start-kafka.sh
RUN chmod a+x /usr/bin/broker-list.sh


CMD start-kafka.sh
2 changes: 1 addition & 1 deletion common/mykafka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ kafka是一种高吞吐量的分布式发布订阅消息系统,她有如下特
>
> 修改地址:consumer_context.xml 192.168.59.103
> 修改地址:context.xml 192.168.59.103
> 运行测试类,查看spring对kafka的调用结果。
> 运行测试类,查看spring对kafka的调用结果。com.colobu.spring_kafka_demo.Producer com.colobu.spring_kafka_demo.Consumer
>
> ## spring+kafka示例
Expand Down
8 changes: 4 additions & 4 deletions common/mykafka/fig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ zookeeper:

##消息队列,配置ip and port
kafka1:
image: wurstmeister/kafka:latest
image: jamesmo/kafka:0.8
ports:
- "9092:9092"
links:
Expand All @@ -24,7 +24,7 @@ kafka1:

##消息队列,配置ip and port
kafka2:
image: wurstmeister/kafka:latest
image: jamesmo/kafka:0.8
ports:
- "9093:9092"
links:
Expand All @@ -38,7 +38,7 @@ kafka2:

##消息队列,配置ip and port
kafka3:
image: wurstmeister/kafka:latest
image: jamesmo/kafka:0.8
ports:
- "9094:9092"
links:
Expand All @@ -62,7 +62,7 @@ kafka3:

#采集数据,传输给kafka
flume1:
image: myflume_base:latest
image: jamesmo/myflume:latest
environment:
FLUME_AGENT_NAME: producer
FLUME_CONF_DIR: /opt/flume/conf
Expand Down
Binary file not shown.
16 changes: 16 additions & 0 deletions common/mykafka/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
fig up -d && fig ps

#tese1
kafka-topics.sh --create --zookeeper 192.168.59.103:2181 --replication-factor 1 --partitions 1 --topic mykafka
telnet 192.168.59.103 44447
kafka-console-consumer.sh --zookeeper 192.168.59.103:2181 --topic mykafka --from-beginning

#test2
kafka-topics.sh --create --zookeeper 192.168.59.103:2181 --replication-factor 1 --partitions 1 --topic metadata
kafka-topics.sh --create --zookeeper 192.168.59.103:2181 --replication-factor 1 --partitions 1 --topic test
java -cp spring-kafka-demo-0.2.0-SNAPSHOT-jar-with-dependencies.jar com.colobu.spring_kafka_demo.Producer
java -cp spring-kafka-demo-0.2.0-SNAPSHOT-jar-with-dependencies.jar com.colobu.spring_kafka_demo.Consumer

fig stop && fig rm --force

echo "test over!"

0 comments on commit f7f93ef

Please sign in to comment.