跳到主要内容

十七、Elasticsearch 教程: 集群管理 API

本章节要介绍的这些 API 用于获取有关集群及其节点的信息,并且可以对集群进行更改

调用这些 API 时,我们需要指定节点的名称、地址或使用 _local 路径参数

例如下面的请求

GET http://localhost:9200/_nodes/_local

会返回本地集群的信息

{
"_nodes": {
"total": 1,
"successful": 1,
"failed": 0
},
"cluster_name": "elasticsearch",
"nodes": {
"4zwAMlTzRCaioBeOE9PaNw": {
"name": "4zwAMlT",
"transport_address": "127.0.0.1:9300",
"host": "127.0.0.1",
"ip": "127.0.0.1",
"version": "6.3.0",
"build_flavor": "default",
"build_type": "zip",
"build_hash": "424e937",
"total_indexing_buffer": 103887667,
"roles": [
"master",
"data",
"ingest"
],
"attributes": {
"ml.machine_memory": "4294967296",
"xpack.installed": "true",
"ml.max_open_jobs": "20",
"ml.enabled": "true"
},
"settings": {
"client": {
"type": "node"
},
"cluster": {
"name": "elasticsearch"
},
"http": {
"type": "security4",
"type.default": "netty4"
},
"node": {
"attr": {
"xpack": {
"installed": "true"
},
"ml": {
"machine_memory": "4294967296",
"max_open_jobs": "20",
"enabled": "true"
}
},
"name": "4zwAMlT"
},
"path": {
"logs": "/usr/local/elasticsearch/6.3.0/logs",
"home": "/usr/local/elasticsearch/6.3.0"
},
"transport": {
"type": "security4",
"features": {
"x-pack": "true"
},
"type.default": "netty4"
}
},
"os": {
"refresh_interval_in_millis": 1000,
"name": "Mac OS X",
"arch": "x86_64",
"version": "10.13.5",
"available_processors": 4,
"allocated_processors": 4
},
"process": {
"refresh_interval_in_millis": 1000,
"id": 33621,
"mlockall": false
},
"jvm": {
"pid": 33621,
"version": "1.8.0_101",
"vm_name": "Java HotSpot(TM) 64-Bit Server VM",
"vm_version": "25.101-b13",
"vm_vendor": "Oracle Corporation",
"start_time_in_millis": 1530181150844,
"mem": {
"heap_init_in_bytes": 1073741824,
"heap_max_in_bytes": 1038876672,
"non_heap_init_in_bytes": 2555904,
"non_heap_max_in_bytes": 0,
"direct_max_in_bytes": 1038876672
},
"gc_collectors": [
"ParNew",
"ConcurrentMarkSweep"
],
"memory_pools": [
"Code Cache",
"Metaspace",
"Compressed Class Space",
"Par Eden Space",
"Par Survivor Space",
"CMS Old Gen"
],
"using_compressed_ordinary_object_pointers": "true",
"input_arguments": [
"-Xms1g",
"-Xmx1g",
"-XX:+UseConcMarkSweepGC",
"-XX:CMSInitiatingOccupancyFraction=75",
"-XX:+UseCMSInitiatingOccupancyOnly",
"-XX:+AlwaysPreTouch",
"-Xss1m",
"-Djava.awt.headless=true",
"-Dfile.encoding=UTF-8",
"-Djna.nosys=true",
"-XX:-OmitStackTraceInFastThrow",
"-Dio.netty.noUnsafe=true",
"-Dio.netty.noKeySetOptimization=true",
"-Dio.netty.recycler.maxCapacityPerThread=0",
"-Dlog4j.shutdownHookEnabled=false",
"-Dlog4j2.disable.jmx=true",
"-Djava.io.tmpdir=/var/folders/yk/2446sljj6hn82nvzkdgxltmw0000gn/T/elasticsearch.PbjUEM9C",
"-XX:+HeapDumpOnOutOfMemoryError",
"-XX:HeapDumpPath=data",
"-XX:ErrorFile=logs/hs_err_pid%p.log",
"-XX:+PrintGCDetails",
"-XX:+PrintGCDateStamps",
"-XX:+PrintTenuringDistribution",
"-XX:+PrintGCApplicationStoppedTime",
"-Xloggc:logs/gc.log",
"-XX:+UseGCLogFileRotation",
"-XX:NumberOfGCLogFiles=32",
"-XX:GCLogFileSize=64m",
"-Des.path.home=/usr/local/elasticsearch/6.3.0",
"-Des.path.conf=/usr/local/elasticsearch/6.3.0/config",
"-Des.distribution.flavor=default",
"-Des.distribution.type=zip"
]
},
"thread_pool": {
"watcher": {
"type": "fixed",
"min": 20,
"max": 20,
"queue_size": 1000
},
"force_merge": {
"type": "fixed",
"min": 1,
"max": 1,
"queue_size": -1
},
"security-token-key": {
"type": "fixed",
"min": 1,
"max": 1,
"queue_size": 1000
},
"ml_datafeed": {
"type": "fixed",
"min": 20,
"max": 20,
"queue_size": 200
},
"fetch_shard_started": {
"type": "scaling",
"min": 1,
"max": 8,
"keep_alive": "5m",
"queue_size": -1
},
"listener": {
"type": "fixed",
"min": 2,
"max": 2,
"queue_size": -1
},
"ml_autodetect": {
"type": "fixed",
"min": 80,
"max": 80,
"queue_size": 80
},
"index": {
"type": "fixed",
"min": 4,
"max": 4,
"queue_size": 200
},
"refresh": {
"type": "scaling",
"min": 1,
"max": 2,
"keep_alive": "5m",
"queue_size": -1
},
"generic": {
"type": "scaling",
"min": 4,
"max": 128,
"keep_alive": "30s",
"queue_size": -1
},
"rollup_indexing": {
"type": "fixed",
"min": 4,
"max": 4,
"queue_size": 4
},
"warmer": {
"type": "scaling",
"min": 1,
"max": 2,
"keep_alive": "5m",
"queue_size": -1
},
"search": {
"type": "fixed_auto_queue_size",
"min": 7,
"max": 7,
"queue_size": 1000
},
"flush": {
"type": "scaling",
"min": 1,
"max": 2,
"keep_alive": "5m",
"queue_size": -1
},
"fetch_shard_store": {
"type": "scaling",
"min": 1,
"max": 8,
"keep_alive": "5m",
"queue_size": -1
},
"management": {
"type": "scaling",
"min": 1,
"max": 5,
"keep_alive": "5m",
"queue_size": -1
},
"ml_utility": {
"type": "fixed",
"min": 80,
"max": 80,
"queue_size": 500
},
"get": {
"type": "fixed",
"min": 4,
"max": 4,
"queue_size": 1000
},
"analyze": {
"type": "fixed",
"min": 1,
"max": 1,
"queue_size": 16
},
"write": {
"type": "fixed",
"min": 4,
"max": 4,
"queue_size": 200
},
"snapshot": {
"type": "scaling",
"min": 1,
"max": 2,
"keep_alive": "5m",
"queue_size": -1
}
},
"transport": {
"bound_address": [
"[::1]:9300",
"127.0.0.1:9300"
],
"publish_address": "127.0.0.1:9300",
"profiles": {}
},
"http": {
"bound_address": [
"[::1]:9200",
"127.0.0.1:9200"
],
"publish_address": "127.0.0.1:9200",
"max_content_length_in_bytes": 104857600
},
"plugins": [
{
"name": "analysis-jieba",
"version": "6.0.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "A jieba analysis of plugins for Elasticsearch",
"classname": "org.elasticsearch.plugin.analysis.jieba.AnalysisJiebaPlugin",
"extended_plugins": [],
"has_native_controller": false
}
],
"modules": [
{
"name": "aggs-matrix-stats",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Adds aggregations whose input are a list of numeric fields and output includes a matrix.",
"classname": "org.elasticsearch.search.aggregations.matrix.MatrixAggregationPlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "analysis-common",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Adds \"built in\" analyzers to Elasticsearch.",
"classname": "org.elasticsearch.analysis.common.CommonAnalysisPlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "ingest-common",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Module for ingest processors that do not require additional security permissions or have large dependencies and resources",
"classname": "org.elasticsearch.ingest.common.IngestCommonPlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "lang-expression",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Lucene expressions integration for Elasticsearch",
"classname": "org.elasticsearch.script.expression.ExpressionPlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "lang-mustache",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Mustache scripting integration for Elasticsearch",
"classname": "org.elasticsearch.script.mustache.MustachePlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "lang-painless",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "An easy, safe and fast scripting language for Elasticsearch",
"classname": "org.elasticsearch.painless.PainlessPlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "mapper-extras",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Adds advanced field mappers",
"classname": "org.elasticsearch.index.mapper.MapperExtrasPlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "parent-join",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "This module adds the support parent-child queries and aggregations",
"classname": "org.elasticsearch.join.ParentJoinPlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "percolator",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Percolator module adds capability to index queries and query these queries by specifying documents",
"classname": "org.elasticsearch.percolator.PercolatorPlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "rank-eval",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "The Rank Eval module adds APIs to evaluate ranking quality.",
"classname": "org.elasticsearch.index.rankeval.RankEvalPlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "reindex",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "The Reindex module adds APIs to reindex from one index to another or update documents in place.",
"classname": "org.elasticsearch.index.reindex.ReindexPlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "repository-url",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Module for URL repository",
"classname": "org.elasticsearch.plugin.repository.url.URLRepositoryPlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "transport-netty4",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Netty 4 based transport implementation",
"classname": "org.elasticsearch.transport.Netty4Plugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "tribe",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Tribe module",
"classname": "org.elasticsearch.tribe.TribePlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "x-pack-core",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Elasticsearch Expanded Pack Plugin - Core",
"classname": "org.elasticsearch.xpack.core.XPackPlugin",
"extended_plugins": [],
"has_native_controller": false
},
{
"name": "x-pack-deprecation",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Elasticsearch Expanded Pack Plugin - Deprecation",
"classname": "org.elasticsearch.xpack.deprecation.Deprecation",
"extended_plugins": [
"x-pack-core"
],
"has_native_controller": false
},
{
"name": "x-pack-graph",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Elasticsearch Expanded Pack Plugin - Graph",
"classname": "org.elasticsearch.xpack.graph.Graph",
"extended_plugins": [
"x-pack-core"
],
"has_native_controller": false
},
{
"name": "x-pack-logstash",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Elasticsearch Expanded Pack Plugin - Logstash",
"classname": "org.elasticsearch.xpack.logstash.Logstash",
"extended_plugins": [
"x-pack-core"
],
"has_native_controller": false
},
{
"name": "x-pack-ml",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Elasticsearch Expanded Pack Plugin - Machine Learning",
"classname": "org.elasticsearch.xpack.ml.MachineLearning",
"extended_plugins": [
"x-pack-core"
],
"has_native_controller": true
},
{
"name": "x-pack-monitoring",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Elasticsearch Expanded Pack Plugin - Monitoring",
"classname": "org.elasticsearch.xpack.monitoring.Monitoring",
"extended_plugins": [
"x-pack-core"
],
"has_native_controller": false
},
{
"name": "x-pack-rollup",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Elasticsearch Expanded Pack Plugin - Rollup",
"classname": "org.elasticsearch.xpack.rollup.Rollup",
"extended_plugins": [
"x-pack-core"
],
"has_native_controller": false
},
{
"name": "x-pack-security",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Elasticsearch Expanded Pack Plugin - Security",
"classname": "org.elasticsearch.xpack.security.Security",
"extended_plugins": [
"x-pack-core"
],
"has_native_controller": false
},
{
"name": "x-pack-sql",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "The Elasticsearch plugin that powers SQL for Elasticsearch",
"classname": "org.elasticsearch.xpack.sql.plugin.SqlPlugin",
"extended_plugins": [
"x-pack-core"
],
"has_native_controller": false
},
{
"name": "x-pack-upgrade",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Elasticsearch Expanded Pack Plugin - Upgrade",
"classname": "org.elasticsearch.xpack.upgrade.Upgrade",
"extended_plugins": [
"x-pack-core"
],
"has_native_controller": false
},
{
"name": "x-pack-watcher",
"version": "6.3.0",
"elasticsearch_version": "6.3.0",
"java_version": "1.8",
"description": "Elasticsearch Expanded Pack Plugin - Watcher",
"classname": "org.elasticsearch.xpack.watcher.Watcher",
"extended_plugins": [
"x-pack-core"
],
"has_native_controller": false
}
],
"ingest": {
"processors": [
{
"type": "append"
},
{
"type": "convert"
},
{
"type": "date"
},
{
"type": "date_index_name"
},
{
"type": "dot_expander"
},
{
"type": "fail"
},
{
"type": "foreach"
},
{
"type": "grok"
},
{
"type": "gsub"
},
{
"type": "join"
},
{
"type": "json"
},
{
"type": "kv"
},
{
"type": "lowercase"
},
{
"type": "remove"
},
{
"type": "rename"
},
{
"type": "script"
},
{
"type": "set"
},
{
"type": "set_security_user"
},
{
"type": "sort"
},
{
"type": "split"
},
{
"type": "trim"
},
{
"type": "uppercase"
},
{
"type": "urldecode"
}
]
}
}
}