如何在 MacOS 上安装 Elasticsearch
Elasticsearch

> 
> 安装 Elasticsearch 很复杂！以下是如何在 Mac 上安装。
> 
> 
> 


![](/data/attachment/album/201907/20/064958dnnwvp8wqzqq4fm2.jpg)


[Elasticsearch](https://www.getapp.com/it-management-software/a/qbox-dot-io-hosted-elasticsearch/) 是一个用 Java 开发的开源全文搜索引擎。用户上传 JSON 格式的数据集。然后，Elasticsearch 在向集群索引中的文档添加可搜索的引用之前先保存原始文档。


Elasticsearch 创建还不到九年，但它是最受欢迎的企业搜索引擎。Elastic 在 2019 年 6 月 25 日发布了最新的更新版本 7.2.0。


[Kibana](https://www.elastic.co/products/kibana) 是 Elasticsearch 的开源数据可视化工具。此工具可帮助用户在 Elasticsearch 集群的内容索引之上创建可视化。


[Sunbursts](https://en.wikipedia.org/wiki/Pie_chart#Ring)、[地理空间数据地图](https://en.wikipedia.org/wiki/Spatial_analysis)、[关系分析](https://en.wikipedia.org/wiki/Correlation_and_dependence)和实时数据面板只是其中几个功能。并且由于 Elasticsearch 的机器学习能力，你可以了解哪些属性可能会影响你的数据（如服务器或 IP 地址）并查找异常模式。


在上个月的 [DevFest DC](https://www.devfestdc.org/) 中，Booz Allen Hamilton 的首席数据科学家 [Summer Rankin 博士](https://www.summerrankin.com/about)将 TED Talk 的内容数据集上传到了 Elasticsearch，然后使用 Kibana 快速构建了面板。出于好奇，几天后我去了一个 Elasticsearch 聚会。


由于本课程针对的是新手，因此我们从第一步开始：在我们的笔记本上安装 Elastic 和 Kibana。如果没有安装这两个包，我们无法将莎士比亚的文本数据集作为测试 JSON 文件创建可视化了。


接下来，我将分享在 MacOS 上下载、安装和运行 Elasticsearch V7.1.1 的分步说明。这是我在 2019 年 6 月中旬参加 Elasticsearch 聚会时的最新版本。


### 下载适合 MacOS 的 Elasticsearch


1、进入 <https://www.elastic.co/downloads/elasticsearch>，你会看到下面的页面：


![The Elasticsearch download page.](/data/attachment/album/201907/20/065017vv8c61wv8kvvvnov.png "The Elasticsearch download page.")


2、在**下载**区，单击 **MacOS**，将 Elasticsearch TAR 文件（例如，`elasticsearch-7.1.1-darwin-x86_64.tar`）下载到 `Downloads` 文件夹。 3、双击此文件并解压到自己的文件夹中（例如，`elasticsearch-7.1.1`），这其中包含 TAR 中的所有文件。


**提示**：如果你希望 Elasticsearch 放在另一个文件夹中，现在可以移动它。


### 在 MacOS 命令行中运行 Elasticsearch


如果你愿意，你可以只用命令行运行 Elasticsearch。只需遵循以下流程：


1、[打开终端窗口](https://support.apple.com/en-ca/guide/terminal/welcome/mac)。


2、在终端窗口中，输入你的 Elasticsearch 文件夹。例如（如果你移动了程序，请将 `Downloads` 更改为正确的路径）：



```
$ cd ~Downloads/elasticsearch-1.1.0
```

3、切换到 Elasticsearch 的 `bin` 子文件夹，然后启动该程序。例如：



```
$ cd bin 
$ ./elasticsearch
```

这是我启动 Elasticsearch 1.1.0 时命令行终端显示的一些输出：


![Terminal output when running Elasticsearch.](/data/attachment/album/201907/20/065020fbpv5zwske8gkwop.png "Terminal output when running Elasticsearch.")


**注意**：默认情况下，Elasticsearch 在前台运行，这可能会导致计算机速度变慢。按 `Ctrl-C` 可以阻止 Elasticsearch 运行。


### 使用 GUI 运行 Elasticsearch


如果你更喜欢点击操作，你可以像这样运行 Elasticsearch：


1、打开一个新的 **Finder** 窗口。


2、在左侧 Finder 栏中选择 `Downloads`（如果你将 Elasticsearch 移动了另一个文件夹，请进入它）。


3、打开名为 `elasticsearch-7.1.1` 的文件夹（对于此例）。出现了八个子文件夹。


![The elasticsearch/bin menu.](/data/attachment/album/201907/20/065021iev3qa56j43jj36a.png "The elasticsearch/bin menu.")


4、打开 `bin` 子文件夹。如上面的截图所示，此子文件夹中有 20 个文件。 5、单击第一个文件，即 `elasticsearch`。


请注意，你可能会收到安全警告，如下所示：


![The security warning dialog box.](/data/attachment/album/201907/20/065021w1ze3cjneqctbc00.jpg "The security warning dialog box.")


这时候要打开程序需要：


1. 在警告对话框中单击 **OK**。
2. 打开**系统偏好**。
3. 单击**安全和隐私**，打开如下窗口：


![Where you can allow your computer to open the downloaded file.](/data/attachment/album/201907/20/065021c61nyx7hlb5h2vq7.jpg "Where you can allow your computer to open the downloaded file.")
4. 单击**永远打开**，打开如下所示的确认对话框：


![Security confirmation dialog box.](/data/attachment/album/201907/20/065022xpap8g88w3md9uos.jpg "Security confirmation dialog box.")
5. 单击**打开**。会打开一个终端窗口并启动 Elasticsearch。


启动过程可能需要一段时间，所以让它继续运行。最终，它将完成，你最后将看到类似这样的输出：


![Launching Elasticsearch in MacOS.](/data/attachment/album/201907/20/065022eigxpzvn31n3gzni.png "Launching Elasticsearch in MacOS.")


### 了解更多


安装 Elasticsearch 之后，就可以开始探索了！


该工具的 [Elasticsearch：开始使用](https://www.elastic.co/webinars/getting-started-elasticsearch?ultron=%5BB%5D-Elastic-US+CA-Exact&blade=adwords-s&Device=c&thor=elasticsearch&gclid=EAIaIQobChMImdbvlqOP4wIVjI-zCh3P_Q9mEAAYASABEgJuAvD_BwE)指南会根据你的目标指导你。它的介绍视频介绍了在 [Elasticsearch Service](https://info.elastic.co/elasticsearch-service-gaw-v10-nav.html?ultron=%5BB%5D-Elastic-US+CA-Exact&blade=adwords-s&Device=c&thor=elasticsearch%20service&gclid=EAIaIQobChMI_MXHt-SZ4wIVJBh9Ch3wsQfPEAAYASAAEgJo9fD_BwE) 上启动托管集群，执行基本搜索查询，通过创建、读取、更新和删除（CRUD）REST API 等方式操作数据的步骤。


本指南还提供文档链接，开发控制台命令，培训订阅以及 Elasticsearch Service 的免费试用版。此试用版允许你在 AWS 和 GCP 上部署 Elastic 和 Kibana 以支持云中的 Elastic 集群。


在本文的后续内容中，我们将介绍在 MacOS 上安装 Kibana 所需的步骤。此过程将通过不同的数据可视化将你的 Elasticsearch 查询带到一个新的水平。 敬请关注！




---


via: <https://opensource.com/article/19/7/installing-elasticsearch-macos>


作者：[Lauren Maffeo](https://opensource.com/users/lmaffeo/users/don-watkins) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
[Elasticsearch](https://www.getapp.com/it-management-software/a/qbox-dot-io-hosted-elasticsearch/) is an open source, full-text search engine developed in Java. Users upload datasets as JSON files. Then, Elasticsearch stores the original document before adding a searchable reference to the document in the cluster’s index.

Less than nine years after its creation, Elasticsearch is the most popular enterprise search engine. Elastic released its latest update—version 7.2.0 —on June 25, 2019.

[Kibana](https://www.elastic.co/products/kibana) is an open source data visualizer for Elasticsearch. This tool helps users create visualizations on top of content indexed in an Elasticsearch cluster.

[Sunbursts](https://en.wikipedia.org/wiki/Pie_chart#Ring), [geospatial data maps](https://en.wikipedia.org/wiki/Spatial_analysis), [relationship analyses](https://en.wikipedia.org/wiki/Correlation_and_dependence), and dashboards with live data are just a few options. And thanks to Elasticsearch’s machine learning prowess, you can learn which properties might influence your data (like servers or IP addresses) and find abnormal patterns.

At [DevFest DC](https://www.devfestdc.org/) last month, [Dr. Summer Rankin](https://www.summerrankin.com/about)—lead data scientist at Booz Allen Hamilton—uploaded a dataset of content from TED Talks to Elasticsearch, then used Kibana to quickly build a dashboard. Intrigued, I went to an Elasticsearch meetup days later.

Since this course was for newbies, we started at Square One: Installing Elastic and Kibana on our laptops. Without both packages installed, we couldn’t create our own visualizations from the dataset of Shakespeare texts we were using as a dummy JSON file.

Next, I will share step-by-step instructions for downloading, installing, and running Elasticsearch Version 7.1.1 on MacOS. This was the latest version when I attended the Elasticsearch meetup in mid-June 2019.

## Downloading Elasticsearch for MacOS

- Go to
[https://www.elastic.co/downloads/elasticsearch](https://www.elastic.co/downloads/elasticsearch), which takes you to the webpage below:

![The Elasticsearch download page. The Elasticsearch download page.](https://opensource.com/sites/default/files/uploads/wwa1f3_600px_0.png)

- In the
**Downloads**section, click**MacOS**, which downloads the Elasticsearch TAR file (for example,**elasticsearch-7.1.1-darwin-x86_64.tar**) into your**Downloads**folder. - Double-click this file to unpack it into its own folder (for example,
**elasticsearch-7.1.1**), which contains all of the files that were in the TAR.

**Tip**: If you want Elasticsearch to live in another folder, now is the time to move this folder.

## Running Elasticsearch from the MacOS command line

You can run Elasticsearch only using the command line if you prefer. Just follow this process:

[Open a](https://support.apple.com/en-ca/guide/terminal/welcome/mac).**Terminal**window- In the terminal window, enter your Elasticsearch folder. For example (if you moved the program, change
**Downloads**to the correct path):

**$ cd ~Downloads/elasticsearch-1.1.0**

- Change to the Elasticsearch
**bin**subfolder, and start the program. For example:

**$ cd bin $ ./elasticsearch**

Here’s some of the output that my command line terminal displayed when I launched Elasticsearch 1.1.0:

![Terminal output when running Elasticsearch. Terminal output when running Elasticsearch.](https://opensource.com/sites/default/files/uploads/io6t1a_600px.png)

**NOTE**: Elasticsearch runs in the foreground by default, which can cause your computer to slow down. Press **Ctrl-C to** stop Elasticsearch from running.

## Running Elasticsearch using the GUI

If you prefer your point-and-click environment, you can run Elasticsearch like so:

- Open a new
**Finder**window. - Select
**Downloads**in the left Finder sidebar (or, if you moved Elasticsearch to another folder, navigate to there). - Open the folder called (for the sake of this example)
**elasticsearch-7.1.1**. A selection of eight subfolders appears.

![The elasticsearch/bin menu. The elasticsearch/bin menu.](https://opensource.com/sites/default/files/uploads/o43yku_600px.png)

- Open the
**bin**subfolder. As the screenshot above shows, this subfolder yields 20 assets. - Click the first option, which is
**elasticsearch**.

Note that you may get a security warning, as shown below:

![The security warning dialog box. The security warning dialog box.](https://opensource.com/sites/default/files/uploads/elasticsearch_security_warning_500px.jpg)

opensource.com


In order to open the program in this case:

- Click
**OK**in the warning dialog box. - Open
**System Preferences**. - Click
**Security & Privacy**, which opens the window shown below:

![Where you can allow your computer to open the downloaded file. Where you can allow your computer to open the downloaded file.](https://opensource.com/sites/default/files/uploads/the_general_tab_of_the_system_preferences_security_and_privacy_window.jpg)

- Click
**Open Anyway**, which opens the confirmation dialog box shown below:

![Security confirmation dialog box. Security confirmation dialog box.](https://opensource.com/sites/default/files/uploads/confirmation_dialog_box.jpg)

- Click
**Open**. A terminal window opens and launches Elasticsearch.

The launch process can take a while, so let it run. Eventually, it will finish, and you will see output similar to this at the end:

![Launching Elasticsearch in MacOS. Launching Elasticsearch in MacOS.](https://opensource.com/sites/default/files/uploads/y5dvtu_600px.png)

## Learning more

Once you’ve installed Elasticsearch, it’s time to start exploring!

The tool’s [Elasticsearch: Getting Started](https://www.elastic.co/webinars/getting-started-elasticsearch?ultron=%5BB%5D-Elastic-US+CA-Exact&blade=adwords-s&Device=c&thor=elasticsearch&gclid=EAIaIQobChMImdbvlqOP4wIVjI-zCh3P_Q9mEAAYASABEgJuAvD_BwE) guide directs you based on your goals. Its introductory video walks through steps to launch a hosted cluster on [Elasticsearch Service](https://info.elastic.co/elasticsearch-service-gaw-v10-nav.html?ultron=%5BB%5D-Elastic-US+CA-Exact&blade=adwords-s&Device=c&thor=elasticsearch%20service&gclid=EAIaIQobChMI_MXHt-SZ4wIVJBh9Ch3wsQfPEAAYASAAEgJo9fD_BwE), perform basic search queries, play with data through create, read, update, and delete (CRUD) REST APIs, and more.

This guide also offers links to documentation, dev console commands, training subscriptions, and a free trial of Elasticsearch Service. This trial lets you deploy Elastic and Kibana on AWS and GCP to support your Elastic clusters in the cloud.

In the follow-up to this article, we’ll walk through the steps you’ll take to install Kibana on MacOS. This process will take your Elasticsearch queries to the next level via diverse data visualizations. Stay tuned!

## 1 Comment