Elastic Search是一个基于Lucene的全文搜索框架,提供了restful接口。最近项目组的机器学习项目搜索引擎考虑选用Elastic Search,所以先尝试在自己的Mac上安装使用Elastic Search(以下简称ES),本文主要记录mac上安装ES的过程。
2种安装方案
mac上安装ES可以直接下载安装,也可以使用mac平台上第三房软件包安装工具homebrew安装。
homebrew安装
使用以下命令安装:
$ brew install elasticsearch
执行成功以后可以使用以下命令启动ES服务:
$ brew services start elasticsearch
直接下载安装
ES安装包下载
本文采用这种方法安装,先去这个页面past releases下载,可以看到2.4版本过后就是5.0及其以上版本,没有3. X和4.X版本。考虑将来配合spring boot项目使用,最终选择了2.4.6版本。关于spring boot,spring data elastic search以及ES的版本兼容性建议参考这个页面Spring Data Elasticsearch Spring Boot version matrix,目前只能使用5.0以下版本的ES.
ES安装包目录结构
下载后的ES的ZIP格式压缩包大小约26M,解压以后根目录结构如下:
-
bin: bin是目录,里面包含elasticsearch、plugin共2个二进制命令,elasticsearch-service-mgr.exe、elasticsearch-service-x64.exe、elasticsearch-service-x86.exe共3个可执行文件,elasticsearch.bat、elasticsearch.in.bat、elasticsearch.in.sh、plugin.bat、service.bat共5个脚本文件
-
config: config是目录,里面包含elasticsearch.yml和logging.yml共2个配置文件。
-
lib: lib是目录,包含常用jar包
-
modules: modules是目录
-
LICENSE.txt
-
NOTICE.txt
-
README.textile
启动ES
进入ES解压保存路径:
$ cd /Users/chenxin/Workspaces/ES/elasticsearch-2.4.6
执行以下命令启动ES:
$ bin/elasticsearch
Terminal输出内容如下:
[2018-01-09 10:43:23,060][INFO ][node ] [Ghost Dancer] version[2.4.6], pid[33264], build[5376dca/2017-07-18T12:17:44Z]
[2018-01-09 10:43:23,061][INFO ][node ] [Ghost Dancer] initializing ...
[2018-01-09 10:43:23,563][INFO ][plugins ] [Ghost Dancer] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2018-01-09 10:43:23,616][INFO ][env ] [Ghost Dancer] using [1] data paths, mounts [[/ (/dev/disk1s1)]], net usable_space [281.5gb], net total_space [465.7gb], spins? [unknown], types [apfs]
[2018-01-09 10:43:23,616][INFO ][env ] [Ghost Dancer] heap size [989.8mb], compressed ordinary object pointers [true]
[2018-01-09 10:43:23,617][WARN ][env ] [Ghost Dancer] max file descriptors [10240] for elasticsearch process likely too low, consider increasing to at least [65536]
[2018-01-09 10:43:25,025][INFO ][node ] [Ghost Dancer] initialized
[2018-01-09 10:43:25,026][INFO ][node ] [Ghost Dancer] starting ...
[2018-01-09 10:43:25,101][INFO ][transport ] [Ghost Dancer] publish_address {127.0.0.1:9300}, bound_addresses {[fe80::1]:9300}, {[::1]:9300}, {127.0.0.1:9300}
[2018-01-09 10:43:25,105][INFO ][discovery ] [Ghost Dancer] elasticsearch/G6v0rh5LTRmW4m3km1Npkw
[2018-01-09 10:43:29,143][INFO ][cluster.service ] [Ghost Dancer] new_master {Ghost Dancer}{G6v0rh5LTRmW4m3km1Npkw}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2018-01-09 10:43:29,158][INFO ][http ] [Ghost Dancer] publish_address {127.0.0.1:9200}, bound_addresses {[fe80::1]:9200}, {[::1]:9200}, {127.0.0.1:9200}
[2018-01-09 10:43:29,158][INFO ][node ] [Ghost Dancer] started
[2018-01-09 10:43:29,175][INFO ][gateway ] [Ghost Dancer] recovered [0] indices into cluster_state
验证安装成功
不管用哪种方式安装,服务启动以后,如果浏览器打开http://127.0.0.1:9200/
可以看到以下内容说明安装启动成功:
{
"name": "Ghost Dancer",
"cluster_name": "elasticsearch",
"cluster_uuid": "cY_MZO9TQPSNTP72edYkVw",
"version": {
"number": "2.4.6",
"build_hash": "5376dca9f70f3abef96a77f4bb22720ace8240fd",
"build_timestamp": "2017-07-18T12:17:44Z",
"build_snapshot": false,
"lucene_version": "5.5.4"
},
"tagline": "You Know, for Search"
}
添加环境变量
为了方便以后操作ES,将ES加入Mac环境变量,打开Terminal,编辑.bash_profile
$ vim .bash_profile
添加下面内容:
export PATH=$PATH:/Users/chenxin/Workspaces/ES/elasticsearch-2.4.6/bin
之后可以直接使用下面的命令启动ES了:
$ elasticsearch
网友评论