ElasticSearch总结【基于5.2.2版本】

本文详细介绍Elasticsearch 5.2.2版本的安装步骤、配置参数调整、环境变量设置及常见问题解决方法,包括如何修改elasticsearch.yml,设置JVM参数,使用head插件,以及elasticsearch-head-master插件的安装与配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

elasticsearch安装使用步骤

1 拷贝elasticsearch-5.2.2文件夹
   es5必须安装jdk1.8
2 修改/config/elasticsearch.yml中的
  node.name
  network.host
  discovery.zen.ping.unicast.hosts
  path.data
  还可设置node的性质
     #master节点
          node.master: true
     #存储数据节点
          node.data: false
     #搜索、协调节点
          node.ingest: true
  
3 增加(如已增加,此步骤忽略)在/config/elasticsearch.yml中:
  bootstrap.memory_lock: false
  bootstrap.system_call_filter: false         

4 使用head插件时需设置:
  http.cors.enabled: true
  http.cors.allow-origin: "*"

5 去除ES_HEAP_SIZE环境变量(如果以前没设置则忽略此步)
  系统环境变量配置文件: /etc/profile
  用户环境变量配置文件: /home/用户名/.bashrc


6 修改/etc/security/limits.conf,配置形如:
  *  soft  nofile   655360
  *  hard  nofile   655360
  *  soft  nproc    2048
  *  hard  nproc    4096
  *  soft  memlock   unlimited
  *  hard  memlock   unlimited


7.修改 /etc/security/limits.d/90-nproc.conf
  修改如下内容
  * soft nproc 1024改为
  * soft nproc 2048
  
8 修改 /etc/sysctl.conf,增加
  vm.max_map_count=655360
  并执行命令:sysctl -p
  
9 以非root用户启动es,启动命令:
  ./bin/elasticsearch-5.2.2

FAQ: 


1 Q: 启动时报:
unable to install syscall filter: 
java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ 
with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
答:此为警告,操作系统内核版本太低,可升级操作系统;若不升级也可使用,部分功能会受影响。

2 Q: 启动时报ERROR: bootstrap checks failed
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
system call filters failed to install; check the logs and fix your configuration or disable 
system call filters at your own risk

答: 步骤8未正确执行所致,或者文件修改后未生效。

elasticsearch-head-master插件以及安装方式

1.修改es的设置
    vi /es根目录/config/elasticsearch.yml
    增加:(冒号之后有空格)
    http.cors.enabled: true
     http.cors.allow-origin: "*"
     重启es

2.修改es-headmaster设置
    elasticsearch-head-master\_site\app.js
    4329行
    this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "localhost:9200";
    localhost地址改为es的地址
    
3.压缩文件夹elasticsearch-head-master
    在cmd下命令:
    jar -cvf head.war elasticsearch-head-master
    将生成的head.war放到tomcat目录下的webapps,重启tomcat
    
4.浏览器输入  
    tomcat所在机器ip:8080//head/elasticsearch-head-master/   即可。

 

elasticsearch常用命令【5.2.2版本】


一 检查es是否正常启动


http://es节点IP:9200/
输出以下信息表示启动正常

{
  "name" : "node-157",
  "cluster_name" : "datastore",
  "cluster_uuid" : "sT4c_CSVTd65sGm3JldvJA",
  "version" : {
    "number" : "5.2.2",
    "build_hash" : "f9d9b74",
    "build_date" : "2017-02-24T17:26:45.835Z",
    "build_snapshot" : false,
    "lucene_version" : "6.4.1"
  },
  "tagline" : "You Know, for Search"
}

查看状态

curl -XGET "http://es节点IP:9200/_nodes/stats?pretty" 
http://es节点IP:9200/_cluster/settings?pretty 

查看节点状态

http://es节点IP:9200/_nodes/?pretty
http://es节点IP:9200/_nodes/jvm/?pretty

 

二 查看索引数据


//查看索引状态
http://es节点IP:9200/testsearchstore/_stats/?pretty
//查看索引数据
http://es节点IP:9200/testsearchstore/_search?pretty&size=30
//查看索引中数据的条数
http://es节点IP:9200/testsearchstore/_search?size=0&pretty

//查看索引的内容
http://es节点IP:9200/testsearchstore/_search?pretty

三 查看索引配置


//查看节点状态(索引信息)
http://es节点IP:9200/_nodes/?pretty
//查看节点jvm状态
http://es节点IP:9200/_nodes/jvm/?pretty
//查看线程设置
http://es节点IP:9200/_nodes/thread_pool?pretty

四 刷新


//刷新操作
http://es节点IP:9200/testsearchstore/_refresh
//冲洗
http://es节点IP:9200/testsearchstore/_flush

五 删除

删除索引
curl -XDELETE http://es节点IP:9200/searchstore?pretty
 

六 查看分词

http://es节点IP:9200/testsearchstore/_analyze?analyzer=ik_max_word&pretty&text=五环路
http://es节点IP:9200/testsearchstore/_analyze?analyzer=ik_smart&pretty&text=京华腾东光科技发展有限公司
http://es节点IP:9200/testsearchstore/_analyze?analyzer=ik_max_word&pretty&text=北京华腾东光科技发展有限公司

七 查看线程设置

http://es节点IP:9200/_nodes/thread_pool?pretty

八 修改线程设置

curl -XPUT "http://es节点IP:9200/_cluster/settings?pretty" -d'{
 "transient":{
 		"threadpool.bulk.type":"fixed",
 		"threadpool.bulk.size":"24",
 		"threadpool.bulk.queue_size":"500"
 }
}' 

九 其他

curl -XPUT "http://es节点IP:9200/testsearchstore/_settings" -d '{"index":{"max_result_window":100000}}'

 

问题记录

ES head插件里可以看到Size和docs有两个值
size: 169Mi (169Mi)
docs: 89,139 (125,118)
表示是否包含副本。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LuckyJiang.2021

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值