(1)、手动下载 下载地址:Apache Kafka
(2)、也可以用命令下载(直接下载到服务器哦!):
将安装包下载到/opt/monitor/kafka文件夹下面
下载命令:
wget http://mirrors.hust.edu.cn/apache/kafka/2.0.0/kafka_2.12-2.0.0.tgz
手动下载移动到/opt/monitor/kafka目录下也可以
tar -xzvf kafka_2.12-2.0.0.tgz(文件名可以更换哦!)
在目录/opt/monitor/kafka/kafka_2.12-2.7.0/config下
在config目录下输入命令:vim server.properties


server.properties修改 内容如下:可直接复制粘贴。
broker.id=0 port=9092 #端口号 host.name=localhost #单机可直接用localhost log.dirs=/opt/monitor/kafka/kafka_dat #日志存放路径可修改可不修改 zookeeper.connect=localhost:2181 #zookeeper地址和端口,单机配置部署,localhost:2181
mkdir + 目录名称
vim zookeeper.properties
dataDir=/opt/monitor/kafka/kafka_data/zookeeper #zookeeper数据目录 (可以修改可以不修改) clientPort=2181 maxClientCnxns=100 tickTimes=2000 initLimit=10 syncLimit=5 admin.enableServer=false
由于我修改了默认的数据目录地址和日志目录需要在kafka下创建文件
在/opt/monitor/kafka/创建
mkdir kafka_data/zookeeper
(一般我使用这种方式)
启动:在/opt/monitor/kafka/kafka_2.12-2.7.0路径下先启动zookeeper,默认自带的
bin/zookeeper-server-start.sh config/zookeeper.properties bin/zookeeper-server-start.sh -daemon config/zookeeper.properties #建议使用这种方式,不需要启动多个窗口
然后启动kafka服务在/opt/monitor/kafka/kafka_2.12-2.7.0路径下
bin/kafka-server-start.sh config/server.properties bin/kafka-server-start.sh -daemon config/server.properties #建议使用这种方式,不需要启动多个窗口
#!/bin/sh #启动zookeeper
/opt/monitor/kafka/kafka_2.12-2.7.0/bin/zookeeper-server-start.sh /opt/monitor/kafka/kafka_2.12-2.7.0/config/zookeeper.properties &
sleep 3 #等3秒后执行
#启动kafka
/opt/monitor/kafka/kafka_2.12-2.7.0/bin/kafka-server-start.sh /opt/monitor/kafka/kafka_2.12-2.7.0/config/server.properties &
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic demo bin/kafka-topics.sh --create --zookeeper localhost:2181 --topic demo
其中demo为创建的topic名称。

如上图,创建了一个名为 demo 的主题,其中包含一个分区和一个副本因子。 创建成功之后会输出:Created topic "demo".

如上图,创建主题后,系统会在config / server.properties文件中的"/ tmp / kafka-logs /"中指定的创建主题的日志。
bin/kafka-topics.sh --list --zookeeper localhost:2181bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic demo
bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic demo
进入/opt/monitor/kafka/kafka_2.12-2.7.0目录下执行命令
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic demo bin/kafka-console-producer.sh --broker-list 192.168.113.xxx:9092 --topic prometheusMonitor_event bin/kafka-console-producer.sh --broker-list 192.168.xxx.xxx:9092 --topic zabbixVm
从上面的语法,生产者命令行客户端需要两个主要参数 -
代理列表 - 我们要发送邮件的代理列表。 在这种情况下,我们只有一个代理。 Config / server.properties文件包含代理端口ID,因为我们知道我们的代理正在侦听端口9092,因此您可以直接指定它。主题名称:demo。
为了方便测试,另启一个sheel窗口 这样效果更明显。需要注意的是旧版本和新版本的命令是不一样的
进入/opt/monitor/kafka/kafka_2.12-2.7.0目录下执行命令
2.1、旧版本:
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic demo --from-beginning
报错提示:zookeeper is not a recognized option
2.2、新版本
发现在启动的时候说使用 --zookeeper是一个过时的方法,最新的版本中命令如下:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic demo --from-beginning bin/kafka-console-consumer.sh --bootstrap-server 192.168.xxx.xxx:9092 --topic 名称 --from-beginning
可以开启两个终端,一个发送消息,一个接受消息。效果如下:

进入/opt/monitor/kafka/kafka_2.12-2.7.0目录下执行命令
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic demo --time -1
进入/opt/monitor/kafka/kafka_2.12-2.7.0/bin目录下:
(1)、topic: redis_event ./kafka-console-consumer.sh --bootstrap-server 192.168.xxx.xxx:9092 --topic redis_event --from-beginning (2)、topic: zabbixVm ./kafka-console-consumer.sh --bootstrap-server 192.168.xxx.xxx:9092 --topic zabbixVm #查看最新的数据
八,监控
1个kafka集群只需要1个exporter,在集群上的任意1台服务器部署。
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
我打算为ruby脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e
我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search
我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121
由于fast-stemmer的问题,我很难安装我想要的任何rubygem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=
我是Google云的新手,我正在尝试对其进行首次部署。我的第一个部署是RubyonRails项目。我基本上是在关注thisguideinthegoogleclouddocumentation.唯一的区别是我使用的是我自己的项目,而不是他们提供的“helloworld”项目。这是我的app.yaml文件runtime:customvm:trueentrypoint:bundleexecrackup-p8080-Eproductionconfig.ruresources:cpu:0.5memory_gb:1.3disk_size_gb:10当我转到我的项目目录并运行gcloudprevie
当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub