Elasitcstack
环境准本 Ubuntu22.04
10.0.0.71 elk71
10.0.0.72 elk72
10.0.0.73 elk73
1.什么是elasticsearch
Elasticsearch 是一个分布式、RESTful 风格的搜索和数据分析引擎,能够解决不断涌现出的各种用例。作为 Elastic Stack 的核心,Elasticsearch 会集中存储您的数据,让您飞快完成搜索,微调相关性,进行强大的分析,并轻松缩放规模。简单来讲,ES的核心作用就是存储数据和快速进行模糊查询。
2.单点安装部署ES
2.1 下载es软件包
[root@elk71 ~]# dpkg -i elasticsearch-7.17.22-amd64.deb
2.2 修改配置文件
[root@elk71 ~]# egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml
cluster.name: nolen-linux --cluster.name: 指定ES集群的名称
path.data: /var/lib/elasticsearch --path.data:指定数据目录
path.logs: /var/log/elasticsearch --path.logs: 指定日志目录
network.host: 0.0.0.0 --network.host: 指定宿主机的监听IP
http.port: 9200 -- http.port: 9200 对外提供http|https接口的端口
transport.port: 9300 --transport.port:集群内部数据传输的端口,会优先启动该端口选举master后在启动9200端口。
discovery.type: single-node --discovery.type:指定ES集群的类型,single-node表示的是单点。
2.3 启动es服务
启动服务
systemctl enable --now elasticsearch
检查监听端口
[root@elk71 ~]# ss -ntl | egrep "92|93"
LISTEN 0 4096 *:9200 *:*
LISTEN 0 4096 *:9300 *:*
2.4 测试访问es服务器
[root@elk73 ~]# curl 10.0.0.71:9200
{
"name" : "elk71",
"cluster_name" : "nolen-linux",
"cluster_uuid" : "rYh3jwB7SFu0MKTiwCfOwQ",
"version" : {
"number" : "7.17.22",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "38e9ca2e81304a821c50862dafab089ca863944b",
"build_date" : "2024-06-06T07:35:17.876121680Z",
"build_snapshot" : false,
"lucene_version" : "8.11.3",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
[root@elk73 ~]#
[root@elk73 ~]#
[root@elk73 ~]#
[root@elk73 ~]# curl 10.0.0.71:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
10.0.0.71 15 97 0 0.22 0.18 0.08 cdfhilmrstw * elk71
3.es集群部署
3.1 所有节点安装es软件包
dpkg -i elasticsearch-7.17.22-amd64.deb
3.2 修改配置文件
[root@elk71 ~]# egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml
cluster.name: nolen-linux
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
transport.port: 9300
discovery.seed_hosts: ["10.0.0.71", "10.0.0.72","10.0.0.73"] ---discovery.seed_hosts:当前ES集群的主机列表。
cluster.initial_master_nodes: ["10.0.0.71", "10.0.0.72","10.0.0.73"] ---cluster.initial_master_nodes:集群启动时首次参与master选举的节点列表
[root@elk71 ~]#
3.3 配置文件拷贝到其他节点
[root@elk71 ~]# scp /etc/elasticsearch/elasticsearch.yml 10.0.0.72:/etc/elasticsearch
[root@elk71 ~]# scp /etc/elasticsearch/elasticsearch.yml 10.0.0.73:/etc/elasticsearch
3.4 启动ES集群
[root@elk71 ~]# systemctl enable --now elasticsearch.service
[root@elk72 ~]# systemctl enable --now elasticsearch.service
[root@elk73 ~]# systemctl enable --now elasticsearch.service
3.5 检查端口是否监听
[root@elk71 ~]# ss -ntl | egrep "9200|9300"
LISTEN 0 4096 *:9200 *:*
LISTEN 0 4096 *:9300 *:*
[root@elk71 ~]#
[root@elk72 ~]# ss -ntl | egrep "9200|9300"
LISTEN 0 4096 *:9200 *:*
LISTEN 0 4096 *:9300 *:*
[root@elk72 ~]#
[root@elk73 ~]# ss -ntl | egrep "9200|9300"
LISTEN 0 4096 *:9200 *:*
LISTEN 0 4096 *:9300 *:*
[root@elk73 ~]#
3.6 查看集群节点信息
[root@elk73 ~]#
[root@elk73 ~]# curl 10.0.0.71:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
10.0.0.72 13 97 3 0.89 0.62 0.25 cdfhilmrstw - elk72
10.0.0.73 21 97 1 0.27 0.28 0.11 cdfhilmrstw * elk73
10.0.0.71 15 97 6 0.16 0.21 0.09 cdfhilmrstw - elk71
[root@elk73 ~]#
[root@elk73 ~]# for i in `seq 71 73`;do curl -s 10.0.0.$i:9200 | egrep '_name|_uuid';done
"cluster_name" : "nolen-linux",
"cluster_uuid" : "ORn4OMKKTWK22EGCMguvmw",
"cluster_name" : "nolen-linux",
"cluster_uuid" : "ORn4OMKKTWK22EGCMguvmw",
"cluster_name" : "nolen-linux",
"cluster_uuid" : "ORn4OMKKTWK22EGCMguvmw",
[root@elk73 ~]#

浙公网安备 33010602011771号