Elasticsearch common interface and configuration files Comments

## Elasticsearch common interface documentation

### 1, the query cluster health status
1. ** command: **

`` `
Curl -XGET 'http://127.0.0.1:9200/_cluster/health?pretty
` ``
execution results are as follows:




















| Color | sense |
| -------- | ----- |
| Green | all major fragmentation and fragmentation copy available |
| Yellow | all major slice is available, but not all replication slices available |
| Red | not all of the major fragments are available, the status of the cluster is unavailable |


### 2, query for all nodes in the cluster surviving
1. ** command: **

`` `
Curl -XGET 'HTTP: // localhost: 9200 / _cat / Nodes'
` ``
execution results are as follows:

`` `
[Tsbweb1 the root @ ~] # curl -XGET 'http://127.0.0.1:9200/_cat/nodes?v'
Host IP heap.percent ram.percent Load Master node.role name
DES1 34 is 37 [10.0.2.69 D 0.46 - DES1 
CES1 10.0.2.68 53 is 24 0.01 - - CES1
MES1 10.0.2.67. 4 69 1.61 - * MES1
`` `
node.role =" - "= master" m "which is representative of the primary (master) node, while the node .role = "-" master = " *" represents the master node being used.
node.role = "d" master = " -" which is representative of the data (data) node.
node.role = "-" master = " -" it on behalf of the client (client) node.

2. When we start Elasticsearch instance, it will start at least one node. Connecting the plurality of nodes in the same cluster name on the part of the cluster, by default, each node in the cluster can process the data transmission http request, and cluster nodes, all nodes in the cluster knows all other cluster node, the client may forward the request to the appropriate node. The following types of nodes:

- ** Main (master) node **: In a node taken node.master set to True (the default) when it eligible to be selected as the master node controls the whole cluster.

- ** Data (data) ** node: a node on node.data set to True (the default) time. The node stores the data and perform data-related operations, such as additions and deletions, search, and polymerization.

- ** ** client node: a node when node.master node.data and time are set to false, the data can not be maintained both can not be the master node, the node can act as a client node, the user can respond , the relevant operations and sends to other nodes.

### 3, see the cluster all indexes
1. ** command: **

`` `
Curl -XGET 'HTTP: // localhost:? 9200 / _cat / indices v'
` ``
This request will include information for all indexes in the cluster, information includes:

`` `
Health Status PRI index REP docs.count docs.deleted store.size pri.store.size
Green Open agenttopic_20161117. 8. 1 698 848 0 317.7mb 158.8mb
Green Open mobilesdk_20161117. 8. 1 165 861 0 129.5mb 64.7mb
` ``
index health , the name of the index, the main number of fragments, number of copies, the total number of documents, delete the number of documents, the total storage space, the master slice storage space.

### 4, view all the cluster fragmentation information
1. ** command: **

`` `
Curl -XGET '127.0.0.1:9200/_cat/shards'
` ``
execution results are as follows:

`` `
Index Shard prirep IP Node Store State docs
agenttopic_20161202 the STARTED 2 P 24674 3.2MB 10.0.2.69 DES1
agenttopic_20161202 the STARTED 26653 P 0 3.4MB 10.0.2.69 DES1
agenttopic_20161202 the STARTED. 3 P 23 553 3MB 10.0.2.69 DES1
agenttopic_20161202 the STARTED. 1 25546 P 3.3MB DES1 10.0.2.69
agenttopic_20161202 the STARTED. 4 P 24698 3.1MB 10.0.2.69 DES1
mobilesdk_20161203. 4 0 P the STARTED 144b 10.0.2.69 DES1
mobilesdk_20161203 0 0 P the STARTED 144b 10.0.2.69 DES1
mobilesdk_20161203. 3 0 P the STARTED 144b 10.0.2.69 DES1
mobilesdk_20161203. 1 0 P the STARTED 10.0.2.69 DES1 144b
mobilesdk_20161203 the STARTED P 2 0 144b 10.0.2.69 DES1
`` `
index name, fragmentation, fragmentation status (p represents the master slice, R & lt replica representatives), the state of fragmentation, the number of documents, the storage space

### 5, the cluster open or close the index
1. ** command: **

`
# Open index
curl -XPOST '127.0.0.1:9200/agenttopic_20161202/_open'
# Close index
curl -XPOST '127.0.0.1:9200/agenttopic_20161202/_close'
`
execution results are as follows:

