Elasticsearch7.2中文教程翻译(二):Elasticsearch安装

@高效码农  July 22, 2019

开始使用Elasticsearch

准备将Elasticsearch用于测试驱动器并亲自了解如何使用REST API来存储,搜索和分析数据?

按照此入门教程进行操作:

1.启动并运行Elasticsearch实例
2.索引一些示例文档
3.使用Elasticsearch查询语言搜索文档
4.使用存储分析和指标聚合分析结果

需要的基础知识?
查看Elasticsearch简介以学习术语并理解Elasticsearch如何工作的基础知识。如果您已经熟悉Elasticsearch并希望了解它如何与堆栈的其余部分一起工作,您可能需要跳转到 Elastic Stack Tutorial,了解如何使用Elasticsearch、Kibana、Beats和Logstash设置系统监视解决方案。

安装

Linux上的安装示例
为简单起见,我们使用tar文件。

让我们下载Elasticsearch 8.0.0 Linux tar,如下所示:

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.0.0-linux-x86_64.tar.gz

然后提取如下:

tar -xvf elasticsearch-8.0.0-linux-x86_64.tar.gz

然后它会在当前目录中创建一堆文件和文件夹。然后我们进入bin目录,如下所示:

cd elasticsearch-8.0.0 / bin

现在我们准备启动我们的节点和单个集群:

./elasticsearch

使用MSI Windows Installer 编辑的安装示例
对于Windows用户,我们建议使用MSI安装程序包。该软件包包含一个图形用户界面(GUI),可指导您完成安装过程。

首先,从https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.0.0.msi下载Elasticsearch 8.0.0 MSI 。

然后双击下载的文件以启动GUI。在第一个屏幕中,选择部署目录:

msi安装程序位置
然后选择是作为服务安装还是根据需要手动启动Elasticsearch。要与Linux示例保持一致,请选择不安装为服务:

msi安装程序没有服务
对于配置,只需保留默认值:

msi安装程序配置
再次,要与tar示例对齐,请取消选中所有插件以不安装任何插件:

msi安装程序插件
单击安装按钮后,将安装Elasticsearch:

msi安装程序成功
默认情况下,Elasticsearch将安装在%PROGRAMFILES%ElasticElasticsearch。在此处导航并进入bin目录,如下所示:

使用命令提示符:

cd %PROGRAMFILES%\ Elastic \ Elasticsearch \ bin

使用PowerShell:

cd $ env:PROGRAMFILES \ Elastic \ Elasticsearch \ bin

现在我们准备启动我们的节点和单个集群:

\ elasticsearch.exe

成功运行节点
如果一切顺利安装,你应该看到一堆如下所示的消息:

