采用ELK搭建日志平台,Elasticsearch安装

1、下载elasticsearch

复制代码
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.7-linux-x86_64.tar.gz

2、解压到/usr/local/

复制代码
mkdir -p /usr/local/elasticsearch7.17
tar -zxf elasticsearch-7.17.7-linux-x86_64.tar.gz -C /usr/local/elasticsearch7.17/ --strip-components=1 #--strip-components选项表示从目录级别上去除指定的前缀,以实现更加控制解压的效果

3、修改配置文件

复制代码
cd /usr/local/elasticsearch7.17/config
vi elasticsearch.yml
cluster.name: production
#节点信息
node.name: 192.168.0.191
path.data: /data/elasticsearch7.17
path.logs: /data/elasticsearch7.17/logs
#网络配置
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["192.168.0.191"]
#自发现配置新节点向集群报到的主机名
cluster.initial_master_nodes: ["192.168.0.191"]
bootstrap.system_call_filter: false
#增加跨域配置
http.cors.enabled: true
http.cors.allow-origin: "*"
vi jvm.options
-Xms512m
-Xmx512m
-XX:HeapDumpPath=/data/elasticsearch7.17/
9-:-Xlog:gc*,gc+age=trace,safepoint:file=/data/elasticsearch7.17/logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m

4、创建日志目录

复制代码
mkdir -p /data/elasticsearch7.17/logs

5、创建用户并赋予权限

复制代码
useradd es
passwd es
chown -R es:es /usr/local/elasticsearch7.17/
chown -R es:es /data/elasticsearch7.17/
usermod -g root es

6、elasticsearch 启动的时候要求当前用户最大线程数至少为 4096 个线程,修改当前用户最大线程数

复制代码
ulimit -a
pending signals                 (-i) 3834                  -----此处为当前用户线程数
vi /etc/security/limits.conf
es soft nofile 65536
es hard nofile 65536
es -  nproc  65535
vi /etc/sysctl.conf
vm.max_map_count = 655360

7、启动elasticsearch

复制代码
su es
前台启动
cd /usr/local/elasticsearch7.17/bin
./elasticsearch
后台启动
cd /usr/local/elasticsearch7.17/bin
./elasticsearch -d

8、设置开机启动elasticsearch

复制代码
touch /etc/systemd/system/elasticsearch.service
vi /etc/systemd/system/elasticsearch.service
[Unit]
Description=Elasticsearch
After=network.target
[Service]
Type=simple
User=es
LimitMEMLOCK=infinity
LimitNOFILE=65535
WorkingDirectory=/usr/local/elasticsearch7.17
ExecStart=/usr/local/elasticsearch7.17/bin/elasticsearch
Restart=on-failure
[Install]
WantedBy=multi-user.target

加入开机启动
systemctl daemon-reload
systemctl enable elasticsearch

9、elasticsearch操作命令

复制代码
systemctl start elasticsearch.service	启动
systemctl status elasticsearch.service	查看状态
systemctl restart elasticsearch.service	重启
systemctl stop elasticsearch.service	停止

10、开启防火墙

复制代码
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports

centos7.9 elasticsearch(ES)环境安装结束

相关推荐
ljh5746491191 小时前
大数据geo是什么意思
大数据·人工智能
闲人编程1 小时前
环境配置管理与敏感信息保护
大数据·生命周期·环境配置·加密算法·codecapsule·敏感信息保护
珠海西格电力1 小时前
零碳园区应急能源基础架构规划:备用电源与清洁能源联动配置
大数据·运维·人工智能·物联网·能源
Elastic 中国社区官方博客1 小时前
开始使用 Elastic Agent Builder 和 Strands Agents SDK
大数据·人工智能·elasticsearch·搜索引擎·ai·全文检索
说私域1 小时前
不同类型企业构建私域流量的必要性及定制开发AI智能名片商城小程序的应用
大数据·人工智能·小程序
专业开发者1 小时前
蓝牙 ® 技术正逐步在未来的智慧城市中站稳脚跟。
大数据·人工智能·智慧城市
小技工丨1 小时前
【01】Apache Flink 2025年技术现状与发展趋势
大数据·flink·apache
梦里不知身是客111 小时前
flink的反压查看火焰图
大数据·flink
Jackyzhe2 小时前
Flink源码阅读:集群启动
大数据·flink
盛世宏博北京2 小时前
分布式库房集中管!云端 “八防” 监控平台,多站点统一可视化运维
大数据·网络·数据库·档案温湿度