Preface

This paper mainly introduces ElasticSearch In the use of various problems in the process of solving ideas and methods .

ElasticSearch Environmental installation issues

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

reason : The memory limit is too small !

terms of settlement : Modify the maximum memory limit !

modify sysctl.conf file

vim /etc/sysctl.conf

Add the following configuration at the end :

vm.max_map_count = 655360
vm.swappiness=1

Then save to exit , Enter the following command to make it effective

   sysctl -p

Command view :

tail -3 /etc/sysctl.conf

The picture sample :

2,max number of threads [2048] for user [elastic] is too low, increase to at least [4096]

reason : Too few threads limit !

terms of settlement : Modify the maximum threads limit !

modify 90-nproc.conf file

  vim /etc/security/limits.d/90-nproc.conf

notes : Different linux The server 90-nproc.conf Maybe the file name is different , It is suggested that /etc/security/limits.d/ Check the filename for confirmation before making changes .

Put the following

    soft nproc 2048

It is amended as follows

  soft nproc 4096

Command view :

tail -3 /etc/security/limits.d/90-nproc.conf

3, max file descriptors [65535] for elasticsearch process likely too low, increase to at least [65536]

reason : Too few open files !

terms of settlement : Modify the number of the most open files !

modify limits.conf

vim /etc/security/limits.conf

Add the following at the end :

   * hard nofile 65536
* soft nofile 65536
elastic soft memlock unlimited
elastic hard memlock unlimited

4,ERROR:bootstrap checks failed

reason : Unlocked memory .

terms of settlement : On the error reporting machine elasticsearch.yml Add... To the configuration file bootstrap.memory_lock: true To configure !

ElasticSearch Use of

1,ES Too many subscripts to query

reason : index * pagesiz Greater than ES The default is to return the maximum value 1w, So the prompt is abnormal !

terms of settlement :

One 、 Can pass url Set up , Convenient and fast, no need to restart . as follows :

curl -XPUT http://127.0.0.1:9200/book/_settings -d '{ "index" : { "max_result_window" : 200000000}}'

Be careful :

  • 1.size The size of cannot exceed index.max_result_window The setting of this parameter , The default is 10,000.
  • 2. You need to search for pagination , Can pass from size Combine to do .from Start with the line ,size Indicates how many documents to query .from The default is 0,size The default is 10

Two 、 Set up... Through the configuration file :

