在通过MakeDown显示表格效果的时候,当内容存在“|”符号,这个时候需要通过|来进行替换
1 | | 服务名称 | 应用名称 | 类型 | TRACEID | 消耗时间 | |
1 | | 服务名称 | 应用名称 | 类型 | TRACEID | 消耗时间 | |
集群是一个或多个节点(服务器)的集合,它们共同保存您的整个数据,并提供跨所有节点的联合索引和搜索功能。
A cluster is identified by a unique name which by default is “elasticsearch”. This name is important because a node can only be part of a cluster if the node is set up to join the cluster by its name.
群集由唯一名称标识,默认情况下为“elasticsearch”。此名称很重要,因为节点要加入集群作为一部分,节点就需要通过这个名称来加入。
Make sure that you don’t reuse the same cluster names in different environments, otherwise you might end up with nodes joining the wrong cluster. For instance you could use logging-dev, logging-stage, and logging-prod for the development, staging, and production clusters.
确保不要在不同的环境中重用相同的群集名称,否则最终会导致节点加入错误的群集。例如,您可以使用logging-dev,logging-stage以及logging-prod 用于开发,登台和生产集群。
Note that it is valid and perfectly fine to have a cluster with only a single node in it. Furthermore, you may also have multiple independent clusters each with its own unique cluster name.
节点是作为群集单个服务器,存储数据并参与群集的索引和搜索功能。就像集群一样,节点由名称标识,默认情况下,该名称是在启动时分配给节点的随机通用唯一标识符(UUID)。如果不需要默认值,可以定义所需的任何节点名称。此名称对于管理目的非常重要,您可以在其中识别网络中哪些服务器与Elasticsearch集群中的哪些节点相对应。
A node can be configured to join a specific cluster by the cluster name. By default, each node is set up to join a cluster named elasticsearch which means that if you start up a number of nodes on your network and—assuming they can discover each other—they will all automatically form and join a single cluster named elasticsearch.
可以将节点配置为按群集名称加入特定群集。默认情况下,每个节点都设置为加入一个名为cluster的集群elasticsearch,这意味着如果您在网络上启动了许多节点并且假设它们可以相互发现 - 它们将自动形成并加入一个名为的集群elasticsearch。
In a single cluster, you can have as many nodes as you want. Furthermore, if there are no other Elasticsearch nodes currently running on your network, starting a single node will by default form a new single-node cluster named elasticsearch.
索引是具有某些类似特征的文档集合。例如,您可以拥有客户数据的索引,产品目录的另一个索引以及订单数据的另一个索引。索引由名称标识(索引必须全部小写),此名称用于在对其中的文档执行索引,搜索,更新和删除操作时引用索引。
In a single cluster, you can define as many indexes as you want.
在单个群集中,您可以根据需要定义任意数量的索引。
type 在大于6.0.0的版本已经废弃。
文档是可以被索引的基本单元,例如,你可用一个JSON文档存储一个用户信息,一个JSON文档存储一个产品信息,一个JSON文档存储一个订单信息.
Within an index/type, you can store as many documents as you want. Note that although a document physically resides in an index, a document actually must be indexed/assigned to a type inside an index.
索引可能存储大量数据并且超过单个节点的硬件存储限制,例如,占用1TB磁盘空间包含十亿个文档的单个索引可能不适合存储在单个节点的磁盘中,这样会导致太慢而无法从单个索引节点提供搜索请求。
To solve this problem, Elasticsearch provides the ability to subdivide your index into multiple pieces called shards. When you create an index, you can simply define the number of shards that you want. Each shard is in itself a fully-functional and independent “index” that can be hosted on any node in the cluster.
为了解决这个问题,ES提供了将索引细分为多个称为分片的功能。创建索引时,只需定义所需的分片数即可。每个分片本身都是一个功能齐全且独立的“索引”,可以托管在集群中的任何节点上。
Sharding is important for two primary reasons:
分片很重要,主要有两个原因:
The mechanics of how a shard is distributed and also how its documents are aggregated back into search requests are completely managed by Elasticsearch and is transparent to you as the user.
分片的分布方式以及如何将其文档聚合回搜索请求的机制完全由Elasticsearch管理,对用户而言是透明的。
In a network/cloud environment where failures can be expected anytime, it is very useful and highly recommended to have a failover mechanism in case a shard/node somehow goes offline or disappears for whatever reason. To this end, Elasticsearch allows you to make one or more copies of your index’s shards into what are called replica shards, or replicas for short.
在可以随时发生故障的网络/云环境中,非常有用,强烈建议使用故障转移机制,以防分片/节点以某种方式脱机或因任何原因消失。为此,Elasticsearch允许您将索引的分片的一个或多个副本制作成所谓的副本分片或简称副本。
Replication is important for two primary reasons:
复制很重要,主要有两个原因:
它在碎片/节点发生故障时提供高可用性。因此,请务必注意,副本分片永远不会在与从中复制的原始/主分片相同的节点上分配。
It allows you to scale out your search volume/throughput since searches can be executed on all replicas in parallel.
To summarize, each index can be split into multiple shards. An index can also be replicated zero (meaning no replicas) or more times. Once replicated, each index will have primary shards (the original shards that were replicated from) and replica shards (the copies of the primary shards).
总而言之,每个索引可以拆分为多个分片。索引也可以复制为零(表示没有副本)或更多次。复制后,每个索引都将具有主分片(从中复制的原始分片)和副本分片(主分片的副本)。
The number of shards and replicas can be defined per index at the time the index is created. After the index is created, you may also change the number of replicas dynamically anytime. You can change the number of shards for an existing index using the _shrink and _split APIs, however this is not a trivial task and pre-planning for the correct number of shards is the optimal approach.
可以在创建索引时为每个索引定义分片和副本的数量。创建索引后,您还可以随时动态更改副本数。您可以使用_shrink和_splitAPI 更改现有索引的分片数,但这不是一项简单的任务,并且预先计划正确数量的分片是最佳方法。
By default, each index in Elasticsearch is allocated 5 primary shards and 1 replica which means that if you have at least two nodes in your cluster, your index will have 5 primary shards and another 5 replica shards (1 complete replica) for a total of 10 shards per index.
ES最低使用JDK8版本安装,建议1.8.0_131。
1 | ./elasticsearch -Ecluster.name=my_cluster_name -Enode.name=my_node_name |
1 | GET /_cat/health?v |
1 | GET / _cat / nodes ?v |
1 | GET /_cat/indices?v |
1 | PUT /customer?pretty |
1 | PUT /customer/_doc/1?pretty |
1 | docker run --name es_1 \ |
安装JDK8版本。
Linux平台需要先创建用户,在指定用户权限下运行ES程序。
修改elasticsearch.yml配置文件。
Cluster
1. cluster.name 集群名称,如果有多个集群,那么每个集群名就得是唯一的。
Node
1. node.name 节点名称
2.node.attr.rack 该节点自定义信息。
Paths
1. path.data 存储数据的目录
2. path.logs 存储日志的目录
Memory
1. bootstrap.memory_lock 是否使用交换内存
Network
1. network.host: 0.0.0.0 绑定的地址
2. http.port: 9200 绑定的端口
Discovery
1. discovery.zen.ping.unicast.hosts: ["host1", "host2"] 设置集群中master集群初始化列表,这个数组里的机器将被自动发现加入集群
2. discovery.zen.minimum_master_nodes 最小集群数量= total / 2 + 1
Gateway
1. gateway.recover_after_nodes 控制集群在达到多少个节点之后才会开始数据恢复,通过这个设置可以避免集群自动相互发现的初期,shard分片不全的问题。
提示OpenJDK内存分配失败,如下图:
解决方法:通过调整ES的JVM参数,根据机器配置适当调整大小。
提示最大虚拟内存不足,如下图
解决办法:通过调整机器的最大内存配置文件
1 | vim /etc/sysctl.conf |
其它问题
system call filters failed to install,出现这个问题的时候。-Ebootstrap.system_call_filter=false
max file descriptors [4096] for elasticsearch process is too low,出现这个说明,系统打开的文件描述符太少。
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N 提示运行的容器虚拟机CPU数量只有1个,调整即可。
Docker Container exited with code 137,这个错误发生在分配给容器的内存不足导致的错误,调整机器配置。
Failed to Setup IP tables: Unable to enable SKIP DNAT rule: 发生这个错误,重启docker容器即可。