`` `
[Tsbweb1 the root @ ~] # curl -XPOST '127.0.0.1:9200/agenttopic_20161202/_open'
{" Acknowledged ": to true}
[tsbweb1 the root @ ~] # curl -XPOST '127.0.0.1:9200/agenttopic_20161202/ _close, '
{ "Acknowledged": true}
`` `
returns true if the index is successfully opened or closed, open or close the return error indicates failure index

### 6, delete the cluster index
1. ** command: **

`` `
Curl -XDELETE '127.0.0.1:9200/agenttopic_20161202'
` ``
execution results are as follows:

`` `
[Tsbweb1 the root @ ~] # curl -XDELETE '127.0.0.1:9200/agenttopic_20161202'
{" Acknowledged ": true}
` ``
Returns true if the index is successfully deleted, the index represents a return error deletion failed

### 7, manually create the index
1. ** command: **

`` `
Curl -XPUT" 127.0.0.1:9200/agenttopic_20161202 "-d '{" Settings ": {" number_of_shards ":. 5," number_of_replicas ": 0}}';
` ``
execution results are as follows:

`` `
[Tsbweb1 the root @ ~] # -XPUT curl" 127.0.0.1:9200/agenttopic_20161206 "-d '{" Settings ": {" number_of_shards ":. 5," number_of_replicas ": 0}}'
{" Acknowledged ": } true
`` `
returns true if the index is successfully created, the return of error that failed to create an index
**` "number \ _of \ _shards ": 5` ** indicates the number of fragments specified when creating the index, "5" indicates that the specified 5 fragmentation
** `" number \ _of \ _replicas ": 0` ** indicates the number of copies when creating an index," 0 "means no set up a replica

### 8, clustered index manually modify the number of copies
1. ** command: **

`` `
Curl -XPUT '127.0.0.1:9200/agenttopic_20161206/_settings' -d '{" number_of_replicas ": 0}'
` ``
** `Number \ _of \ _replicas:` ** specified number of copies need to modify the index

### 9, Elasticsearch manually assign index fragmentation
1. To fully manual, must first `cluster.routing.allocation.disable_allocation` parameter set to true, prohibit es automatic index fragmentation distribution, or you from a the slice moved to another node a node, a slice will move to another node of that node.
2. a total of three operations, namely: movement (move), cancellation (cancel) and distribution (the allocate) . The following describes three cases:
- ** movement (Move) **
the fragment moved from one node to another. You can specify the index name and fragmentation number.
- ** cancellation (Cancel) **
unassign a slice. You can specify the index name and fragmentation number. node parameters can be specified at that node to cancel slices are allocated. allow_primary parameter supports deallocation master slice. Cancel (cancel) is not commonly used not in this explanation.
- ** distribution (the allocate) **
Assign an unused slice allocated to the designated nodes. You can specify the index name and fragmentation number. node parameter specifies the node is assigned. allow_primary argument forces the primary slice allocated, but this could result in loss of data, this parameter is not recommended to add.

** movement (move) the specific command: **

`` `
Curl -XPOST '127.0.0.1:9200/_cluster/reroute' -d '{" Commands ": [{" Move ": {" index ":" javatopic_20161115 "," Shard ": 0," from_node ": "node1", "to_node": "node2"}]} '
`` `
** distribution (the allocate) the specific command: **

` ``
curl -XPOST' 127.0.0.1:9200/_cluster/reroute '-d' { "Commands": [{ "the allocate": { "index": "javatopic_20161115", "Shard": 2, "Node": "DES1", "allow_primary": to true}}]} '
`` `
> * ** `" index ":" javatopic_20161115 " ` ** specify allocated slice index name
> * ** `" shard ": 2` ** specified slice to be allocated," 2 "denotes a second manually assigned to the javatopic_20161115 a slice
>* ** `" node ":" des1 "` ** specify the target node allocation index fragmentation of
> * ** `" from_node ": " node1 "` ** index points where the current node piece
> * * `" to_node ":" node2 "` ** movement destination of the fragment


Detailed profiles ## Elasticsearch

