您好,登录后才能下订单哦!
本篇内容介绍了“storm的详细安装教程”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
本文演示安装单机storm系统,并运行内置的示例程序。分为四个步骤:
安装Java环境
安装 Zookeeper
安装Storm(单机)
运行Storm实例-WordCount
安装Java环境
[root@localhost strom]# yum install java-1.7.0-openjdk java-1.7.0-openjdk-devel
env没有JAVA_HOME变量,因此要自己配置该变量。查找jdk安装目录。
[root@localhost strom]# find / -name java-1.7.0-openjdk/usr/lib/jvm/java-1.7.0-openjdk
在/root目录下编辑.bashrc
[root@localhost ~]# vi .bashrc # .bashrc# Source global definitionsif [ -f /etc/bashrc ]; then . /etc/bashrcfi#文件末尾加上JAVA_HOME变量export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk
使环境变量生效
[root@localhost ~]# source .bashrc
检查是否有JAVA_HOME变量
[root@localhost ~]# env | grep JAVAJAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk
安装 Zookeeper
下载zookeeper-3.4.6.tar.gz,上传到服务器,解压
[root@localhost strom]# tar -zxf zookeeper-3.4.6.tar.gz
进入zookeeper的conf文件夹
[root@localhost conf]# cp zoo_sample.cfg zoo.cfg然后vi zoo.cfg修改dataDir目录为你希望的目录# example sakes.dataDir=/home/strom/zookeeper-3.4.6/data
启动zookeeper
[root@localhost bin]# ./zkServer.sh startJMX enabled by defaultUsing config: /home/strom/zookeeper-3.4.6/bin/../conf/zoo.cfgStarting zookeeper ... STARTED
安装Storm(单机)
下载apache-storm-0.9.6.tar.gz 上传服务器,解压
[root@localhost strom]# tar -zxf apache-storm-0.9.6.tar.gz
进入storm的conf目录,修改storm.yaml文件,地址改成127.0.0.1,ui端口改成8888
[root@localhost conf]# vi storm.yamlstorm.zookeeper.servers:- "127.0.0.1"# - "server2"#nimbus.host: "127.0.0.1"ui.port: 8888
bin目录下依次启动storm nimbus、storm supervisor、storm ui
[root@localhost bin]# ./storm nimbusRunning: /usr/lib/jvm/java-1.7.0-openjdk/bin/j。。。-Dlogback.configurationFile=/home/strom/apache-storm-0.9.6/logback/cluster.xml backtype.storm.daemon.nimbus
[root@localhost bin]# ./storm supervisorRunning: /usr/lib/jvm/java-1.7.0-openjdk/bin/java -server -Dstorm.options= -Dstorm.home=/home/strom/apache-storm-0.9.6 -Dstorm.log.dir=/home/strom/apache-storm-0.9.6/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /home/strom/apache-storm-0.9.6/lib/storm-core-0.9.6.jar:/home/strom/apache-storm-0.9.6/lib/clojure-1.5.1.jar:/home/strom/apache-storm-0.9.6/lib/clj-time-0.4.1.jar:/home/strom/apache-storm-.name=supervisor.log -Dlogback.configurationFile=/home/strom/apache-storm-0.9.6/logback/cluster.xml backtype.storm.daemon.supervisor
[root@bogon bin]# ./storm uiRunning: /usr/lib/jvm/java-1.7.0-openjdk/bin/java -server -Dstorm.options= -Dstorm.home=/home/strom/apache-storm-0.9.6 -Dstorm.log.dir=/home/strom/apache-storm-0.9.6conf -Xmx768m -Dlogfile.name=ui.log -Dlogback.configurationFile=/home/strom/apache-storm-0.9.6/logback/cluster.xml backtype.storm.ui.core
浏览器输入IP:8888可以打开UI界面。
如果访问UI打不开一般是防火墙没关闭,systemctl stop firewalld临时关闭防火墙试试。
下图描述了几个角色之间的关系
运行Storm实例-WordCount
运行内置示例,示例程序不断地取如下语句作为数据源,然后统计单词出现的次数。后面加上grep the是筛选统计结果关于the这个单词的次数。该程序执行10秒后会自动关闭。
{
"the cow jumped over the moon",
"an apple a day keeps the doctor away",
"four score and seven years ago",
"snow white and the seven dwarfs", "i am at two with nature"
}
[root@bogon apache-storm-0.9.6]# ./bin/storm jar ./examples/storm-starter/storm-starter-topologies-0.9.6.jar storm.starter.WordCountTopology |grep 'Thread-[0-9]*-count' | grep the33663 [Thread-11-count] INFO backtype.storm.daemon.executor - Processing received message source: split:7, stream: default, id: {}, ["the"]33663 [Thread-11-count] INFO backtype.storm.daemon.task - Emitting: count default [the, 1]33672 [Thread-11-count] INFO backtype.storm.daemon.executor - Processing received message source: split:6, stream: default, id: {}, ["the"]33672 [Thread-11-count] INFO backtype.storm.daemon.task - Emitting: count default [the, 2]33678 [Thread-11-count] INFO backtype.storm.daemon.executor - Processing received message source: split:6, stream: default, id: {}, ["the"]33678 [Thread-11-count] INFO backtype.storm.daemon.task - Emitting: count default [the, 3]
其它版本的安装包不一定能安装成功。请严格按照文中版本下载安装包,操作系统为Redhat7.6,我安装其它版本时遇到的报错为
Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain
如果自行开发storm程序,需要创建maven工程,按storm要求写spout,bolt,然后打包上传,运行测试。
“storm的详细安装教程”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。