Elasticsearch集群的运维与管理

news/2024/9/21 3:35:35/

【1】安装启动ES 集群

(1.1)集群架构规划

OS  ES versionIpnode.nameRolecluster.namees basedir
CentOS Linux release 7.8.2003 (Core)elasticsearch-7.14.1

192.168.175.132:9200

cluster:192.168.175.132:9301

node_1

node.master=true

node.data=true

es_cluster1/data/es/es_9200
CentOS Linux release 7.8.2003 (Core)elasticsearch-7.14.1

192.168.175.129:9200

cluster:192.168.175.132:9301

node_2

node.data=true

node.master=true

es_cluster1/data/es/es_9200
CentOS Linux release 7.8.2003 (Core)elasticsearch-7.14.1

192.168.175.129:9200

cluster:192.168.175.132:9301

node_3

node.data=true

node.master=true

es_cluster1/data/es/es_9200

es从5.x开始,默认不支持root账户启动的

可以以非root账户启动,或者是在启动时候加上参数: -Des.insecure.allow.root=true

1.2)前置目录、账户、信息等准备工作

 1 elasticsearch安装-CSDN博客

 1.1 elasticsearch分布式集群基本搭建(centos7.x + elaticsearch7.11.1)-CSDN博客

jdk如果不配置,没有 JAVA_HOME,则自动使用 es 包中自带的 JDK,这里我就没有安装jdk

mkdir -p /data/software
cd /data/software
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-linux-x86_64.tar.gz
groupadd elk
useradd elk -g elk
tar -zxf elasticsearch-7.14.1-linux-x86_64.tar.gzmkdir -p /data/es/
mv elasticsearch-7.14.1 /data/es/es_9200
echo 'vm.max_map_count=2655350'>> /etc/sysctl.conf
echo 'vm.swappiness=1'>>/etc/sysctl.conf
cat <<eof>> /etc/security/limits.conf
elk soft nproc 65535
elk hard nproc 65535
elk soft nofile 65535
elk hard nofile 65535
elk soft stack 65535
elk hard stack 65535
elk hard memlock unlimited  #锁定内存页
elk soft memlock unlimited  #需要退出重登会话生效
eofsysctl -p# /data/es/es_9200/data # 默认数据目录,同目录的 logs 放日志mkdir -p /data/es/es_9200/{es_data,es_logs}chown -R elk:elk /data/es#参考启动命令 su -l elk -c "/data/es/es_9200/bin/elasticsearch -d -p /tmp/es_9200.pid"

(1.3)配置文件 elasticsearch.yml

cp -r /data/es/es_9200/config/elasticsearch.yml /data/es/es_9200/config/elasticsearch.yml.bak
cat <<eof > /data/es/es_9200/config/elasticsearch.yml
#-----cluster-----
cluster.name: es_cluster1 #集群名称
  #gateway.recover_after_nodes: 3 #至少恢复3个节点及以上,集群节点才可以被访问

#-----node-----
node.name: node_1  #节点名称,其他两个节点分别改成 node_2 node_3
node.master: true  #该是否可被选举为主节点
node.data: true    #该节点是否可成为数据节点
node.max_local_storage_nodes: 5  #集群最大逻辑存储节点数
transport.port: 9301 #集群内部通信端口

#-----data and log------
path.data: es_data  #生产环境建议把这2个和解压文件夹分离,避免升级丢失数据
path.logs: es_logs

#-----memory-----
bootstrap.memory_lock: true  #启动锁定内存页,这样就可以避免内存压力从而导致es的内存页被释放掉或被存到交换内存

#-----network-----
network.host: 0.0.0.0  # 网关地址,0.0.0.0为不限制
http.port: 9200

discovery.seed_hosts: ["192.168.175.132:9301", "192.168.175.147:9301", "192.168.175.148:9301"]
cluster.initial_master_nodes: ["node_1", "node_2", "node_3"]

#-----http requests-----
bootstrap.system_call_filter: false
http.cors.allow-origin: "*"
http.cors.enabled: true
http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
http.cors.allow-credentials: true

#-----es operation-----
  #action.destructive_requires_name: true  #删除索引时是否必须要实际索引名,避免批量删除eof

(1.4)启动es、查阅(9200)

3个机器配置文件都弄好之后,启动es

echo 'su -l elk -c "/data/es/es_9200/bin/elasticsearch -d -p /tmp/es_9200.pid"'>>/etc/rc.localsu -l elk -c "/data/es/es_9200/bin/elasticsearch -d -p /tmp/es_9200.pid"#kill -F /tmp/es_9200.pid
#查阅curl localhost:9200curl localhost:9200/_cat/health?v

(1.5)整合UI监控,es-head(9100)

参考:ElasticSearch7整合es-head,ES配置密码-CSDN博客

(1)下载前置依赖:https://nodejs.org/en/download/

cd /data/software
wget https://nodejs.org/dist/v14.17.6/node-v14.17.6-linux-x64.tar.xz
tar -Jxf  node-v14.17.6-linux-x64.tar.xz
echo "export PATH=${PATH}:`pwd`/bin">> /etc/profile
source /etc/profile

(2)下载es-head插件:https://github.com/mobz/elasticsearch-head

