搭建kafka消息队列

需要先搭建zookeeper 协助其做容灾 选举等工作

搭建zookeeper流程如下

 

Install the Java JDK. You can use the native packaging system for your system, or download the JDK from

下载jdk 用wget装jdk wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"

然后 tar -zxvf 解压  安装oscent jdk自己百度。

 

  1. Set the Java heap size. This is very important to avoid swapping, which will seriously degrade ZooKeeper performance. To determine the correct value, use load tests, and make sure you are well below the usage limit that would cause you to swap. Be conservative - use a maximum heap size of 3GB for a 4GB machine.

  2. Install the ZooKeeper Server Package. It can be downloaded from:

    zk包 也可用wget装

  3. Create a configuration file. This file can be called anything. Use the following settings as a starting point:

    tickTime=2000
    dataDir=/var/lib/zookeeper/  /**这里不放data*/
    clientPort=2181
    initLimit=5
    syncLimit=2
    server.1=zoo1:2888:3888
    server.2=zoo2:2888:3888
    server.3=zoo3:2888:3888

    You can find the meanings of these and other configuration settings in the section Configuration Parameters. A word though about a few here:

    Every machine that is part of the ZooKeeper ensemble should know about every other machine in the ensemble. You accomplish this with the series of lines of the form server.id=host:port:port. The parameters host and port are straightforward. You attribute the server id to each machine by creating a file named myid, one for each server, which resides in that server's data directory, as specified by the configuration file parameter dataDir.

    在dataDir路径下创建一个${dataDir}/data/myid文件 里面指定的数字 对应自己的server.后面的数字    

  1. The myid file consists of a single line containing only the text of that machine's id. So myid of server 1 would contain the text "1" and nothing else. The id must be unique within the ensemble and should have a value between 1 and 255.

  2. If your configuration file is set up, you can start a ZooKeeper server:

    $ java -cp zookeeper.jar:lib/slf4j-api-1.6.1.jar:lib/slf4j-log4j12-1.6.1.jar:lib/log4j-1.2.15.jar:conf \ org.apache.zookeeper.server.quorum.QuorumPeerMain zoo.cfg

    QuorumPeerMain starts a ZooKeeper server, JMX management beans are also registered which allows management through a JMX management console. The ZooKeeper JMX document contains details on managing ZooKeeper with JMX.//上面的内容 放置到conf/zoo.cfg中。

  3. See the script bin/zkServer.sh, which is included in the release, for an example of starting server instances. //启动zk bin目录下 ./zkServer.sh start

  4. ./zkServer.sh status的状态 是
  5.  

  6. Test your deployment by connecting to the hosts:

    In Java, you can run the following command to execute simple operations:

    $ bin/zkCli.sh -server 127.0.0.1:2181 //./zkCli.sh -server 127.0.0.1:2181

https://blog.csdn.net/sinat_37513998/article/details/82686490 搭建kafka分布式消息队列 支持动态横向扩展。需要启动kafka服务端,每个服务器都有brokerid需要不一致 生产者和消费者启动起来后,就可以收发消息

 

转载于:https://www.cnblogs.com/tecnologycc/p/10488836.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值