{ "order": 1, "template": "index_template*", "settings": { "index.number_of_replicas": "0", "index.number_of_shards": "1", "index.max_result_window": 2147483647 }

2,ES The partition of is not allocated

1、 The positioning problem is divided into pieces

Use ES Of cat API We can analyze the unallocated fragmentation information and the reasons for unallocated fragmentation

curl -XGETlocalhost:9200/_cat/shards?h=index,shard,prirep,state,unassigned.reason| grepUNASSIGNED

The command returns information including the index name 、 Segment number 、 Whether it's a master partition or a replica partition 、 Reasons for not being allocated, etc

If it is a fragment of a deleted index , You can directly use the delete command to delete the index :

curl -XDELETE 'localhost:9200/index_name/'

2、 Cluster purposeful delay allocation

When a node leaves the cluster , The master node will temporarily delay the redistribution of fragmentation , In order to reduce the resource waste caused by rebalancing , In this case , If the source node is in a certain time ( Default 1 minute ) Rejoin in , You can recover the fragmentation information . The log information for this situation is as follows :

[TIMESTAMP][INFO][cluster.routing] [MASTER NODE NAME]delaying allocation for [54] unassigned shards, next check in [1m]

You can modify the delay time manually :

curl -XPUT'localhost:9200/<index_name>/_settings' -d '
{
"settings": {
"index.unassigned.node_left.delayed_timeout": "30s"
}
}'

If you need to change the threshold of all indexes , You can use _all Replace <index_name>

3、 Too many pieces , And the number of nodes is not enough

The master node does not assign the master partition and the replica partition to the same node , Again , Nor will two replica nodes be assigned to the same node , So when there are not enough nodes to allocate slices , There will be an unallocated state ; To avoid that , The relationship between the number of nodes and the number of copies should be N>=R+1 ( among N For the node number ,R Is the number of copies .

We can solve this problem by increasing nodes or reducing the number of replicas .

4、 You need to reallocate the pieces

Partition reallocation is on by default , But maybe for some reason, reallocation was turned off, but I forgot to turn it on , After opening , Shards are redistributed .

Turn on the redistribution command :

curl -XPUT 'localhost:9200/_cluster/settings'-d
'{ "transient":
{"cluster.routing.allocation.enable" : "all"
}
}'

5、 Fragment data no longer exists in the cluster

Data no longer exists in the cluster , processing method :

  • 1, Restore being 0 The source node of the partition , And join the cluster ( Don't force redistribution of master tiles )
  • 2, Use Reroute API Force reallocation fragmentation
curl -XPOST'localhost:9200/_cluster/reroute' -d '{ "commands" :
[ { "allocate_empty_primary" :
{ "index" :"constant-updates", "shard" : 0, "node":"<node_name>", "accept_data_loss": "true" }
}]
}'
  • 3, Re index from raw data or restore from backup snapshot

6、 Insufficient disk space

In general , When disk utilization reaches 85% when , The master node will no longer be allocated to that node

You can use the following command to view disk utilization :

curl -s 'localhost:9200/_cat/allocation?v'

If the disk space is large , and 85% Utilization is a bit wasteful , By setting cluster.routing.allocation.disk.watermark.low

and ( or )cluster.routing.allocation.disk.watermark.high To increase the value :

curl -XPUT 'localhost:9200/_cluster/settings'-d
'{
"transient": {
"cluster.routing.allocation.disk.watermark.low":"90%"
}
}'

notes : If cluster restart is needed, it is effective , Can be transient Change it to persistent;ES The percentage in the setting refers to the used space , Byte value refers to unused space

7、 Multi version problem

ES There are multiple versions in the cluster ES, Causes incompatibilities

3,ES The status of the index library is only readable

reason : ES When the index library writes data

