elasticsearch集群布署

Posted ~~~~~~~~~~~~~~

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elasticsearch集群布署相关的知识,希望对你有一定的参考价值。

官网下载elasticsearch:

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.1-linux-x86_64.tar.gz

解压缩包后配置jdk环境:

cd elasticsearch-7.8.1

mv jdk /usr/local/

mkdir /data/elasticsearch/data,logs -p

添加java环境系统配置:

echo "export JAVA_HOME=/usr/local/jdk" >> /etc/profile

echo "export CLASSPATH=\\$JAVA_HOME/lib:\\$CLASSPATH" >> /etc/profile

echo "export PATH=\\$JAVA_HOME/bin:\\$PATH" >> /etc/profile

系统内核配置:

echo "vm.max_map_count = 655300" >>/etc/sysctl.conf

sysctl -p

cat>>/etc/security/limits.conf<<EOF

*       soft    nproc                   655350

*       hard    nproc                   655350

*       soft    nofile                  655350

*       hard    nofile                  655350

EOF

ulimit -n 655350

 

使环境配置生效:

source /etc/profile

chmod 755 -R /usr/local/jdk

useradd elastic

chown elastic:elastic /usr/local/elasticsearch -R

chown elastic:elastic /data/elasticsearch –R

各节点修改elasticsearch.yml配置文件如下:

节点1:

cluster.name: my-application

node.name: node-1

path.data: /data/elasticsearch/data

path.logs: /data/elasticsearch/logs

network.host: 192.168.199.140

http.port: 9200

discovery.seed_hosts: ["192.168.199.140", "192.168.199.141","192.168.199.142"]

cluster.initial_master_nodes: ["192.168.199.140", "192.168.199.141","192.168.199.142"]

节点2:

cluster.name: my-application

node.name: node-2

path.data: /data/elasticsearch/data

path.logs: /data/elasticsearch/logs

network.host: 192.168.199.141

http.port: 9200

discovery.seed_hosts: ["192.168.199.140", "192.168.199.141","192.168.199.142"]

cluster.initial_master_nodes: ["192.168.199.140", "192.168.199.141","192.168.199.142"]

节点3:

cluster.name: my-application

node.name: node-3

path.data: /data/elasticsearch/data

path.logs: /data/elasticsearch/logs

network.host: 192.168.199.142

http.port: 9200

discovery.seed_hosts: ["192.168.199.140", "192.168.199.141","192.168.199.142"]

cluster.initial_master_nodes: ["192.168.199.140", "192.168.199.141","192.168.199.142"]

切换至elastic用户启动elasticsearch集群:

su - elastic

/usr/local/elasticsearch/bin/elasticsearch -d

查看集群健康状况:

http://192.168.199.140:9200/_cat/health?v

 

查看集群节点详细信息:

http://192.168.199.140:9200/_cat/nodes?v

 

 

每个命令都支持使用?v参数,来显示详细的信息。

help

每个命令都支持使用help参数,来输出可以显示的列:

$ curl localhost:9200/_cat/master?help

 

headers

通过h参数,可以指定输出的字段:

$ curl localhost:9200/_cat/master?v
$ curl localhost:9200/_cat/master?h=ip,node

 

 

查看_cat下可用命令:

http://192.168.199.140:9200/_cat,返回如下:

=^.^=

/_cat/allocation

/_cat/shards

/_cat/shards/index

/_cat/master

/_cat/nodes

/_cat/tasks

/_cat/indices

/_cat/indices/index

/_cat/segments

/_cat/segments/index

/_cat/count

/_cat/count/index

/_cat/recovery

/_cat/recovery/index

/_cat/health

/_cat/pending_tasks

/_cat/aliases

/_cat/aliases/alias

/_cat/thread_pool

/_cat/thread_pool/thread_pools

/_cat/plugins

/_cat/fielddata

/_cat/fielddata/fields

/_cat/nodeattrs

/_cat/repositories

/_cat/snapshots/repository

/_cat/templates

/_cat/ml/anomaly_detectors

/_cat/ml/anomaly_detectors/job_id

/_cat/ml/trained_models

/_cat/ml/trained_models/model_id

/_cat/ml/datafeeds

/_cat/ml/datafeeds/datafeed_id

/_cat/ml/data_frame/analytics

/_cat/ml/data_frame/analytics/id

/_cat/transforms

/_cat/transforms/transform_id

 

更多请参考官方文档:

https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html

以上是关于elasticsearch集群布署的主要内容,如果未能解决你的问题,请参考以下文章

k8s集群监控布署

kafka_2.12集群布署

Docker集群实验环境布署--swarm3 注册服务监控与自动发现组件--consul

Redis v6.0.6 集群cluster模式布署

MySQL MGR高可用集群布署

MySQL MGR高可用集群布署