es(Elasticsearch)安装使用(01es安装篇)

1.ES介绍

           Elasticsearch是一个基于Apache Lucene的开源搜索引擎。Lucene可以被认为是迄今为止最先进、性能最好的、功能最全的搜索引擎库。 特点: 分布式的实时文件存储,每个字段都被索引并可被搜索 分布式的实时分析搜索引擎--做不规则查询 可以扩展到上百台服务器,处理PB级结构化或非结构化数据 Elasticsearch也使用Java开发并使用Lucene作为其核心来实现所有索引和搜索的功能,但是它的目的是通过简单的RESTful API来隐藏Lucene的复杂性,从而让全文搜索变得简单。

同类产品

 Solr、ElasticSearch、 Solr、ES 1. 源自搜索引擎,侧重搜索与全文检索。 2. 数据规模从几百万到千万不等,数据量过亿的集群特别少。 有可能存在个别系统数据量过亿,但这并不是普遍现象(就像Oracle的表里的数据规模有可能超过Hive里一样,但需要小型机)。 Hermes 1. 一个基于大索引技术的海量数据实时检索分析平台。侧重数据分析。 2. 数据规模从几亿到万亿不等。最小的表也是千万级别。 在 腾讯17 台TS5机器,就可以处理每天450亿的数据(每条数据1kb左右),数据可以保存一个月之久。 Solr、ES区别 全文检索、搜索、分析。基于lucene Solr 利用 Zookeeper 进行分布式管理,而 Elasticsearch 自身带有分布式协调管理功能; Solr 支持更多格式的数据,而 Elasticsearch 仅支持json文件格式; Solr 官方提供的功能更多,而 Elasticsearch 本身更注重于核心功能,高级功能多有第三方插件提供; Solr 在传统的搜索应用中表现好于 Elasticsearch,但在处理实时搜索应用时效率明显低于 Elasticsearch-----附近的人 Lucene是一个开放源代码的全文检索引擎工具包,但它不是一个完整的全文检索引擎,而是一个全文检索引擎的架构,提供了完整的查询引擎和索引引擎,部分文本分析引擎 搜索引擎产品简介

采用倒排索引

文章推荐

es(Elasticsearch)安装使用(01es安装篇)_少年ing的博客-CSDN博客

 es(Elasticsearch)客户端Kibana安装使用(02Kibana安装篇)_少年ing的博客-CSDN博客

es(Elasticsearch)安装使用(03ik分词器安装篇)_少年ing的博客-CSDN博客

es(Elasticsearch)客户端Elasticsearch-head安装使用(04Elasticsearch-head安装篇)_少年ing的博客-CSDN博客

2.ES官网

ES官网: es官网

3.ES安装

版本声明

CenOS:7.5;
JDK:1.8;
Elasticsearch:7.6.1;

安装环境 centos 7.5   关闭了防火墙

依赖java jdk  1.8

下载安装包

官网下载安装包

官网地址:Past Releases of Elastic Stack Software | Elastic

某云盘下载 链接:https://pan.baidu.com/s/17SEfp1CgwA8s7XMJdyhBag
提取码:507j

一开始 下载最新包 8.3.3 和本地jdk 版本不符起不來具体原因没深入研究  又下载安装的7.6.1 版本

安装

解压到指定目录 /usr/local/  

tar -zxvf elasticsearch-7.6.1-linux-x86_64.tar.gz  -C /usr/local/

解压后

先采用默认配置 启动 看是否能启动成功    进入解压目录启动

关闭窗口 和 ctrl+c   停止es服务

./bin/elasticsearch

关闭窗口 和 ctrl+c   停止es服务 

守护进程启动 无启动信息   关闭 采用 kill -9 进程号方式

 ./bin/elasticsearch -d

 

    关闭 采用 kill -9 进程号方式

核验安装是否成功    如果是阿里云服务器 记得安全组打开9200端口 要不然外网也是无法访问

 查看9200端口是否启用、监听

netstat -nltp | grep 9200

查看安装信息

curl 127.0.0.1:9200

注意:ES需要使用两个端口

  • 9200:HTTP协议,restful api
  • 9300:tcp协议,使用java客户端使用9300端口连接 

 浏览器查看基本信息  ip:9200

 健康检查

ip:9200/_cat/health

 查看所有索引

ip:9200/_cat/indices

查看所有节点

ip:9200/_cat/nodes

配置文件

 外网不能访问 修改配置文件

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
bootstrap.memory_lock: false
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 127.0.0.1

network.bind_host: 0.0.0.0
network.publish_host: 127.0.0.1
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["127.0.0.1"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

4.安裝中出现的错误处理

 1.1 java.lang.RuntimeException: can not run elasticsearch as root

不能用root启动  创建es用户  使用root账户创建es用户  已创建es用户 此处记录下创建es2

   给es用户授权,目录elasticsearch-7.6.1 (重要) 切换es命令来启动

sudo chown -R  es:es elasticsearch-7.6.1/

切换es用户 启动

3.切换es账号,启动服务
su es
./bin/elasticsearch

后台运行,否则客户端退出了,服务就停止了。
./bin/elasticsearch -d
出现started时启动完成

关闭ES服务
kill pid

说明:
Elasticsearch端口9300、9200,其中:
9300是tcp通讯端口,集群ES节点之间通讯使用,9200是http协议的RESTful接口

问题2 需要使用jdk11 我安装的是1.8  不想换jdk 使用es默认的 改配置

future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk1.8.0_1/jre] does not meet this requirement