retrying failed action with response code: 403 ({"type"=&gt;"cluster_block_exception", "reason"=&gt;"block

abnormal .

reason : It may be that the disk of the service is almost full , therefore ES The cluster modifies the state of these index libraries , Make it read-only , Unable to write .

The fundamental solution , Add disks or clean up useless data on disks .

Temporary method , The modifier state is readable .

PUT /_all/_settings
{
"index.blocks.read_only_allow_delete": null
}

4,ES The cluster is red

First, check the specific situation of the cluster , Use GET /_cluster/health Command to view the health status of the cluster .

If there is unassigned shards, It means that the fragment is missing , have access to GET /_cat/shards Check the status of the tiles and find the missing tiles .

If the main partition is missing due to cluster downtime , If you can add nodes and partition them automatically, it can be solved in general !

If it's because of missing data , That is to say, the main and auxiliary pieces are lost , Then the data in this case cannot be recovered , You can choose according to the situation , If it's data from an important index library , have access to reindex Re migrate the data , Can solve the cluster red The situation of , But the missing data can't be retrieved .

If it's an unimportant index library , Then delete the index library and rebuild it .

5,ES colony GC Recycling failed

terms of settlement : 1. upgrade JDK Version of ,JDK The version of is higher than 1.8_145;

2. Reduce GC Recovery frequency .

6, Split brain

master not discovered or elected yet, an election requires a node with id

terms of settlement :

1. Appoint master node ,es7.x To configure ,

2. Delete old data The data of , I've never been

es7.x Configuration example :

cluster.name: pancm
node.name: node-3
network.host: 192.168.8.160
node.master: false
node.data: true
discovery.seed_hosts: ["192.168.9.238","192.168.8.181","192.168.8.160"]
# Specify master
cluster.initial_master_nodes: ["192.168.9.238"]
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
cluster.routing.allocation.cluster_concurrent_rebalance: 16
cluster.routing.allocation.node_concurrent_recoveries: 16
cluster.routing.allocation.node_initial_primaries_recoveries: 16
path.data: /home/elastic/masternode/data
path.logs: /home/elastic/masternode/logs

Logstash Use of

1,logstash: Could not execute action: PipelineAction::Create, action_result: false

terms of settlement : For diagonal bar “/”

2, logstash: object mapping for [host] tried to parse field [host] as object, but found a concrete value

terms of settlement : stay filter Add inside :

  #mutate {
# rename =&gt; { "[host][name]" =&gt; "host" }
# }
mutate {
rename =&gt; { "host" =&gt; "host.name" }
}

ElasticSearch Of Java Code problem

1..ES7.x Error in version query :

org.elasticsearch.action.search.SearchRequest.isCcsMinimizeRoundtrips()Z

terms of settlement : defect jar package , complete pom The configuration is as follows :

<dependency>
<groupid>org.elasticsearch.client</groupid>
<artifactid>elasticsearch-rest-high-level-client</artifactid>
<version>7.3.2</version>
<exclusions>
<exclusion>
<groupid>org.elasticsearch</groupid>
<artifactid>elasticsearch</artifactid>
</exclusion>
<exclusion>
<groupid>org.elasticsearch.client</groupid>
<artifactid>elasticsearch-rest-client</artifactid>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupid>org.elasticsearch</groupid>
<artifactid>elasticsearch</artifactid>
<version>7.3.2</version>
</dependency> <dependency>
<groupid>org.elasticsearch.client</groupid>
<artifactid>elasticsearch-rest-client</artifactid>
<version>7.3.2</version>
</dependency>

other

Reference resources :

https://blog.csdn.net/laoyang360/article/details/78443006

https://blog.csdn.net/u013673976/article/details/53305898

https://www.datadoghq.com/blog/elasticsearch-unassigned-shards/

https://blog.csdn.net/kezhen/article/details/79379512

ElasticSearch Practical series :

Originality is not easy. , If it feels good , I hope to give you a recommendation ! Your support is my biggest motivation for writing !

Copyright notice :

author : Nothing in

Source of blog garden :http://www.cnblogs.com/xuwujing

CSDN Source :http://blog.csdn.net/qazwsxpcm

Gold diggers :https://juejin.im/user/5ae45d5bf265da0b8a6761e4    

Personal blog source :http://www.panchengming.com</node_name></index_name></index_name>

ElasticSearch Real combat series 11 : ElasticSearch More articles on error problem solutions

  1. ElasticSearch Real World Series II : ElasticSearch Of DSL Sentence usage tutorial --- Graphic,

    Preface In the last article, I introduced ElasticSearch Clusters and kinaba Installation tutorial for , This article is going to explain ElasticSearch Of DSL Statements use . ElasticSearch DSL Introduce Elastic ...

  2. ElasticSearch Practical series three : ElasticSearch Of JAVA API Use the tutorial

    Preface In the last article, I introduced ElasticSearch Real World Series II : ElasticSearch Of DSL Sentence usage tutorial --- Graphic, , This article is going to explain ElasticSearch 6.x official Java API Of ...

  3. ElasticSearch Series four of actual combat : ElasticSearch Introduction to theoretical knowledge

    Preface In the first few articles about ElasticSearch In the article , Let's talk about it briefly ElasticSearch Some uses of , This article talks about ElasticSearch Some of the theoretical knowledge and some of their own views . Although I am ...

  4. ElasticSearch Actual combat Series 5 : ElasticSearch The basic use of aggregate query tutorial measurement (Metric) polymerization

    Title:ElasticSearch Series four of actual combat : ElasticSearch The basic use of aggregate query tutorial measurement (Metric) polymerization Preface In the last article, I introduced ElasticSearch Practical series three : Elas ...

  5. ElasticSearch Real series 10 : ElasticSearch Hot and cold separation architecture

    Preface This paper mainly introduces ElasticSearch Hot and cold separation architecture and Implementation . Introduction to hot and cold separation architecture The separation of heat and cold is currently ES A very popular architecture , It makes full use of the advantages and disadvantages of cluster machines to achieve resource scheduling and allocation .ES Index write and query speed of cluster ...

  6. ElasticSearch A series of practical battles : ElasticSearch colony +Kinaba Installation tutorial

    Preface This article mainly introduces ElasticSearch Clusters and kinaba Installation tutorial for . ElasticSearch Introduce ElasticSearch It's based on Lucene Search server for , That's right Lucene Conduct ...

  7. ElasticSearch Combat Series 7 : Logstash Practical use - Graphic explanation

    Preface In the last article we introduced Logstash Quick start , This article mainly introduces ELK In the log system Logstash The actual use of . I intend to explain it from the following scenarios . Time zone problem solution When we use logstas ...

  8. ElasticSearch Actual combat series six : Logstash Quick start and actual combat

    Preface This article mainly introduces ELK In the log system Logstash Quick start and actual combat ELK Introduce ELK Three abbreviations of open source software , respectively :Elasticsearch , Logstash, Kibana , They are all ...

  9. ElasticSearch Actual combat series 8 : Filebeat Quick start and use --- Graphic,

    Preface This article mainly introduces ELK In the log system Filebeat Quick start tutorial . ELK Introduce ELK Three abbreviations of open source software , respectively :Elasticsearch , Logstash, Kibana , They are all ...

  10. ElasticSearch Real combat series 9 : ELK Introduction and installation of log system

    Preface This article mainly introduces ELK Log system introduction and use tutorial . ELK Introduce ELK Three abbreviations of open source software , respectively :Elasticsearch , Logstash, Kibana , They are all open source software . A new ...

Random recommendation

  1. Hierarchical Storage structure

    1.hierarchical storage structure      This notion of inserting a smaller, faster storage device (e.g ...

  2. Explain the recent fire step by step density_peak Great

    I've been busy making trouble in the company recently SOA The emergency framework , I saw it on Weibo just two weeks ago density_peak, Reprinted by many people in the circle . Because the name of this algorithm is really eye-catching , How to translate the name of this algorithm into Chinese , Of course, what's more striking is , ...

  3. About TD Email function can not be sent to the authentication mailbox solution

    [ original ]  About TD Email function can not be sent to the authentication mailbox solution Authentication email ,  Mail server ,  user ,  Mail system In view of many peer inquiries TD The question of email , Update the instructions today The principle of solving the problem is as follows . stay TD Install a mail on the server ...

  4. jquery Series of tutorials 6-ajax The application of total solution

    Click on the open : jquery Series of tutorials 1- Total solution of selector jquery Series of tutorials 2-style Style operation is fully understood jquery Series of tutorials 3-DOM Operate the whole solution jquery Series of tutorials 4- Event operations are fully understood jquery Series of tutorials 5- dynamic ...

  5. Mina frame ( Detailed explanation of the actual battle )

    Apache Mina Server Is a network communication application framework , It provides a very convenient framework for developing high performance and high availability network applications . characteristic : Asynchronous NIO frame , take UDP As a " Connection oriented " The agreement One ...

  6. Internal connection query (select * from a join b on a.id = b.id) And Relational query (select * from a , b where a.id = b.id) The difference between

    from https://blog.csdn.net/l690781365/article/details/76261093 1. First understand on .where The order of execution and the efficiency of ? from a join ...

  7. get、post The difference between

    Get.post Differences in requests Preface Whether it's get still post The way , All belong to http agreement , It's just http There are two different ways of transmission , and http The protocol is based on TCP Transmission protocol , So whether it's get still post, In the transport layer ...

  8. MySQL Approximate test update time

    1: demand : Put one 2 A table of tens of millions of data , How long does it take to update 20 lines randomly ? DROP TABLE IF EXISTS test20; CREATE TABLE test20( id INT AUTO_I ...

  9. Web Application type scan recognition tool WhatWeb

    Web Application type scan recognition tool WhatWeb   WhatWeb Is a Kali Linux Pre installed Web Scan tool . It USES Ruby Language writing . The tool can scan websites , Get all kinds of information about the website , As used CMS. Blog flat ...

  10. Get it done android Multi touch simulation

    Principle in android Create a multi touch virtual device , And then writing analog data to the device can