ElasticSearch总结【基于5.2.2版本】

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)
表示是否包含副本。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
elasticsearch-5.2.2客户端JAVA开发需要的69个jar包。当然也可以通过maven自动下载。activation-1.1.jar,bcpkix-jdk15on-1.55.jar,bcprov-jdk15on-1.55.jar,commons-codec-1.10.jar,commons-logging-1.2.jar,compiler-0.9.3.jar,elasticsearch-5.2.2.jar,elasticsearch-analysis-ik-5.2.2.jar,elasticsearch-analysis-pinyin-5.2.2.jar,guava-16.0.1.jar,HdrHistogram-2.1.6.jar,hppc-0.7.1.jar,httpasyncclient-4.1.2.jar,httpclient-4.5.2.jar,httpcore-4.4.5.jar,httpcore-nio-4.4.5.jar,jackson-core-2.8.6.jar,jackson-dataformat-cbor-2.8.6.jar,jackson-dataformat-smile-2.8.6.jar,jackson-dataformat-yaml-2.8.6.jar,javax.mail-1.5.3.jar,jna-4.2.2.jar,joda-time-2.9.5.jar,jopt-simple-5.0.2.jar,jts-1.13.jar,lang-mustache-client-5.1.1.jar,log4j-1.2-api-2.7.jar,log4j-api-2.7.jar,log4j-core-2.7.jar,lucene-analyzers-common-6.4.1.jar,lucene-backward-codecs-6.4.1.jar,lucene-core-6.4.1.jar,lucene-grouping-6.4.1.jar,lucene-highlighter-6.4.1.jar,lucene-join-6.4.1.jar,lucene-memory-6.4.1.jar,lucene-misc-6.4.1.jar,lucene-queries-6.4.1.jar,lucene-queryparser-6.4.1.jar,lucene-sandbox-6.4.1.jar,lucene-spatial-6.4.1.jar,lucene-spatial-extras-6.4.1.jar,lucene-spatial3d-6.4.1.jar,lucene-suggest-6.4.1.jar,netty-3.10.6.Final.jar,netty-buffer-4.1.7.Final.jar,netty-codec-4.1.7.Final.jar,netty-codec-http-4.1.7.Final.jar,netty-common-4.1.7.Final.jar,netty-handler-4.1.7.Final.jar,netty-resolver-4.1.7.Final.jar,netty-transport-4.1.7.Final.jar,nlp-lang-1.7.jar,owasp-java-html-sanitizer-r239.jar,percolator-client-5.1.1.jar,reindex-client-5.1.1.jar,rest-5.1.1.jar,rest-5.2.2.jar,securesm-1.1.jar,snakeyaml-1.15.jar,sniffer-5.2.2.jar,spatial4j-0.6.jar,t-digest-3.0.jar,transport-5.1.1.jar,transport-netty3-client-5.1.1.jar,transport-netty4-5.2.2.jar,transport-netty4-client-5.1.1.jar,unboundid-ldapsdk-3.2.0.jar,x-pack-5.2.2.jar,
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

LuckyJiang.2021

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

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

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

打赏作者

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

抵扣说明:

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

余额充值