使用ES7版本时,启动或者执行ES命令,提示上面错误信息。这是由于ES7使用的高版本的jdk。如果不想升级服务的jdk,可以通过修改elasticsearch-env配置文件,使用ES内置的jdk来解决上面的问题

vim elasticsearch-env

# now set the path to java
if [ ! -z "$JAVA_HOME" ]; then
  JAVA="$ES_HOME/jdk/bin/java"
  JAVA_TYPE="JAVA_HOME"
else
  if [ "$(uname -s)" = "Darwin" ]; then
    # macOS has a different structure
    JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java"
  else
    JAVA="$ES_HOME/jdk/bin/java"
  fi  
  JAVA_TYPE="bundled jdk"
fi

 3. 解决内存不足问题,启动的时候卡住的原因了,warning: ignoring JAVA_HOME=/usr/local/jdk1.8.0_131; using bundled JDK

 vim jvm.options

 4.max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

bootstrap check failure [1] of [3]: max number of threads [2048] for user [es] is too low, increase to at least [4096]
bootstrap check failure [2] of [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
bootstrap check failure [3] of [3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

使用root账户 修改配置

1.修改limits.conf

vim /etc/security/limits.conf

 最后添加

* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
* soft stack 65535
* hard stack 65535

  ulimilt -a    发现没生效

退出root账户登录重登后生效;su root

 2. 修改 sysctl.conf     vm.max_map_count >= 262144

vim /etc/sysctl.conf

 在最下面添加 

vm.max_map_count=2655350

 保存,然后重新加载参数:

sysctl -p

目录介绍

目录结构说明
• home目录 :使用$ES_HOME表示,如上图,就是 /usr/local/elasticsearch
• bin/ : 位置 $ES_HOME/bin,包含了elasticsearch和elasticsearch-plugin等脚本
• conf/ :位置 $ES_HOME/config,包含了 配置文件 elasticsearch.yml 和 log4j2.properties,使用 path.conf 指定
• data/ :位置 $ES_HOME/data,包含了每个index/shard的数据文件,可以指定多个位置,使用 path.data 指定
• logs/ : 位置 $ES_HOME/logs,使用 path.logs 指定
• plguins/ : 位置$ES_HOME/plugins
• repo/ :使用 path.repo指定,没有默认位置,表示共享文件系统repository的位置。可以指定多个位置。
• script/ :位置$ES_HOME/scripts,使用 path.scripts 指定。

  • 3
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装Elasticsearch,你可以按照以下步骤进行操作: 1. 首先,你可以从官方网站下载Elasticsearch安装包。官网下载地址为。 2. 下载完成后,解压缩安装包。你可以使用以下命令解压缩tar.gz文件: ```shell tar -zxvf elasticsearch-7.8.1-linux-x86_64.tar.gz ``` 3. 解压缩完成后,进入解压缩后的目录,找到配置文件elasticsearch.yml。你可以使用以下命令来编辑该文件并进行配置: ```shell vim /usr/local/elasticsearch-7.13.2/config/elasticsearch.yml ``` 4. 在编辑配置文件之前,你可能需要了解一些配置选项以满足你的需求。根据你的环境和需求,修改elasticsearch.yml文件中的配置选项。 5. 当你完成了配置文件的修改后,保存并退出编辑器。 6. 现在,可以启动Elasticsearch了。你可以使用以下命令启动Elasticsearch: ```shell ./bin/elasticsearch ``` 这是一个基本的安装和启动Elasticsearch的过程。请注意,具体的步骤可能因操作系统和版本而略有不同。确保你仔细阅读官方文档以获取更详细的安装指南。 关于卸载Elasticsearch,你可以按照以下步骤进行操作: 1. 首先,你可以通过以下命令来查看已安装Elasticsearch软件包: ```shell dpkg -l | grep elastic ``` 2. 接下来,你可以使用以下命令查找Elasticsearch安装关联: ```shell dpkg -L elasticsearch ``` 3. 然后,使用以下命令来移除已安装Elasticsearch软件包: ```shell dpkg -P elasticsearch ``` 4. 继续使用以下命令查找未卸载的目录和文件: ```shell find ./elasticsearch | grep elasticsearch ``` 注意:根据你的环境和安装方式,可能会有其他目录和文件与Elasticsearch相关。 5. 最后,根据你的环境,使用以下命令来移除相关的目录和文件: ```shell rm -r /var/lib/elasticsearch rm /var/lib/dpkg/info/elasticsearch.* rm /etc/default/elasticsearch rm /etc/init.d/elasticsearch ``` 请根据自己的具体环境和需求来执行移除目录和文件的操作,确保操作正确无误。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [一、ElasticSearch安装](https://blog.csdn.net/m0_51295655/article/details/123193074)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值