介绍
若果将数据存贮在Elasticsearch中,则可能会碰到须要了解所运行产品的版本的情况。有好多缘由可能造成您须要了解版本。您可能须要检测以查看是否须要升级,或则可能须要确保与弹性堆栈的其他组件兼容。不管您须要版本的诱因怎样,Elasticsearch都可以轻松确定版本。在本教程中,您将学习两种从命令行检测您的Elasticsearch版本的简单方式。
先决条件
在尝试检测Elasticsearch的版本之前,须要具备一些关键的先决条件。系统要求最低:
确保Elasticsearch已安装并正在运行。
要检测Elasticsearch是否正在运行,请在终端中执行以下命令:
curl:9200/_cluster/health?pretty
您应当收到包含有关Elasticsearch实例信息的输出。
#curl:9200/_cluster/health?pretty
"cluster_name":"elasticsearch",
"status":"yellow",
"timed_out":false,
"number_of_nodes":1,
"number_of_data_nodes":1,
"active_primary_shards":37,
"active_shards":37,
"relocating_shards":0,
"initializing_shards":0,
"unassigned_shards":26,
"delayed_unassigned_shards":0,
"number_of_pending_tasks":0,
"number_of_in_flight_fetch":0,
"task_max_waiting_in_queue_millis":0,
"active_shards_percent_as_number":58.7335
倘若您晓得已安装Elasticsearch,但未收到预期的输出,则可能须要在计算机上重新启动Elasticsearch。
一旦确认了这一点,您只须要基本熟悉命令行工具和curl命令即可。倘若您对功能没有太多经验,则curl其基本概念很简单:curl容许您使用HTTP恳求与服务器进行通讯。在本教程中linux 软件ubuntu linux,我们将用于curl与Elasticsearch进行通讯。
检测版本选项
选项1:从命令行使用Curl检测版本
您可以使用两种简单的方式来使用命令行操作来查找正在运行的Elasticsearch版本。检测您的Elasticsearch版本的第一种方式是使用curl命令。在运行Elasticsearch的curl情况下linux版本查看命令,在终端中执行以下所示的命令,以获取有关您的Elasticsearch版本的信息:
curl-XGET':9200'
在此示例中linux版本查看命令,Elasticsearch在默认端口上本地运行,因而我们的HTTP恳求将为:9200。假如Elasticsearch在其他服务器上运行,则您的HTTP恳求将采用方式:9200。
以下结果包含有关Elasticsearch的一些信息,其中包括版本号。在此示例中,结果显示我们的Elasticsearch版本为7.8.0:
#curl-XGET':9200'
"name":"suricata",
"cluster_name":"elasticsearch",
"cluster_uuid":"rFagDbrFagDb66gRuaKlgRuaKl6969ff55KkJMAKkJMA",
"version":{
"number":"7.8.0",
"build_flavor":"default",
"build_type":"rpm",
"build_hash":"757314695644ea9a1dc2fecd26d1a43856725e65",