#### elasticsearch the config folder there are two configuration files: elasticsearch.yml and logging.yml. The first is es basic configuration file, the second is the log configuration file, es also use log4j for logging, so logging.yml in settings as normal log4j configuration file to set the line. Here the main thing on the next elasticsearch.yml this file configurable.
* Cluster.name:elasticsearch
configuration es cluster name, the default is elasticsearch, es es automatically discovers in the same network segment, if there are multiple clusters in the same network segment, you can use this property to distinguish between different clusters.
* Node.name:"FranzKafka "
node name, the default name randomly assigned to a list name, the list config file folder name.txt es in the jar package, which add a lot of interesting names.
* Node.master: true
specify whether the node is eligible to be elected as the node, the default is true, es is the default cluster first machine for the master, if this machine will be linked to the re-election of master.
* Node.data:true
specify whether the node is stored in the index data, the default is true.
* Index.number_of_shards: 5
disposed slice default index number, the default is five.
* Index.number_of_replicas: 1
Set the default number of copies of the index, the default is one copy.
* Path.conf: / path / to / conf
Storage path setting configuration file, the default is the config file in the root directory folder es.
* Path.data:/path/to/data
Set index data storage path, data file in the default root folder es may be provided a plurality of storage paths, separated by commas, for example:
* path.data:/path / to / data1, / path / to / data2
path.work:/path/to/work
set the storage path of the temporary files, default work file in the root directory folder es.
* Path.logs: / path / to / logs
stored in the log file path is set, the default is the logs files in the root directory folder es
* path.plugins: / path / to / plugins
Set plugin storage path, the default is the root es plugins folder under
* bootstrap.mlockall: true
set to true to lock the memory. Because when jvm starts swapping es efficiency will be reduced, so to ensure that it does not swap, and can ES_MIN_MEM two ES_MAX_MEM environment variable to the same value, and to ensure that the machine has enough memory allocated es. But also allows a process elasticsearch can lock memory, under linux can `ulimit-lunlimited` command.
* Network.bind_host: 192.168.0.1
set binding ip address, can be ipv4 or ipv6 default is 0.0.0.0.
* Network.publish_host: 192.168.0.1
Node and the other nodes arranged to interact ip address, if it is not set automatically determined, the value must be a real ip address.
* Network.host:192.168.0.1
This parameter is used to set both parameters and publish_host bind_host above.
* Transport.tcp.port: 9300
provided between the nodes interact tcp port, the default is 9300.
* Transport.tcp.compress: true
data compression settings are tcp transmission, default is false, not compressed.
* Http.port: 9200
Set of Foreign Service http port, default 9200.
* Http.max_content_length: 100mb
set the content of the maximum capacity, the default 100MB
* http.enabled: false
whether to use the http protocol to provide services, the default is true, open.
Gateway.type *: local
Gateway type, the default is local is the local file system can be set to the local file system, distributed file system, hadoop of HDFS, and the amazon s3 server, set up the next method other file systems again detail.
* Gateway.recover_after_nodes: 1
data Restoring the start cluster nodes N, the default is one.
* Gateway.recover_after_time: 5m
set the timeout initialization data recovery process, the default is 5 minutes.
* Gateway.expected_nodes: 2
set the number of nodes in the cluster, the default is 2, N nodes once it starts, it will immediately perform data recovery.
* Cluster.routing.allocation.node_initial_primaries_recoveries: 4
initialization data recovery, restore the number of concurrent threads, the default is 4.
* Cluster.routing.allocation.node_concurrent_recoveries: 2
to add or delete nodes concurrent recovery of load balancing the number of threads, the default is 4.
* Indices.recovery.max_size_per_sec: 0
limitations restoring setting data bandwidth, such as the 100MB, the default is 0, that is unlimited.
* Indices.recovery.concurrent_streams: 5
set this parameter to limit the maximum number of concurrent streams simultaneously opened while the data from the other fragments, the default is 5.
* Discovery.zen.minimum_master_nodes: 1
Set this parameter to ensure that the cluster nodes can know the other N nodes have master qualifications. Defaults to 1 for large clusters, it can be a larger value of (2-4)
* discovery.zen.ping.timeout: 3S
of ping connection timeout time set automatically discover other nodes in the cluster, the default is 3 seconds, comparing the difference value to be the high point of a network environment to prevent errors in the Auto discovery.
* Discovery.zen.ping.multicast.enabled: false
Set whether to open multicast discovery node, the default is true.
* Discovery.zen.ping.unicast.hosts: [ "host1", "host2: port", "host3 [portX-portY]"]
setting the initial list of cluster master nodes may be automatically found these new nodes join the cluster node

Guess you like

Origin www.cnblogs.com/Liudarren/p/11284193.html