centos-elasticsearch-logstash-kibana-filebeat

原创
08/25 20:51
阅读数 11

修改内核参数

# echo "vm.swappiness=0" >> /etc/sysctl.conf
# echo "vm.max_map_count=655350" >> /etc/sysctl.conf
# sysctl -p

修改资源参数

# vim /etc/security/limits.conf
* soft    nofile  655360
* hard    nofile  655360
* soft    nproc   unlimited
* hard    nproc   unlimited
* soft    core    unlimited
* hard    core    unlimited
* soft    memlock unlimited
* hard    memlock unlimited

修改用户参数

# vim /etc/security/limits.d/90-nproc.conf
*          soft    nproc     262144
root       soft    nproc     unlimited

elasticsearch

https://www.elastic.co/cn/downloads/elasticsearch

  • jdk
# yum -y list java*
# yum install -y java-1.8.0-openjdk-devel.x86_64
# vim /etc/profile
export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin
# source /etc/profile
# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
  • 下载安装
# wget https://mirrors.huaweicloud.com/elasticsearch/7.8.0/elasticsearch-7.8.0-x86_64.rpm
# rpm -ivh elasticsearch-7.8.0-x86_64.rpm
  • 设置自启
# systemctl enable elasticsearch.service
or
# chkconfig --add elasticsearch
  • 修改配置
# cd /etc/elasticsearch
# cp -a elasticsearch.yml elasticsearch.yml.bak
# cat elasticsearch.yml | grep -v ^#
# vim elasticsearch.yml
cluster.name: es-application
node.name: es-node-1
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 127.0.0.1
http.port: 9200
discovery.seed_hosts: ["127.0.0.1"]
cluster.initial_master_nodes: ["es-node-1"]
  • 添加用户
# groupadd elasticsearch
# useradd -g elasticsearch elasticsearch --no-create-home
# mkdir -p /data/elasticsearch/data
# mkdir -p /data/elasticsearch/logs
# chown -R elasticsearch:elasticsearch /data/elasticsearch
  • 启动服务
# service elasticsearch start
  • 查看日志
# tail -f  /data/elasticsearch/logs/es-application.log
  • 测试
# curl http://127.0.0.1:9200
  • nginx 反向代理
upstream es {
	server 127.0.0.1:9200;
}

server {
	listen 80;
	server_name _ localhost 127.0.0.1;

	location /es/ {
		proxy_pass http://es/;
		proxy_http_version 1.1;
		proxy_set_header Connection "";
		proxy_cache_valid 200 302 10m;
		proxy_cache_valid 404 1m;
		proxy_connect_timeout 5s;
		proxy_read_timeout 10s;
	}

	include error.conf;

	location ~ /\.ht {
		deny  all;
	}
}
  • 操作
添加索引
# curl -X PUT 'http://localhost/es/user'

查看索引
# curl 'http://localhost/es/_cat/indices'
# curl 'http://localhost/es/_cat/indices?v'

删除索引
# curl -X DELETE 'http://localhost/es/user'

添加文档
curl  -H "Content-Type: application/json" -X PUT 'http://localhost/es/user/1' -d '{"name":"hnatao"}'

查看文档
curl -X GET ‘http:/localhost/es/user/1?pretty’

Logstash

https://www.elastic.co/cn/downloads/logstash

  • 下载安装
# wget https://mirrors.huaweicloud.com/logstash/7.8.0/logstash-7.8.0.rpm
# rpm -ivh logstash-7.8.0.rpm
  • 设置自启
# systemctl start logstash.service
or
# chkconfig --add logstash
  • 创建目录
# mkdir -p /data/logstash/data
# mkdir -p /data/logstash/logs
  • 修改配置
# cd /etc/logstash
# cp -a logstash.yml logstash.yml.bak
# vim logstash.yml
path.data: /data/logstash/data
path.logs: /data/logstash/logs
http.enabled: true
http.host: 0.0.0.0
http.port: 9600

# vim jvm.options
-Xms128m
-Xmx256m
  • 启动服务(centos6.9)
# /usr/share/logstash/bin/system-install /etc/logstash/startup.options sysv
# service logstash start

Filebeat

https://www.elastic.co/cn/downloads/beats/filebeat

  • 下载安装
# wget https://mirrors.huaweicloud.com/filebeat/7.9.0/filebeat-7.9.0-x86_64.rpm
# rpm -ivh filebeat-7.9.0-x86_64.rpm
  • 设置自启
# systemctl enable filebeat
or
# chkconfig --add filebeat
  • 修改配置
# cd /etc/filebeat/
# cp -a filebeat.yml filebeat.yml.bak
# vim filebeat.yml
- type: log
    paths:
        - /var/log/*.log
#output.elasticsearch:
    #hosts: ["localhost:9200"]
output.logstash:
  hosts: ["localhost:9600"]
  • 启动服务
# service filebeat start
  • 数据模块
# filebeat modules list
# filebeat modules enable system nginx mysql

Kibana

https://www.elastic.co/cn/downloads/kibana

  • 下载安装
# wget https://mirrors.huaweicloud.com/kibana/7.8.0/kibana-7.8.0-x86_64.rpm
# rpm -ivh kibana-7.8.0-x86_64.rpm
  • 设置自启
# systemctl enable kibana
or
# chkconfig --add kibana
  • 修改配置
# cd /etc/kibana
# cp -a kibana.yml kibana.yml.bak
# vim kibana.yml
server.port: 5601
server.host: "127.0.0.1"
i18n.locale: "zh-CN"
  • 启动服务
# service kibana start
  • 访问
curl http://localhost:5601

http://old.vletou.com
http://old.vletou.com/elasticsearch
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部