[2018-09-13T12:20:01,766][INFO ][o.e.e.NodeEnvironment    ] [localhost.localdomain] using [1] data paths, mounts [[/home (/dev/mapper/fedora-home)]], net usable_space [335.3gb], net total_space [410.3gb], types [ext4]
[2018-09-13T12:20:01,772][INFO ][o.e.e.NodeEnvironment    ] [localhost.localdomain] heap size [990.7mb], compressed ordinary object pointers [true]
[2018-09-13T12:20:01,774][INFO ][o.e.n.Node               ] [localhost.localdomain] node name [localhost.localdomain], node ID [B0aEHNagTiWx7SYj-l4NTw]
[2018-09-13T12:20:01,775][INFO ][o.e.n.Node               ] [localhost.localdomain] version[8.0.0], pid[13030], build[oss/zip/77fc20e/2018-09-13T15:37:57.478402Z], OS[Linux/4.16.11-100.fc26.x86_64/amd64], JVM["Oracle Corporation"/OpenJDK 64-Bit Server VM/10/10+46]
[2018-09-13T12:20:01,775][INFO ][o.e.n.Node               ] [localhost.localdomain] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch.LN1ctLCi, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m, -Djava.locale.providers=COMPAT, -XX:UseAVX=2, -Dio.netty.allocator.type=unpooled, -Des.path.home=/home/manybubbles/Workspaces/Elastic/master/elasticsearch/qa/unconfigured-node-name/build/cluster/integTestCluster node0/elasticsearch-7.0.0-alpha1-SNAPSHOT, -Des.path.conf=/home/manybubbles/Workspaces/Elastic/master/elasticsearch/qa/unconfigured-node-name/build/cluster/integTestCluster node0/elasticsearch-7.0.0-alpha1-SNAPSHOT/config, -Des.distribution.flavor=oss, -Des.distribution.type=zip]
[2018-09-13T12:20:02,543][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [aggs-matrix-stats]
[2018-09-13T12:20:02,543][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [analysis-common]
[2018-09-13T12:20:02,543][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [ingest-common]
[2018-09-13T12:20:02,544][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [lang-expression]
[2018-09-13T12:20:02,544][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [lang-mustache]
[2018-09-13T12:20:02,544][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [lang-painless]
[2018-09-13T12:20:02,544][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [mapper-extras]
[2018-09-13T12:20:02,544][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [parent-join]
[2018-09-13T12:20:02,544][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [percolator]
[2018-09-13T12:20:02,544][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [rank-eval]
[2018-09-13T12:20:02,544][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [reindex]
[2018-09-13T12:20:02,545][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [repository-url]
[2018-09-13T12:20:02,545][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] loaded module [transport-netty4]
[2018-09-13T12:20:02,545][INFO ][o.e.p.PluginsService     ] [localhost.localdomain] no plugins loaded
[2018-09-13T12:20:04,657][INFO ][o.e.d.DiscoveryModule    ] [localhost.localdomain] using discovery type [zen]
[2018-09-13T12:20:05,006][INFO ][o.e.n.Node               ] [localhost.localdomain] initialized
[2018-09-13T12:20:05,007][INFO ][o.e.n.Node               ] [localhost.localdomain] starting ...
[2018-09-13T12:20:05,202][INFO ][o.e.t.TransportService   ] [localhost.localdomain] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2018-09-13T12:20:05,221][WARN ][o.e.b.BootstrapChecks    ] [localhost.localdomain] max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2018-09-13T12:20:05,221][WARN ][o.e.b.BootstrapChecks    ] [localhost.localdomain] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018-09-13T12:20:08,355][INFO ][o.e.c.s.MasterService    ] [localhost.localdomain] elected-as-master ([0] nodes joined)[, ], reason: master node changed {previous [], current [{localhost.localdomain}{B0aEHNagTiWx7SYj-l4NTw}{hzsQz6CVQMCTpMCVLM4IHg}{127.0.0.1}{127.0.0.1:9300}{testattr=test}]}
[2018-09-13T12:20:08,360][INFO ][o.e.c.s.ClusterApplierService] [localhost.localdomain] master node changed {previous [], current [{localhost.localdomain}{B0aEHNagTiWx7SYj-l4NTw}{hzsQz6CVQMCTpMCVLM4IHg}{127.0.0.1}{127.0.0.1:9300}{testattr=test}]}, reason: apply cluster state (from master [master {localhost.localdomain}{B0aEHNagTiWx7SYj-l4NTw}{hzsQz6CVQMCTpMCVLM4IHg}{127.0.0.1}{127.0.0.1:9300}{testattr=test} committed version [1] source [elected-as-master ([0] nodes joined)[, ]]])
[2018-09-13T12:20:08,384][INFO ][o.e.h.n.Netty4HttpServerTransport] [localhost.localdomain] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2018-09-13T12:20:08,384][INFO ][o.e.n.Node               ] [localhost.localdomain] started

我们可以看到名为“localhost.localdomain”的节点已经启动并在单个集群中选择自己作为主节点。现在不要担心没有掌握这些输出是什么。这里最重要的是我们在一个集群中启动了一个节点。

如前所述,我们可以覆盖集群或节点名称。这可以在启动Elasticsearch时从命令行完成,如下所示:

./elasticsearch -Ecluster.name = my_cluster_name -Enode.name = my_node_name

另请注意标记为http的行,其中包含有关可从中访问节点的HTTP地址(192.168.8.112)和端口(9200)的信息。默认情况下,Elasticsearch使用port 9200来提供对其REST API的访问。如有必要,可以配置此端口。



评论已关闭