在Mac上下载Elasticsearch并在本地运行

获取Elasticsearch和Kibana。

请从以下位置下载Elasticsearch和Kibana。

开始使用Elasticsearch、Kibana和Elastic Stack | Elastic

スクリーンショット 2020-10-06 12.56.25.png

elasticsearch.yml的翻译:

elasticsearch-7.9.2/config/elasticsearch.yml 的含义是什么?

数据存储区域的更改

为了方便处理,进行数据存储区域的更改。

我在这里创建了一个位于/Users/你的名字/Elasticsearch/local/data/下的文件。

# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /Users/your name/Elasticsearch/local/data/data
#
# Path to log files:
#
path.logs: /Users/your name/Elasticsearch/local/data/logs
#

增加插件

添加Kuromoji

$ bin/elasticsearch-plugin install analysis-kuromoji
-> Installing analysis-kuromoji
-> Downloading analysis-kuromoji from elastic
[=================================================] 100%   
-> Installed analysis-kuromoji

添加ICU

$ bin/elasticsearch-plugin install analysis-icu
-> Installing analysis-icu
-> Downloading analysis-icu from elastic
[=================================================] 100%   
-> Installed analysis-icu

执行

移动到elasticsearch文件夹。

bin/elasticsearch

进入Kibana文件夹。

bin/kibana

打开Kibana

访问以下网址

http://localhost:5601
スクリーンショット 2020-10-06 13.09.14.png

登録样本数据

请点击我们的样本数据按钮

スクリーンショット 2020-10-06 13.11.42.png

点击一下Add data按钮尝试要测试的数据
在这里我们试试添加一个Sample web logs数据

undefined

当数据添加完成后,按钮会变为“查看数据”,请点击查看仪表盘。

undefined

仪表板显示得很不错。

スクリーンショット 2020-10-06 13.14.58.png

数据的注册

我将使用Github上的样本数据,具体是CraigKelly/steam-data项目中的一项简单数据项目。

请从以下网址下载示例数据:
https://s3.amazonaws.com/public-service/steam-data.tar.gz

这里也写了详细的说明

在Kibana菜单中,选择[机器学习 > 数据可视化器]。

スクリーンショット 2020-10-06 14.34.14.png

把刚刚下载的文件中的games-features.csv放进去。

スクリーンショット 2020-10-06 14.33.41.png

数据被加载并解析了标题行。数据也被解析,并推断出了大致的类型。

スクリーンショット 2020-10-06 14.34.49.png

如果想要更改名称,请点击“覆盖设定”。

スクリーンショット 2020-10-06 16.51.50.png

如果原始数据中包含空列,需要在“Should trim fields”选项中勾选。

当你仔细观察一番后,点击一下“导入”按钮。

导入数据

这次我们不希望自动创建_id,而是想要使用数据中的ResponseID作为_id,因此我们将在Ingest pipeline中添加设置。

在Ingest pipeline的底部,添加一个_id字段的设置,位置在remove: field的下方。

,
{
  "set" : {
    "field" : "_id",
    "value" : "{{ResponseID}}"
  }
}
スクリーンショット 2020-10-06 17.13.26.png

点击导入按钮。

スクリーンショット 2020-10-06 17.14.09.png

稍等一下就会被吸收进去。

スクリーンショット 2020-10-06 17.15.11.png

发现

当我在Discover中查看时,数据已被导入。

スクリーンショット 2020-10-06 17.16.36.png

添加認證

激活认证

在elasticsearch.yml文件中添加以下内容

xpack.security.enabled: true

设置密码

通过 elasticsearch-setup-passwords 工具设置密码。

$ sudo bin/elasticsearch-setup-passwords interactive

结果

Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y


Enter password for [elastic]: 
Reenter password for [elastic]: 
Enter password for [apm_system]: 
Reenter password for [apm_system]: 
Enter password for [kibana_system]: 
Reenter password for [kibana_system]: 
Enter password for [logstash_system]: 
Reenter password for [logstash_system]: 
Enter password for [beats_system]: 
Reenter password for [beats_system]: 
Enter password for [remote_monitoring_user]: 
Reenter password for [remote_monitoring_user]: 
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]

为每个用户设置密码

Kibana设置

将以下内容添加到 kibana.yml 文件中。

elasticsearch.username: "kibana_system"
elasticsearch.password: "password"

在构建Elasticsearch的认证用户之前,需要预先注册。由于新冠疫情的影响,本月一直在家办公。

广告
将在 10 秒后关闭
bannerAds