在 Mac OS 中安装 Elasticsearch 7.5.2

Elasticsearch 是一个基于 Lucene 构建的开源全文搜索引擎,同时也是一个分布式文档数据库。本文演示如何在 Mac OS中安装用于开发用的 Elasticsearch。

在 Mac OS 中安装 Elasticsearch 有两种方式,一种是使用 homebrew, 一种是直接下载 gz 包,手动安装,本文选择后者。

下载安装包

浏览官方网址, 选择 mac os 的版本,或是直接使用下载链接 下载 7.5.2 版。

下载文件大小为 268M

安装

将安装包解压到任意目录,在本文中我选择解压到 ~/devel 目录中。解压完成后,设置环境变量, 编辑 ~/.bash_profile 文件,加入以下内容:

1
2
3
4
5
ES_HOME=~/devel/elasticsearch-7.5.2
export ES_HOME

PATH=$PATH:~/devel//Users/jini/devel/elasticsearch-7.5.2/bin
export PATH

保存以后执行以下命令让修改立即生效。

1
source ~/.bash_profile

启动并验证

在终端执行:

1
elasticsearch

如果前面的步骤配置正确,则可以看到类似如下的输出:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[2020-02-08T11:19:58,238][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [jinidembp] [controller/7848] [Main.cc@110] controller (64 bit): Version 7.5.2 (Build 68f6981dfb8e2d) Copyright (c) 2020 Elasticsearch BV
[2020-02-08T11:19:59,095][DEBUG][o.e.a.ActionModule ] [jinidembp] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2020-02-08T11:19:59,275][INFO ][o.e.d.DiscoveryModule ] [jinidembp] using discovery type [zen] and seed hosts providers [settings]
[2020-02-08T11:20:00,410][INFO ][o.e.n.Node ] [jinidembp] initialized
[2020-02-08T11:20:00,411][INFO ][o.e.n.Node ] [jinidembp] starting ...
[2020-02-08T11:20:00,619][INFO ][o.e.t.TransportService ] [jinidembp] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2020-02-08T11:20:00,824][WARN ][o.e.b.BootstrapChecks ] [jinidembp] the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
[2020-02-08T11:20:00,842][INFO ][o.e.c.c.ClusterBootstrapService] [jinidembp] no discovery configuration found, will perform best-effort cluster bootstrapping after [3s] unless existing master is discovered
[2020-02-08T11:20:03,850][INFO ][o.e.c.c.Coordinator ] [jinidembp] setting initial configuration to VotingConfiguration{QJxOcuDgQy-H36uxWMu0Rg}
[2020-02-08T11:20:04,054][INFO ][o.e.c.s.MasterService ] [jinidembp] elected-as-master ([1] nodes joined)[{jinidembp}{QJxOcuDgQy-H36uxWMu0Rg}{weyZUDapTRqLpLacY6hUvA}{127.0.0.1}{127.0.0.1:9300}{dilm}{ml.machine_memory=8589934592, xpack.installed=true, ml.max_open_jobs=20} elect leader, _BECOME_MASTER_TASK_, _FINISH_ELECTION_], term: 1, version: 1, delta: master node changed {previous [], current [{jinidembp}{QJxOcuDgQy-H36uxWMu0Rg}{weyZUDapTRqLpLacY6hUvA}{127.0.0.1}{127.0.0.1:9300}{dilm}{ml.machine_memory=8589934592, xpack.installed=true, ml.max_open_jobs=20}]}
[2020-02-08T11:20:04,127][INFO ][o.e.c.c.CoordinationState] [jinidembp] cluster UUID set to [0V3G9aRhQ76KrPD3KyPOdg]
[2020-02-08T11:20:04,190][INFO ][o.e.c.s.ClusterApplierService] [jinidembp] master node changed {previous [], current [{jinidembp}{QJxOcuDgQy-H36uxWMu0Rg}{weyZUDapTRqLpLacY6hUvA}{127.0.0.1}{127.0.0.1:9300}{dilm}{ml.machine_memory=8589934592, xpack.installed=true, ml.max_open_jobs=20}]}, term: 1, version: 1, reason: Publication{term=1, version=1}
[2020-02-08T11:20:04,246][INFO ][o.e.h.AbstractHttpServerTransport] [jinidembp] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2020-02-08T11:20:04,247][INFO ][o.e.n.Node ] [jinidembp] started
[2020-02-08T11:20:04,341][INFO ][o.e.g.GatewayService ] [jinidembp] recovered [0] indices into cluster_state
[2020-02-08T11:20:04,585][INFO ][o.e.c.m.MetaDataIndexTemplateService] [jinidembp] adding template [.watch-history-10] for index patterns [.watcher-history-10*]
[2020-02-08T11:20:04,661][INFO ][o.e.c.m.MetaDataIndexTemplateService] [jinidembp] adding template [.watches] for index patterns [.watches*]
[2020-02-08T11:20:04,737][INFO ][o.e.c.m.MetaDataIndexTemplateService] [jinidembp] adding template [.triggered_watches] for index patterns [.triggered_watches*]
[2020-02-08T11:20:04,802][INFO ][o.e.c.m.MetaDataIndexTemplateService] [jinidembp] adding template [.slm-history] for index patterns [.slm-history-1*]
[2020-02-08T11:20:04,879][INFO ][o.e.c.m.MetaDataIndexTemplateService] [jinidembp] adding template [.monitoring-logstash] for index patterns [.monitoring-logstash-7-*]
[2020-02-08T11:20:04,980][INFO ][o.e.c.m.MetaDataIndexTemplateService] [jinidembp] adding template [.monitoring-es] for index patterns [.monitoring-es-7-*]
[2020-02-08T11:20:05,065][INFO ][o.e.c.m.MetaDataIndexTemplateService] [jinidembp] adding template [.monitoring-beats] for index patterns [.monitoring-beats-7-*]
[2020-02-08T11:20:05,141][INFO ][o.e.c.m.MetaDataIndexTemplateService] [jinidembp] adding template [.monitoring-alerts-7] for index patterns [.monitoring-alerts-7]
[2020-02-08T11:20:05,212][INFO ][o.e.c.m.MetaDataIndexTemplateService] [jinidembp] adding template [.monitoring-kibana] for index patterns [.monitoring-kibana-7-*]
[2020-02-08T11:20:05,279][INFO ][o.e.x.i.a.TransportPutLifecycleAction] [jinidembp] adding index lifecycle policy [watch-history-ilm-policy]
[2020-02-08T11:20:05,351][INFO ][o.e.x.i.a.TransportPutLifecycleAction] [jinidembp] adding index lifecycle policy [slm-history-ilm-policy]
[2020-02-08T11:20:05,544][INFO ][o.e.l.LicenseService ] [jinidembp] license [3d2a70c1-d826-45f3-8a2b-7defeb51b26f] mode [basic] - valid
[2020-02-08T11:20:05,545][INFO ][o.e.x.s.s.SecurityStatusChangeListener] [jinidembp] Active license is now [BASIC]; Security is disabled

说明 Elasticsearch 已经正常启动。

打开浏览器,浏览

1
http://localhost:9200/

看到如下内容,说明安装正常:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"name": "jinidembp",
"cluster_name": "elasticsearch",
"cluster_uuid": "0V3G9aRhQ76KrPD3KyPOdg",
"version": {
"number": "7.5.2",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "8bec50e1e0ad29dad5653712cf3bb580cd1afcdf",
"build_date": "2020-01-15T12:11:52.313576Z",
"build_snapshot": false,
"lucene_version": "8.3.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}

如果对 Elasticsearch 的功能感兴趣,又希望能快速上手,可以试试 ElasticSearch教程

本文标题:在 Mac OS 中安装 Elasticsearch 7.5.2

文章作者:晨星

发布时间:2020年02月08日 - 11:02

最后更新:2020年09月16日 - 08:09

原始链接:https://www.mls-tech.info/microservice/elasticsearch/es-setup-on-mac-os/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。