這篇文章主要記錄一下CentOS 7.1下安裝配置Elasticsearch和Storm。html
安裝Oracle JDK,這個能夠參照我以前寫的文章。java
安裝Elasticsearchgit
到https://www.elastic.co/downloads/elasticsearch下載Elasticsearch,最新版本是2.3.1。解壓以後放到/opt目錄下面。命令爲:github
tar zxvf elasticsearch-2.3.1.tar.gzmv elasticsearch-2.3.1 /opt/
如今,可在elasticsearch的bin目錄下運行elasticsearch。個人目錄爲/opt/elasticsearch-2.3.1/bin;不要使用root用戶啓動elasticsearch。apache
./elasticsearch
對於elasticsearch的配置,能夠在/opt/elasticsearch-2.3.1/config下修改elasticsearch.yml文件。bash
接下來安裝elasticsearch-head,這個是elasticsearch集羣的管理工具。在elasticsearch的目錄下運行以下命令便可:服務器
./plugin install mobz/elasticsearch-head
安裝Marvelelasticsearch
由於衆所周知的緣由,在這裏只能採用離線安裝Marvel等相關插件。ide
首先,下載相關的安裝文件,命令以下:工具
wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/license/2.3.1/license-2.3.1.zip --no-check-certificatewget https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/marvel-agent/2.3.1/marvel-agent-2.3.1.zip --no-check-certificatewget https://download.elasticsearch.org/elasticsearch/marvel/marvel-2.3.1.tar.gz --no-check-certificate
由於後面要用到kibana,因此先在這裏安裝kibana,官網上有相關安裝教程:https://www.elastic.co/guide/en/kibana/current/setup.html。我仍是把kibana安裝在/opt目錄下面,具體安裝步驟就不說了。
./plugin install file:///home/hiccup/Downloads/license-2.3.1.zip./plugin install file:///home/hiccup/Downloads/marvel-agent-2.3.1.zip./kibana plugin --install marvel --url file:///home/hiccup/Downloads/marvel-2.3.1.tar.gz
接下來開始安裝Marvel。
運行elasticsearch,再運行kibana,能夠再看一下elasticsearch的狀態,有一些變化了。
接下來安裝Storm,這個比較複雜,容易遇到各類問題,要有耐心。
安裝zookeeper
我選擇的版本是zookeeper-3.4.8。解壓放到/opt目錄下:命令以下:
mv zookeeper-3.4.8 /opt/
定位到conf目錄下,將zoo_sample.cfg文件改名爲zoo.cfg文件,而後進行配置。我在Documents文件夾下,建了一個zookeeper文件夾,再分別建了data和logs文件夾。後面配置要用到。在zoo.cfg配置文件中配置一下dataDir和dataLogDir的位置。個人以下所示:
dataDir=/home/hiccup/Documents/zookeeper/datadataLogDir=/home/hiccup/Documents/zookeeper/logs
運行zookeeper進程的命令以下:./zkServer.sh start
可用客戶端鏈接服務器:./zkCli.sh -server zookeeper:2181
中止zookeeper進程的命令以下:./zkServer.sh stop
安裝zeromq
在/home/hiccup/Downloads/zeromq-4.1.4目錄下編譯安裝:
首先運行autogen.sh這個腳本,第一次./configure的時候,會出現以下的問題:
configure: error: Package requirements (libsodium) were not met:No package 'libsodium' foundConsider adjusting the PKG_CONFIG_PATH environment variable if youinstalled software in a non-standard prefix.Alternatively, you may set the environment variables sodium_CFLAGSand sodium_LIBS to avoid the need to call pkg-config.See the pkg-config man page for more details.
在configure以前,要編譯安裝libsodium,這是一個加密庫。可在https://download.libsodium.org/libsodium/releases/下載該庫文件,而後進行編譯安裝。
./autogen.sh./configuremakemake install
安裝完成以後,在zeromq目錄下執行以下命令,注意其中的參數:
./configure PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
其中的PKG_CONFIG_PATH中的路徑是libsodium的路徑。能夠用whereis libsodium查看一下。
而後接着
makemake installldconfig
安裝JZMQ
下載:
git clone git://github.com/zeromq/jzmq.git
定位到jzmq/jzmq-jni目錄下。而後執行以下命令:
./autogen.sh./configure
可能會出現以下錯誤:
checking for javac... javac
checking for javah... no
configure: error: cannot find javah
解決方法以下:
找到安裝的jdk所在目錄,我本地jdk所在位置爲/opt/jdk1.8.0_77。輸入以下幾個命令:
export JAVA_HOME=/opt/jdk1.8.0_77export JAVAH=/opt/jdk1.8.0_77/bin/javahexport JAR=/opt/jdk1.8.0_77/bin/jarsource ~/.bashrc
再次運行以下命令便可:
./configuremakemake install
安裝lein
將https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein連接下的內容保存爲lein文件,將lein文件移到/usr/bin/目錄下。
mv lein /usr/bin/leincd /usr/binchmod a+x leinlein (不要在root下運行)
安裝Storm
我這裏安裝的是最新版apache-storm-1.0.0
解壓縮以後,移到到/opt目錄下面。在/opt/apache-storm-1.0.0/conf下配置storm.yaml文件。由於暫時在單機僞storm集羣運行,全部配置以下:(集羣配置後續補充上來)
######### These MUST be filled in for a storm configurationstorm.zookeeper.servers:- "localhost"
# - "server2"
#nimbus.host: "localhost"
# nimbus.seeds: ["host1", "host2", "host3"]##storm.local.dir: "/home/smurf/storm"
接下來運行storm的一些命令:
nohup ./storm nimbus & (啓動storm控制進程)nohup ./storm ui & (啓動storm的ui監控界面,ui界面進程必須與控制進程在同一臺機器)nohup ./storm supervisor & (啓動storm的工做進程)
經過http://localhost:8080/能夠直接訪問Storm UI。以下圖所示:
幹掉nimbus相關進程:
kill `ps aux | egrep '(daemon\.nimbus)|(storm\.ui\.core)' | fgrep -v egrep | awk '{print $2}'`
幹掉supervisor上全部storm進程:
kill `ps aux | fgrep storm | fgrep -v 'fgrep' | awk '{print $2}'`
這樣,基本是就安裝好了。
注意,在這裏啓動elasticsearch以後,會發現本機能夠訪問,局域網中的其餘機器無法訪問。由於是CentOS,全部能夠在終端執行iptables –F。而後就能夠在局域網中其餘機器訪問elasticsearch所在的機器了。