赞
踩
目录
IP | 服务 |
172.30.18.10 | elasticsearch、logstash、kibana |
172.30.18.12 | filebeat(作为客户端收集日志,发送给172.30.18.10) |
172.30.18.13 | filebeat(作为客户端收集日志,发送给172.30.18.10) |
- 查看用户列表:
- # cat /etc/passwd
-
- 查看用户组列表:
- # cat /etc/group
-
- # 创建 filebeat用户和组
- groupadd elasticsearch
- useradd elasticsearch-m -s /sbin/nologin -d /home/elasticsearch -g elasticsearch
-
-
- # useradd 参数
- -s /sbin/nologin 设置不能登陆
- -d 设置用户主目录,如果此目录不存在,则同时使用-m选项,可以创建主目录。
- -g 用户组
- -m 创建用户目录
- #切换目录
- cd /home/elasticsearch
-
- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.1-x86_64.rpm
-
- yum -y localinstall elasticsearch-7.12.1-x86_64.rpm
-
- rpm -qc elasticsearch
-
- whereis elasticsearch
es安装路径是/usr/share/elasticsearch,日志路径是/var/log/elasticsearch
查看日志:tail -f /var/log/elasticsearch/elasticsearch.log
- # 设置服务开机启动
- systemctl enable elasticsearch.service
-
- # 启动服务
- systemctl start elasticsearch.service
-
- #查询服务状态
- systemctl status elasticsearch.service
-
- #重启服务
- systemctl restart elasticsearch.service
-
- 查看服务日志
- journalctl -u elasticsearch.service
-
- 查看服务端口
- netstat -nltp | grep 9200
vi /etc/elasticsearch/elasticsearch.yml
- # 绑定本机IP地址
- network.host: 0.0.0.0
- # 绑定HTTP端口
- http.port: 9200
- # 指定集群master节点
- discovery.seed_hosts: ["0.0.0.0","127.0.0.1", "[::1]"]
重启:systemctl restart elasticsearch.service
查询ES状态
curl -X GET localhost:9200/_cluster/health
创建索引
curl -X PUT "localhost:9200/machine_cap_1003?pretty"
查询索引列表
curl -X GET localhost:9200/_cat/indices
删除索引
curl -X DELETE "localhost:9200/machine_cap_1003"
- # vim delete_es_by_day.sh
- # chmod +x delete_es_by_day.sh
-
- ---------------------------------------------
- #!/bin/bash
- #定时删除elasticsearch索引
- date=`date -d "-7 days" "+%Y.%m.%d"`
- /usr/bin/curl -v --user elasticsearch:password -XDELETE "http://localhost:9200/*-$date"
-
-
- ---------------------------------------------
- #!/bin/bash
- # 两个月之前
- date=`date -d "-2 months" "+%Y.%m"`
- /usr/bin/curl -v --user elastic:elastic用户密码 -XDELETE "http://es机器IP:9200/*-$date"
-
-
- ---------------------------------------------
- #定时任务
- crontab -e
- 00 01 * * * /home/elasticsearch/script/delete_es_by_day.sh
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。