Elastic Stack ----- ES

本文详细介绍了如何在三台虚拟机上部署Elasticsearch集群,包括时间同步、下载安装、单点部署及配置修改。通过设置网络主机、调整集群名称和节点名称,实现了Elasticsearch的集群环境。最后,展示了通过curl命令检查集群状态和节点信息,确保集群正常运行。
摘要由CSDN通过智能技术生成

目录

一, ElasticSearch

二 .下载elasticsearch

三 .单点部署elasticsearch


一, ElasticSearch

集群基础环境初始化

 准备三台虚拟机 IP地址为192.168.1.{105.106.107} ;hostname为master server1 server2

1.安装时间同步

[root@master ~]# yum -y install chrony


[root@master ~]# vim /etc/chrony.conf  ##修改配置文件

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server ntp.aliyun.com iburst

server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst

[root@master ~]# systemctl enable --now chronyd ##设置开机自启
[root@master ~]# systemctl restart  chronyd ##查看服务状态

二 .下载elasticsearch

官方版本: https://www.elastic.co/cn/downloads/past-releases#elasticsearchhttps://www.elastic.co/cn/downloads/past-releases#elasticsearch

[root@master ~]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.7-linux-x86_64.tar.gz
##下载linux tar包

[root@master ~]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.7-x86_64.rpm
##下载rpm包

三 .单点部署elasticsearch

安装elasticsearch 

[root@master ~]# yum -y install elasticsearch-7.17.7-x86_64.rpm 

[root@master ~]# systemctl restart  elasticsearch.service ##启动服务
[root@master ~]# systemctl status  elasticsearch.service
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: active (running) since 三 2022-11-16 21:12:33 CST; 25s ago

[root@master ~]# ss -ntl ##9200对外提供端口 9300 对内提供通信端口
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN      0      100    127.0.0.1:25                      *:*                  
LISTEN      0      128         *:22                      *:*                  
LISTEN      0      100     [::1]:25                   [::]:*                  
LISTEN      0      128    [::ffff:127.0.0.1]:9200                 [::]:*                  
LISTEN      0      128     [::1]:9200                 [::]:*                  
LISTEN      0      128    [::ffff:127.0.0.1]:9300                 [::]:*                  
LISTEN      0      128     [::1]:9300                 [::]:*    

修改配置文件


[root@master ~]#  vim /etc/elasticsearch/elasticsearch.yml 

# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: elasticseach-666 ##修改集群名称
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: master ##节点名称
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: 0.0.0.0 ##本机任意同网段都可以访问,默认是本机

# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
discovery.seed_hosts: ["master","server1", "server2"] ##可以写主机名或ip地址。集群其他地址

[root@master ~]# systemctl restart elasticsearch.service





4.集群部署

[root@server1 ~]# yum -y install elasticsearch-7.17.7-x86_64.rpm 
##节点安装elasticsearch

[root@master ~]# scp /etc/elasticsearch/elasticsearch.yml @server1:/etc/elasticsearch/elasticsearch.yml
elasticsearch.yml                            100% 3476     4.6MB/s   00:00    
[root@master ~]# scp /etc/elasticsearch/elasticsearch.yml @server2:/etc/elasticsearch/elasticsearch.yml
elasticsearch.yml                            100% 3476     3.7MB/s   00:00

##将文件同步过去

[root@server1 ~]# vim /etc/elasticsearch/elasticsearch.yml  ##修改节点名称

# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: server1

[root@master ~]# systemctl stop elasticsearch
[root@master ~]# rm -f /var/log/elasticsearch/*
[root@master ~]# rm -f /var/lib/elasticsearch/*
[root@master ~]# systemctl restart elasticsearch //全部重新启动




查看集群状态

# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
discovery.seed_hosts: ["master","server1", "server2"]
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["master","server1", "server2"]


[root@master elasticsearch]# curl 192.168.1.106:9200
{
  "name" : "server1",
  "cluster_name" : "elasticseach-666",
  "cluster_uuid" : "Jn2AyZx0S4y-7aOsX5bz3w",

[root@master elasticsearch]# curl 192.168.1.107:9200
{
  "name" : "server2",
  "cluster_name" : "elasticseach-666",
  "cluster_uuid" : "Jn2AyZx0S4y-7aOsX5bz3w",



##查看集群
[root@master elasticsearch]# curl 192.168.1.107:9200/_cat/nodes
192.168.1.106 50 97 1 0.00 0.04 0.06 cdfhilmrstw * server1
192.168.1.105 55 93 1 0.00 0.03 0.05 cdfhilmrstw - master
192.168.1.107 55 96 1 0.00 0.04 0.05 cdfhilmrstw - server2


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值