1:在每台机器上安装jdk, 脚本代码如下:

每一个机器上下载jdk,zookeeper,kafka

链接:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

      http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.13/

     http://mirrors.shu.edu.cn/apache/kafka/2.0.0/kafka_2.11-2.0.0.tgz

2:部署java的环境,设置环境变量

sudo tar -zxvf jdk-8u191-linux-x64.tar.gz -C /opt/

echo "export JAVAHOME=\"/opt/jdk1.8.0_191\"
export PATH=\"\$PATH:\$JAVAHOME/bin\"
export CLASSPATH=\".:\$JAVAHOME/lib:\$JAVAHOME/jre/lib\"
" >> ~/.bashrc source ~/.bashrc java -version

3:部署zookeeper环境

sudo tar -zxvf zookeeper-3.4..tar.gz -C /opt/

#设置环境变量
export PATH="$PATH:$JAVAHOME/bin:/opt/zookeeper-3.4.13/bin:/opt/kafka_2.11-2.0.0/bin" #三台服务器的环境配置 # The number of milliseconds of each tick
tickTime=
# The number of ticks that the initial
# synchronization phase can take
initLimit=
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/data/zookeeper
# the port at which the clients will connect
clientPort=
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=
# Purge task interval in hours
# Set to "" to disable auto purge feature
#autopurge.purgeInterval=
dataLogDir=/var/log/zookeeper server.=109.123.100.126::
server.=109.123.100.137::
server.=109.123.100.139::
#新建目录并设置权限
sudo mkdir -p /var/log/zookeeper && sudo mkdir -p /data/zookeeper sudo chmod -R a+w /var/log/zookeeper && sudo chmod -R a+w /data/zookeeper
#server
echo "" > /data/zookeeper/myid #server
echo "" > /data/zookeeper/myid #server
echo "" > /data/zookeeper/myid

4:部署kafka环境

sudo tar -xvf kafka_2.-2.0..tgz -C /opt

#设置环境变量
export PATH="$PATH:$JAVAHOME/bin:/opt/zookeeper-3.4.13/bin:/opt/kafka_2.11-2.0.0/bin" #启动kafka集群,在每个机器上执行如下命令
kafka-server-start.sh -daemon /opt/kafka_2.-2.0./config/server.properties #通过jps 验证结果
scm@scm--:~$ jps
Jps
QuorumPeerMain
Kafka
#看到三个进程,说明成功了

5:创建topic 模拟多个生产者一个消费者,和多个消费者,一个生产者

创建一个tizen-unified的topic, 表示这个topic中放的都是tizen-unified 的信息

kafka-topics.sh --create --replication-factor  --zookeeper 109.123.100.126:,109.123.100.137:,109.123.100.144: --partitions  --topic tizen-unified

开启一个生产者:

kafka-console-producer.sh --broker-list 109.123.100.126: --topic tizen-unified

scm@scm--:~$ kafka-console-producer.sh --broker-list 109.123.100.126: --topic tizen-unified
>buildint package1
>building package2
>building package3
>building package4
>building package5

开启两个消费者:(同属于一个group)

kafka-console-consumer.sh --bootstrap-server 109.123.100.126: --topic tizen-unified --from-beginning --group tizen-worker

scm@scm--:~$ kafka-console-consumer.sh --bootstrap-server 109.123.100.126: --topic tizen-unified --from-beginning --group tizen-worker
building package3
building package4
building package5 scm@scm--:~$ kafka-console-consumer.sh --bootstrap-server 109.123.100.126: --topic tizen-unified --from-beginning --group tizen-worker
building package1
building package2

