公号:码农充电站pro

主页:https://codeshellme.github.io

本节来介绍 ES 的安装。

1,下载 ES

ES 是基于 Java 语言开发的,因此,要安装 ES,首先需要有 Java 环境。

从 ES 7.0 开始,ES 内置了 Java 环境,所以如果安装的是 7.0 及以上版本的 ES,就不需要额外安装 Java 环境了。

我们可以到 ES 的下载页面去下载 ES 安装包,你可以根据你的系统,选择不同的安装包进行安装。

我这里选择的是 Windows 版本,下载好压缩包后,将其解压。解压后的目录如下所示:

来看下每个目录的作用:

  • bin 目录中是一些工具命令。
  • data 目录存储数据文件。
  • jdk 目录是 Java 运行环境。
  • lib 目录是 Java 开发类库。
  • logs 目录用于存放日志。
  • modules 目录中包含了所有的 ES 模块。
  • plugins 目录包含所有已安装的插件。
  • config 目录是一些配置文件。
    • elasticsearch.yml 文件用于配置 ES 服务。
    • jvm.options 文件用于配置 JVM 参数。
      • 其中 Xmx 和 Xms 建议设置的大小一样,且不超过机器内存的一半。
      • Xmx 和 Xms 默认为 1g。
      • 这里有一些介绍,你可以参考一下。

2,启动 ES

bin 目录中有一个 elasticsearch 命令,用于运行 ES 实例。我们可以通过 --help 参数查看其帮助:

> bin\elasticsearch --help
Starts Elasticsearch Option Description
------ -----------
-E <KeyValuePair> Configure a setting
-V, --version Prints Elasticsearch version information and exits
-d, --daemonize Starts Elasticsearch in the background `在后台运行`
-h, --help Show help
-p, --pidfile <Path> Creates a pid file in the specified path on start
-q, --quiet Turns off standard output/error streams logging in console
-s, --silent Show minimal output
-v, --verbose Show verbose output

进入到解压后的目录中,在 Windows 系统中用下面命令来启动 ES:

bin\elasticsearch

在 Linux 系统中使用下面命令启动 ES:

bin/elasticsearch

如果启动成功,ES Server 将在本机的 9200 端口监听服务。

我们可以使用 curl 命令访问本机 9200 端口,查看 ES 是否启动成功。如果输出像下面这样,则说明启动成功:

