ElasticStack笔记(二)Elasticsearch Cluster

总括

在这里插入图片描述

主机IPHOSTNAME
FileBeat13.13.11.5/16web01
LogStash 113.13.12.5/16logstash01
LogStash 213.13.12.6/16logstash02
Elasticsearch 113.13.13.5/16es01
Elasticsearch 213.13.13.6/16es02
Elasticsearch 313.13.13.7/16es03
Kibana13.13.14.5/16kibana

ES集群搭建

  • 配置/etc/hosts(all)
[root@es01 ~]# vi /etc/hosts
[root@es01 ~]# tail -3 /etc/hosts
13.13.13.5 es01
13.13.13.6 es02
13.13.13.7 es03
[root@es01 ~]# 
  • 防火墙(all)
[root@es01 ~]# firewall-cmd --permanent --add-service=elasticsearch
success
[root@es01 ~]# firewall-cmd --reload
success
[root@es01 ~]# 
  • 安装软件
[root@es01 ~]# ll el*
-rw-r--r--. 1 root root 317277408 Oct 13 13:37 elasticsearch-7.9.2-x86_64.rpm
-rw-r--r--. 1 root root       160 Oct 13 13:37 elasticsearch-7.9.2-x86_64.rpm.sha512
[root@es01 ~]# shasum -a 512 -c elasticsearch-7.9.2-x86_64.rpm.sha512
elasticsearch-7.9.2-x86_64.rpm: OK
[root@es01 ~]# rpm --install elasticsearch-7.9.2-x86_64.rpm
warning: elasticsearch-7.9.2-x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID d88e42b4: NOKEY
Creating elasticsearch group... OK
Creating elasticsearch user... OK
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
 sudo systemctl daemon-reload
 sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
 sudo systemctl start elasticsearch.service
Created elasticsearch keystore in /etc/elasticsearch/elasticsearch.keystore
[/usr/lib/tmpfiles.d/elasticsearch.conf:1] Line references path below legacy directory /var/run/, updating /var/run/elasticsearch → /run/elasticsearch; please update the tmpfiles.d/ drop-in file accordingly.
[root@es01 ~]# systemctl daemon-reload
[root@es01 ~]# 
  • 配置文件
[root@es01 ~]# cp /etc/elasticsearch/elasticsearch.yml{,.bak}
[root@es01 ~]# vi /etc/elasticsearch/elasticsearch.yml
[root@es01 ~]# cat /etc/elasticsearch/elasticsearch.yml
# Use a descriptive name for your cluster:
cluster.name: escluster

node.name: es01
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 13.13.13.5
http.port: 9200

# Pass an initial list of hosts to perform discovery when this node is started:
discovery.seed_hosts: ["13.13.13.5", "13.13.13.6", "13.13.13.7"]

# Bootstrap the cluster using an initial set of master-eligible nodes:
cluster.initial_master_nodes: ["es01", "es02", "es03"]
[root@es01 ~]# 
[root@es02 ~]# cat /etc/elasticsearch/elasticsearch.yml
....
node.name: es02
....
network.host: 13.13.13.6
....
[root@es02 ~]# 
[root@es03 ~]# cat /etc/elasticsearch/elasticsearch.yml
....
node.name: es03
....
network.host: 13.13.13.7
....
[root@es03 ~]# 
  • 启动与检验
[root@es01 ~]# systemctl enable elasticsearch.service 
Synchronizing state of elasticsearch.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable elasticsearch
Created symlink /etc/systemd/system/multi-user.target.wants/elasticsearch.service → /usr/lib/systemd/system/elasticsearch.service.
[root@es01 ~]# systemctl start elasticsearch.service 
[root@es01 ~]# ss -tunlp | grep 9200
tcp    LISTEN  0       128      [::ffff:13.13.13.5]:9200                *:*      users:(("java",pid=1772,fd=307))
[root@es01 ~]# curl -X GET  http://es01:9200/_cluster/health?pretty
{
  "cluster_name" : "escluster",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 3,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}
[root@es01 ~]# 

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值