Elasticsearch搜索引擎基于Lucene实现的,项目开源,官方已经给出了安装细节。
我这里整理了一下具体安装流程,方便日后内容的维护和更新。
由于Elasticsearch是基于Lucene实现的,而Lucene又是java开发的,因此我们第一步需要安装java。
当前Elasticsearch release稳定版本是1.5版本,官网建议安装jdk1.8版本。
Specifically as of this writing, it is recommended that you use the Oracle JDK version 1.8. Java installation varies from platform to platform so we won’t go into those details here.
首先检测当前系统是否安装java,并确认版本是否一致,若不一致,需要删除当前java版本。
#检查当前系统安装的java版本
root@localhost [~]# yum list installed | grep java
java-1.7.0-openjdk.x86_64
java-1.7.0-openjdk-demo.x86_64
java-1.7.0-openjdk-devel.x86_64
java-1.7.0-openjdk-javadoc.noarch
java-1.7.0-openjdk-src.x86_64
tzdata-java.noarch 2015b-1.el6 @updates
#若没有,或版本一致,则跳过后续步骤
#删除当前版本的java
root@localhost [~]# yum -y remove java-1.7.0-openjdk*
root@localhost [~]# yum -y remove tzdata-java.noarch
root@localhost [~]# yum list installed | grep java
java-1.7.0-openjdk.x86_64
java-1.7.0-openjdk-demo.x86_64
java-1.7.0-openjdk-devel.x86_64
java-1.7.0-openjdk-javadoc.noarch
java-1.7.0-openjdk-src.x86_64
tzdata-java.noarch 2015b-1.el6 @updates
#若没有,或版本一致,则跳过后续步骤
#删除当前版本的java
root@localhost [~]# yum -y remove java-1.7.0-openjdk*
root@localhost [~]# yum -y remove tzdata-java.noarch
安装jdk 1.8版本。
#查看list
root@localhost [~]# yum list java-1.8*
Loaded plugins: security
Available Packages
java-1.8.0-openjdk.x86_64 1:1.8.0.31-1.b13.el6_6 updates
java-1.8.0-openjdk-demo.x86_64 1:1.8.0.31-1.b13.el6_6 updates
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.31-1.b13.el6_6 updates
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.31-1.b13.el6_6 updates
java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.31-1.b13.el6_6 updates
java-1.8.0-openjdk-src.x86_64
#安装
root@localhost [~]# yum install java-1.8*
查看java当前版本
root@localhost [~]# java -version
openjdk version "1.8.0_31"
OpenJDK Runtime Environment (build 1.8.0_31-b13)
OpenJDK 64-Bit Server VM (build 25.31-b07, mixed mode)
root@localhost [~]# yum list java-1.8*
Loaded plugins: security
Available Packages
java-1.8.0-openjdk.x86_64 1:1.8.0.31-1.b13.el6_6 updates
java-1.8.0-openjdk-demo.x86_64 1:1.8.0.31-1.b13.el6_6 updates
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.31-1.b13.el6_6 updates
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.31-1.b13.el6_6 updates
java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.31-1.b13.el6_6 updates
java-1.8.0-openjdk-src.x86_64
#安装
root@localhost [~]# yum install java-1.8*
查看java当前版本
root@localhost [~]# java -version
openjdk version "1.8.0_31"
OpenJDK Runtime Environment (build 1.8.0_31-b13)
OpenJDK 64-Bit Server VM (build 25.31-b07, mixed mode)
官网已经给出了具体安装细节,这里仅作参考。
#下载当前稳定版本
root@localhost [~]# curl -L -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.5.0.tar.gz
root@localhost [~]# tar -zxvf elasticsearch-1.5.0.tar.gz
#copy到需要的目录下面
root@localhost [~]# cp elasticsearch-1.5.0 /app/ -R
root@localhost [~]# cd elasticsearch-1.5.0/bin
root@localhost [~]# ./elasticsearch
[2015-04-06 13:28:31,811][INFO ][node ] [Ironclad] version[1.5.0], pid[23384], build[5448160/2015-03-23T14:30:58Z]
[2015-04-06 13:28:31,812][INFO ][node ] [Ironclad] initializing ...
[2015-04-06 13:28:31,820][INFO ][plugins ] [Ironclad] loaded [], sites []
[2015-04-06 13:28:36,748][INFO ][node ] [Ironclad] initialized
[2015-04-06 13:28:36,754][INFO ][node ] [Ironclad] starting ...
[2015-04-06 13:28:37,113][INFO ][transport ] [Ironclad] bound_address {inet[/0.0.0.0:9300]}, publish_address {inet[/10.251.26.174:9300]}
[2015-04-06 13:28:37,172][INFO ][discovery ] [Ironclad] elasticsearch/XIkS6SuFSGGqY7NfmvkPNw
[2015-04-06 13:28:40,966][INFO ][cluster.service ] [Ironclad] new_master [Ironclad][XIkS6SuFSGGqY7NfmvkPNw][iZ28w0fjfxvZ][inet[/10.251.26.174:9300]], reason: zen-disco-join (elected_as_master)
[2015-04-06 13:28:41,028][INFO ][http ] [Ironclad] bound_address {inet[/0.0.0.0:9200]}, publish_address {inet[/10.251.26.174:9200]}
[2015-04-06 13:28:41,029][INFO ][node ] [Ironclad] started
[2015-04-06 13:28:42,331][INFO ][gateway ] [Ironclad] recovered [2] indices into cluster_state
root@localhost [~]# curl -L -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.5.0.tar.gz
root@localhost [~]# tar -zxvf elasticsearch-1.5.0.tar.gz
#copy到需要的目录下面
root@localhost [~]# cp elasticsearch-1.5.0 /app/ -R
root@localhost [~]# cd elasticsearch-1.5.0/bin
root@localhost [~]# ./elasticsearch
[2015-04-06 13:28:31,811][INFO ][node ] [Ironclad] version[1.5.0], pid[23384], build[5448160/2015-03-23T14:30:58Z]
[2015-04-06 13:28:31,812][INFO ][node ] [Ironclad] initializing ...
[2015-04-06 13:28:31,820][INFO ][plugins ] [Ironclad] loaded [], sites []
[2015-04-06 13:28:36,748][INFO ][node ] [Ironclad] initialized
[2015-04-06 13:28:36,754][INFO ][node ] [Ironclad] starting ...
[2015-04-06 13:28:37,113][INFO ][transport ] [Ironclad] bound_address {inet[/0.0.0.0:9300]}, publish_address {inet[/10.251.26.174:9300]}
[2015-04-06 13:28:37,172][INFO ][discovery ] [Ironclad] elasticsearch/XIkS6SuFSGGqY7NfmvkPNw
[2015-04-06 13:28:40,966][INFO ][cluster.service ] [Ironclad] new_master [Ironclad][XIkS6SuFSGGqY7NfmvkPNw][iZ28w0fjfxvZ][inet[/10.251.26.174:9300]], reason: zen-disco-join (elected_as_master)
[2015-04-06 13:28:41,028][INFO ][http ] [Ironclad] bound_address {inet[/0.0.0.0:9200]}, publish_address {inet[/10.251.26.174:9200]}
[2015-04-06 13:28:41,029][INFO ][node ] [Ironclad] started
[2015-04-06 13:28:42,331][INFO ][gateway ] [Ironclad] recovered [2] indices into cluster_state
没错,就这么简单,安装已经完成了。
安装完成后,使用curl检查运行是否正常。
root@localhost [~]# curl -X GET 'http://localhost:9200'
{
"status" : 200,
"name" : "Tombstone",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "1.5.0",
"build_hash" : "544816042d40151d3ce4ba4f95399d7860dc2e92",
"build_timestamp" : "2015-03-23T14:30:58Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"
},
"tagline" : "You Know, for Search"
}
{
"status" : 200,
"name" : "Tombstone",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "1.5.0",
"build_hash" : "544816042d40151d3ce4ba4f95399d7860dc2e92",
"build_timestamp" : "2015-03-23T14:30:58Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"
},
"tagline" : "You Know, for Search"
}
Elasticsearch 提供了数据管理界面插件——Marvel,方便我们查看,不过线上环境需要付费。
安装过程非常简单:
root@localhost [~]# plugin -i elasticsearch/marvel/latest
root@localhost [~]# ./elasticsearch
root@localhost [~]# ./elasticsearch
Leave a Reply