# git clone https://github.com/mobz/elasticsearch-head.gitcd /data/software
wget https://github.com/mobz/elasticsearch-head/archive/master.zip
unzip master.zip
cd elasticsearch-head-master #如果报错,则运行下面那个,如果下面那个也报错,则检查Yum源
npm installnpm install phantomjs-prebuilt@2.1.16 --ignore-scripts# run softwarenohup npm run start &echo "nohup npm run start &">>/etc/rc.local

1.5)整合UI,cerebro(参考就行,不怎么会用,9000)

cerebro官网:​​​​​​GitHub - lmenezes/cerebro

装一个就可以了,我装在了 192.168.175.132 机器上 也就是 node_1

cd /data/software

wget https://github.com/lmenezes/cerebro/releases/download/v0.9.4/cerebro-0.9.4.tgz

tar -zxf cerebro-0.9.4.tgz
cd /data/software/cerebro-0.9.4/bin && nohup ./cerebro &echo 'cd /data/software/cerebro-0.9.4/bin && nohup ./cerebro &' >>/etc/rc.local

访问:http://192.168.175.132:9000

输入任意集群节点信息

 效果:

(1.6)整合kibana(5601)

1》依然装在 192.16.175.132 上面吧

cd /data/software
wget https://artifacts.elastic.co/downloads/kibana/kibana-7.14.1-linux-x86_64.tar.gz
tar -zxf kibana-7.14.1-linux-x86_64.tar.gz

2》修改配置文件

vim /data/software/kibana-7.14.1-linux-x86_64/config/kibana.yml

server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://192.168.175.132:9200", "http://192.168.175.147:9200"

其他的默认值就好了

3》启动:

su -l elk -c"nohup /data/software/kibana-7.14.1-linux-x86_64/bin/kibana >/data/software/kibana-7.14.1-linux-x86_64/kibana.log &"echo 'su -l elk -c"nohup /data/software/kibana-7.14.1-linux-x86_64/bin/kibana >/data/software/kibana-7.14.1-linux-x86_64/kibana.log &"' >>/etc/rc.local

4》连接使用

http://192.168.175.132:5601/


http://www.ppmy.cn/news/1528212.html

相关文章

海外问卷调查:选择静态IP还是动态IP?

在全球化的市场研究中&#xff0c;海外问卷调查是一种重要的数据收集手段。然而&#xff0c;选择合适的IP类型对于确保调查的效率、质量和合法性至关重要。本文将探讨在进行海外问卷调查时&#xff0c;静态IP与动态IP的优劣&#xff0c;并提供决策指导。 一、IP类型基础 在深入…

单片机实现内存管理的C语言实现

在嵌入式系统&#xff08;如单片机&#xff09;中&#xff0c;内存资源非常有限&#xff0c;因此需要高效的内存管理机制。在这种情况下&#xff0c;可能无法使用标准的动态内存管理函数&#xff08;如 malloc 和 free&#xff09;。因此&#xff0c;通常需要设计一个自定义的内…

【java面试每日五题之基础篇一】(仅个人理解)

1. 怎么理解面向对象编程&#xff08;Object Oriented Programming&#xff0c;OOP&#xff09; 面向对象编程是一种编程范式&#xff0c;核心思想是将真实世界中的事物都抽象为对象&#xff0c;通过与代码中的对象进行交互从而实现各种需求&#xff0c;对于OOP中关键概念的理解…

基于python flask的高血压疾病预测分析与可视化系统的设计与实现,使用随机森林、决策树、逻辑回归、xgboost等机器学习库预测

研究背景 随着现代社会的快速发展&#xff0c;生活方式的改变和人口老龄化的加剧&#xff0c;心血管疾病&#xff0c;尤其是高血压&#xff0c;已成为全球范围内的重大公共健康问题。高血压是一种常见的慢性疾病&#xff0c;其主要特征是动脉血压持续升高。长期不控制的高血压…

【云原生监控】Prometheus监控系统

Prometheus监控系统 文章目录 Prometheus监控系统资源列表基础环境一、部署Prometheus服务1.1、解压1.2、配置systemctl启动1.3、监听端口1.4、访问Prometheus仪表盘 二、部署Node-Exporter2.1、解压2.2、配置systemctl启动2.3、监听端口2.4、访问node-exporter仪表盘 三、配置…

Python | python中的特殊方法__str__和__repr__

__str__和__repr__ 无方法有方法__str____repr__同时存在 __str__和__repr__都是更改print的输出形式 无方法 无特殊方法 class Person:def __init__(self,name,age):self.name nameself.age ageprint(Person(aa, 34))<main.Person object at 0x000002231EF78B38> …

计算机毕业设计 大学志愿填报系统的设计与实现 Java实战项目 附源码+文档+视频讲解

博主介绍&#xff1a;✌从事软件开发10年之余&#xff0c;专注于Java技术领域、Python人工智能及数据挖掘、小程序项目开发和Android项目开发等。CSDN、掘金、华为云、InfoQ、阿里云等平台优质作者✌ &#x1f345;文末获取源码联系&#x1f345; &#x1f447;&#x1f3fb; 精…

Linux 防火墙:Firewalld 常用命令行操作命令

firewalld命令行操作管理 按增删改查分类&#xff0c;前面加上 firewall-cmd &#xff1a; ### 查询操作--get-default-zone 查看当前默认区域 --get-zones 查看所有可用的区域 --get-active-zones …