版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010871004/article/details/81570939
Elasticsearch简介
最近在看elasticsearch相关的东西,看到一本名叫《Elasticsearch Essentials》的书籍,自己在看的时候,总觉得自己要有点东西要记录下来。可能有些东西记录的跟作者要表达的意思有些出入,但是自己看到的记录下来总是有好处的,要是我记录有什么不对的地方请给我评论,我及时修改。
Elasticsearch是建立在Lucene之上的用java进行一次重写的分布式,全文本搜索和分析引擎。只从2010发布之后,ES已经被很多大小组织采用,例如NASA,Wikipedia和GitHub。最新的版本的ES更加注重弹性,让使用者更加觉得ES是个数据储存工具,而不仅仅是一个全文检索引擎。Elasticsearch有以下几个特点
- 高可用
- 分布式
- 基于Rest架构风格
- 强大的查询DSL
- 无模式
Elasticsearch安装
安装的前提是linux系统中,已经安装了jdk,如果不知道linux中怎么安装jdk可以参考这篇文章
linux安装jdk8
下面介绍在Ubuntu和CentOS中安装的具体步骤,文章中使用的Elasticsearch是基于2.0.0版本,我这里使用的是2.4.4版本,安装步骤
解压文件,移动到/usr/local/目录中
tar -zxvf elasticsearch-2.4.4.tar.gz
sudo mv elasticsearch-2.4.4.tar.gz
新建elasticsearch用户,更改密码
sudo useradd -m elasticsearch
sudo passwd elasticsearch
更改elasticsearch目录所属权限
sudo chown -R elasticsearch:elasticsearch /usr/local/elasticsearch-2.4.4
然后进入elasticsearch安装目录中bin目录,执行
./elasticsearch
控制台显示
[2018-08-16 21:44:57,491][INFO ][node ] [Tutinax the Mountain-Mover] version[2.4.4], pid[3494], build[fcbb46d/2017-01-03T11:33:16Z]
[2018-08-16 21:44:57,497][INFO ][node ] [Tutinax the Mountain-Mover] initializing ...
[2018-08-16 21:45:00,921][INFO ][plugins ] [Tutinax the Mountain-Mover] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2018-08-16 21:45:01,672][INFO ][env ] [Tutinax the Mountain-Mover] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [11.8gb], net total_space [18.6gb], spins? [possibly], types [ext4]
[2018-08-16 21:45:01,673][INFO ][env ] [Tutinax the Mountain-Mover] heap size [1015.6mb], compressed ordinary object pointers [true]
[2018-08-16 21:45:13,299][INFO ][node ] [Tutinax the Mountain-Mover] initialized
[2018-08-16 21:45:13,307][INFO ][node ] [Tutinax the Mountain-Mover] starting ...
[2018-08-16 21:45:13,755][INFO ][transport ] [Tutinax the Mountain-Mover] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2018-08-16 21:45:13,814][INFO ][discovery ] [Tutinax the Mountain-Mover] elasticsearch/BshfTqapRAiI87szEsXdaw
[2018-08-16 21:45:17,019][INFO ][cluster.service ] [Tutinax the Mountain-Mover] new_master {Tutinax the Mountain-Mover}{BshfTqapRAiI87szEsXdaw}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2018-08-16 21:45:17,078][INFO ][http ] [Tutinax the Mountain-Mover] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2018-08-16 21:45:17,079][INFO ][node ] [Tutinax the Mountain-Mover] started
[2018-08-16 21:45:17,275][INFO ][gateway ] [Tutinax the Mountain-Mover] recovered [0] indices into cluster_state
说明启动成功。
进入浏览器中,输入localhost:9200
{
"name" : "Tutinax the Mountain-Mover",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "iKZ4wLQnShaO0Q2RE-I8AA",
"version" : {
"number" : "2.4.4",
"build_hash" : "fcbb46dfd45562a9cf00c604b30849a6dec6b017",
"build_timestamp" : "2017-01-03T11:33:16Z",
"build_snapshot" : false,
"lucene_version" : "5.5.2"
},
"tagline" : "You Know, for Search"
}
出现上述信息,说明elasticsearch安装成功。