使用kafka和zookeeper 构建分布式编译环境的更多相关文章

  1. selenium结合docker构建分布式测试环境

    selenium是目前web和app自动化测试的主要框架.对于web自动化测试而言,由于selenium2.0以后socker服务器由本地浏览器自己启动且直接通过浏览器原生API操作页面,故越来越多的 ...

  2. selenium 结合 docker 构建分布式测试环境 (初学者视角)

    前言:随着自动化测试越学越深,深深觉得有太多的东西需要总结. 1.记录下学习中遇到的坑,当做学习笔记.2.有前人路过看到文章中比较落后的做法,请务必一定要指教.(因为是初学者视角,很多东西只是走通而已 ...

  3. 深入浅出理解基于 Kafka 和 ZooKeeper 的分布式消息队列

    消息队列中间件是分布式系统中重要的组件,主要解决应用耦合,异步消息,流量削锋等问题.实现高性能,高可用,可伸缩和最终一致性架构,是大型分布式系统不可缺少的中间件. 本场 Chat 主要内容: Kafk ...

  4. Kafka 和 ZooKeeper 的分布式消息队列分析

    1. Kafka 总体架构 基于 Kafka-ZooKeeper 的分布式消息队列系统总体架构如下: 如上图所示,一个典型的 Kafka 体系架构包括若干 Producer(消息生产者),若干 bro ...

  5. 【转】Ant学习笔记——自己构建Ant编译环境

    自从年初开始用NetBeans6.0,才接触到Ant. 这是今年6月份的一篇Ant学习笔记.安装 1.下载并构建环境.   去官网下载src包和bin包.解压缩它们到同一目录,运行build.bat, ...

  6. sublime构建各个编译环境

    一 java运行环境配置: 打开sublime选择Tool 到 Building System 选择new building System 输入 {"shell_cmd": &qu ...

  7. java企业架构 spring mvc +mybatis + KafKa+Flume+Zookeeper

    声明:该框架面向企业,是大型互联网分布式企业架构,后期会介绍linux上部署高可用集群项目. 项目基础功能截图(自提供了最小部分)      平台简介        Jeesz是一个分布式的框架,提供 ...

  8. (转)Android分布式编译学习(一)distcc实现分布式编译 —— Ubuntu12.04上部署distcc分布式编译

    转自:http://blog.csdn.net/eqiang8271/article/details/17144411   版权声明:本文为博主原创文章,未经博主允许不得转载. Android代码庞大 ...

  9. kafka在zookeeper创建使用了哪些znode节点?

    我们都知道kafka利用zookeeper做分布式管理,具体创建使用了哪些znode节点呢? 答案均在源码的ZkData.scala文件中,具体路径如下: https://github.com/apa ...

随机推荐

  1. Tensor RT使用记录

    Tensor RT的介绍在此不做赘述. 自己在服务器上本打算装Tensor RT来着,不过过程很艰辛,最后发现服务器的cudnn版本偏低了,还需要升级cudnn的版本.故,在自己的电脑上了装了下Ten ...

  2. SPL之Iterator(迭代器)接口

    前言:SPL是用于解决典型问题(standard problems)的一组接口与类的集合. <?php /** * Class MyIterator * 在 PHP 中,通常情况下遍历数组使用 ...

  3. Tempter of the Bone HDU - 1010

    The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it u ...

  4. git clone项目

    1. 生成公钥和私钥 ssh-keygen 2. 将公钥添加到github或者gitlab上,一般github或者gitlab允许添加多个公钥,可能是考虑到用户使用不同的机器了吧,还是很贴心的. 3. ...

  5. spring security antMatchers相关内容

    一.antMatcher与antMatchers的区别以及使用场景 来源:https://stackoverflow.com/questions/35890540/when-to-use-spring ...

  6. Redis+Twemproxy+HAProxy集群(转) 干货

    原文地址:Redis+Twemproxy+HAProxy集群  干货 Redis主从模式 Redis数据库与传统数据库属于并行关系,也就是说传统的关系型数据库保存的是结构化数据,而Redis保存的是一 ...

  7. oracle 日常设置

    查看缓冲区命令:list  执行save  1.sql 可以吧缓冲区的命令保存下来.  执行 @1.sql可以执行保存下来的内容:  show feedback 显示反馈信息,最后一行.  show ...

  8. VSS迁移详细教程

    本文默认迁移机和目标机已是安装好VSS服务,如果没装好参见VSS+SourceAnywhere for VSS搭建版本控制系统教程 如果你只想以最快的速度迁移库而并不关心VSS的一些操作使用,那么可直 ...

  9. weblogic创建domain教程

    1.创建domain [ls@ls ~]$ cd /weblogic/wlserver_10.3/common/bin/ #进入创建文件所在目录 [ls@ls bin]$ ./config.sh #执 ...

  10. 把旧系统迁移到.Net Core 2.0 日记 (12) --发布遇到的问题

    1. 开发时是在Mac+MySql, 尝试发布时是在SQL2005+Win 2008 (第一版) 在Startup.cs里,数据库连接要改,分页时netcore默认是用offset关键字分页, 如果用 ...