> curl http://localhost:9200/
{
"name" : "LAPTOP-VH778PAK",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "trxvXvAfQ5GxWe3D4vEIXA",
"version" : {
"number" : "7.10.1",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "1c34507e66d7db1211f66f3513706fdf548736aa",
"build_date" : "2020-12-05T01:00:33.671820Z",
"build_snapshot" : false,
"lucene_version" : "8.7.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

你也可以在浏览器中访问服务地址,来查看是否启动成功:

3,安装 ES 插件

我们可以通过安装 ES 插件来为 ES 扩展功能。

bin 目录中有一个 elasticsearch-plugin.bat 命令,是关于 ES 插件的命令,可以使用 --help 参数来查看其用法:

> bin\elasticsearch-plugin --help
A tool for managing installed elasticsearch plugins Commands
--------
list - Lists installed elasticsearch plugins
install - Install a plugin
remove - removes a plugin from Elasticsearch Non-option arguments:
command Option Description
------ -----------
-E <KeyValuePair> Configure a setting
-h, --help Show help
-s, --silent Show minimal output
-v, --verbose Show verbose output

使用 list 参数查看是否有插件:

> bin\elasticsearch-plugin list

没有任何输出,说明没有插件。

下面演示安装 analysis-icu 插件,这是一个分词插件:

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

安装完成后,再次查看插件列表:

> bin\elasticsearch-plugin list
analysis-icu

可以看到,这时有了一个插件。

重新启动 ES 服务后,我们也可以访问 HTTP 接口来查看插件:

> curl localhost:9200/_cat/plugins
LAPTOP-VH778PAK analysis-icu 7.10.1
`服务名称` `插件名称` `插件版本`

添加 ?v 后缀可以查看字段的解释:

> curl localhost:9200/_cat/plugins?v
name component version `解释`
LAPTOP-VH778PAK analysis-icu 7.10.1

这里是关于 ES 插件的介绍,你可以了解一下。

4,运行 ES 集群

我们可以运行多个 ES 实例,将其组成一个 ES 集群,命令如下:

> bin\elasticsearch -E node.name=node1 -E cluster.name=escluster -E path.data=node1_data -d
> bin\elasticsearch -E node.name=node2 -E cluster.name=escluster -E path.data=node2_data -d
> bin\elasticsearch -E node.name=node3 -E cluster.name=escluster -E path.data=node3_data -d

其中 -E 用于指定命令参数,node.name 表示节点名称,cluster.name 表示集群名称,path.data 表示数据目录,-d 表示在后台运行实例。

查看集群中的节点:

> curl localhost:9200/_cat/nodes?v
ip heap.percent ram.percent cpu node.role master name
127.0.0.1 30 91 9 cdhilmrstw - node2
127.0.0.1 28 91 9 cdhilmrstw - node3
127.0.0.1 34 91 9 cdhilmrstw * node1

可以看到有 3 个节点,分别是 node1,node2,node3。其中标有星号 * 的节点为主节点。

默认情况下,集群中启动的第一个节点,会将自己选举为 Master 节点

查看集群健康状态:

> curl localhost:9200/_cluster/health
{
"cluster_name":"escluster", `集群名称`
"status":"green", `健康状态`
"timed_out":false, `是否超时`
"number_of_nodes":3, `节点数量`
"number_of_data_nodes":3, `数据节点数量`
"active_primary_shards":0,
"active_shards":0,
"relocating_shards":0,
"initializing_shards":0,
"unassigned_shards":0,
"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":100
}

(本节完。)


推荐阅读:

ElasticSearch 入门简介


欢迎关注作者公众号,获取更多技术干货。

ElasticSearch 安装与运行的更多相关文章

  1. ElasticSearch安装及运行的坑

    一.确认centos系统是为64位的,x86的不可以安装 1. 下载elasticsearch包 2. 用 tar -zxvf 解压包 3. 增加一个elk用户,elasticsearch7不可用ro ...

  2. ElasticSearch安装及部署

    安装及部署 一.环境配置 操作系统:Cent OS 7ElasticSearch版本:1.3.2JDK版本:1.7.0_51SSH Secure Shell版本:XShell 5elasticsear ...

  3. Elasticsearch是一个分布式可扩展的实时搜索和分析引擎,elasticsearch安装配置及中文分词

    http://fuxiaopang.gitbooks.io/learnelasticsearch/content/  (中文) 在Elasticsearch中,文档术语一种类型(type),各种各样的 ...

  4. Elasticsearch安装详解

    本文只介绍在windows上的安装和配置,其他安装和配置请参见官方文档 ES在windows上安装需下载zip安装包,解压后bin目录下有个 elasticsearch-service.bat 文件. ...

  5. Elasticsearch 安装和配置

      1. 下载并解压   wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.0.tar.gz   ...

  6. ELK日志监控平台安装部署简介--Elasticsearch安装部署

    最近由于工作需要,需要搭建一个ELK日志监控平台,本次采用Filebeat(采集数据)+Elasticsearch(建立索引)+Kibana(展示)架构,实现日志搜索展示功能. 一.安装环境描述: 1 ...

  7. elasticsearch 安装 windows linux macOS

    导读 在上一章节我们介绍Elasticsearch基本概念,今天我们继续进行本章内容,Elasticsearch在各种环境下安装,下面将逐一讲解在各种操作系统或不同安装在不同环境中注意事项. 安装 E ...

  8. elasticsearch 安装、配置

    elasticsearch:基于java开发,基于RESTful web 接口,提供分布式多用户能力的全文搜索引擎. elasticsearch 安装: 1. java SE Development ...

  9. (转载)Centos下Elasticsearch安装详细教程

    原文地址:http://www.cnblogs.com/sunny1009/articles/7874251.html Centos下Elasticsearch安装详细教程 1.Elasticsear ...

随机推荐

  1. 使用sublime text3搭建Python编辑环境

    最近在工作遇到一个难题. 我所在的测试组有一套PC软件前端自动化工程,在进行自动化测试时,需要在一台古老的xp机器上运行,但这台古老的xp机器带给我诸多烦恼,特别是使用Pycharm编辑器时,我遇到了 ...

  2. 通过DNSLOG回显验证漏洞

    通过DNSLOG回显验证漏洞 前言 实际渗透测试中,有些漏洞因为没有回显导致无法准确判断漏洞是否存在,可能导致渗透测试人员浪费大量精力在一个并不存在的漏洞上,因此为了验证一些无回显漏洞,可结合DNSl ...

  3. 温故而知新--day2

    温故而知新--day2 类 类与对象 类是一个抽象的概念,是指对现实生活中一类具有共同特征的事物的抽象.其实列化后称为对象.类里面由类属性组成,类属性可以分为数据属性和函数属性(函数属性又称为类方法) ...

  4. 通过trace分析优化其如何选择执行计划

    mysql5.6提供了对sql的跟踪trace,通过trace文件能够进一步了解为什么优化其选择执行计划a而不选b执行计划,帮助我们更好的理解优化其的行为. 使用方式:首先打开trace,设置格式为j ...

  5. 【Python】国内pip节点

    pip在国内使用国内节点: http://pypi.douban.com/simple 现在已经无法使用了,新版的python3需要使用https://pypi.douban.com/simple/ ...

  6. VSCode运行时弹出powershell

    问题 安装好了vscode并且装上code runner插件后,运行代码时总是弹出powershell,而不是在vscode底部终端 显示运行结果. 解决方法 打开系统cmd ,在窗口顶部条右击打开属 ...

  7. 1.5V转5V的最少电路的芯片电路图

    PW5100满足1.5V转5V的很简洁芯片电路,同时达到了最少的元件即可组成DC-DC电路1.5V转5V的升压转换器系统. PW5100在1.5V转5V输出无负载时,输入效率电流极低,典型值10uA. ...

  8. vue-cli3x4x修改本地端口port

    一.推荐方法 "scripts": { "serve": "vue-cli-service serve --port 3000", &quo ...

  9. jQuery 页面滚动 吸顶 和 吸底

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  10. Linux网卡没有eth0显示ens33原因以及解决办法

    原因 首先说明下eth0与ens33的关系: 目前的主流网卡为使用以太网络协定所开发出来的以太网卡 (Ethernet),因此我们 Linux 就称呼这种网络接口为 ethN (N 为数字). 举例来 ...