elk搭建Elasticsearch和kibana和logstash

参考谢谢:https://www.cnblogs.com/zjfjava/p/12099897.html

 https://blog.csdn.net/BigCabbageFy/article/details/100555092

Elasticsearch配置7.9.0版本

Elasticsearch: http://192.168.1.174:9200/

kibana:http://192.168.1.174:5601/app/home

如果  netstat -alnp | grep 9200 提示netstat: 未找到命令执行  yum -y install net-tools

记得关闭防火墙

下面是red hat/CentOs7关闭防火墙的命令!

1:查看防火状态

systemctl status firewalld

service  iptables status

2:暂时关闭防火墙

systemctl stop firewalld

service  iptables stop

3:永久关闭防火墙

systemctl disable firewalld

chkconfig iptables off

4:重启防火墙

systemctl enable firewalld

service iptables restart  

5:永久关闭后重启

Elasticsearch安装步骤

1.把 elsearch 上传到服务器
2.添加  useradd elsearch
	
chown -R elsearch:elsearch /opt
3.修改文件限制
#vi /etc/security/limits.conf
#修改内容
* hard nofile 65536
* soft nproc 65536
* hard nproc 65536
* soft memlock unlimited
* hard memlock unlimited
4.调整进程数
#vi /etc/security/limits.d/20-nproc.conf

#调整内容
* soft nproc 4096
root soft nproc unlimited

5.调整虚拟内存&最大并发连接
#vi /etc/sysctl.conf
#修改内容
vm.max_map_count=655360
fs.file-max=655360

然后  sysctl -p #配置生效 

6.切换用户su elsearch
 cd elasticsearch-7.9.0/config/
 vi elasticsearch.yml 
新增如下配置:
cluster.name: zang #设置集群的名字,要小写
node.name: node-1 #设置节点的名字
network.host: 0.0.0.0 #设置ip地址,使外界可以访问es
http.port: 9200 #设置对外服务的端口,默认是9200
#设置在集群中的所有节点名称,这个节点名称就是之前所修改的,当然你也可以采用默认的也行,目前是单机,放入一个节点即可
cluster.initial_master_nodes: ["node-1"]
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#解决跨域问题
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"

#说明:在Elasticsearch中如果,network.host不是localhost或者127.0.0.1的话,就会认为是生产环境, 会对环境的要求比较高,我们的测试环境不一定能够满足,一般情况下需要修改2处配置,如下: #1:修改jvm启动参数
vim conf/jvm.options
-Xms512m 
-Xmx1024m

启动 
cd elasticsearch-7.3.0/bin

sh elasticsearch &
或者
./elasticsearch 或 ./elasticsearch -d #后台启动

如果启动后,关闭可能会占用9200端口,要关闭
 netstat -alnp | grep 9200

http://192.168.1.174:9200/

启动大约要20多秒,别急,出现这个忽略,只要你的jdk是8以上的就行

启动成功后测试

 curl "http://192.168.200.128:9200/"
{
  "name" : "node-1",
  "cluster_name" : "lurunzhen1",
  "cluster_uuid" : "GtNA82-UTSOUCp1DD8GSaQ",
  "version" : {
    "number" : "7.9.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "a479a2a7fce0389512d6a9361301708b92dff667",
    "build_date" : "2020-08-11T21:36:48.204330Z",
    "build_snapshot" : false,
    "lucene_version" : "8.6.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

kibana和logstash 配置

1.把 kibana ,logstash上传到服务器
2.添加  useradd elsearch  之前安装了elsearch就不要了
----------------------------------------------------------kibana--------------	
chown -R elsearch:elsearch ./kibana-7.9.0-linux-x86_64
chown -R elsearch:elsearch ./logstash-7.9.0

3.修改配置 
cd kibana-7.9.0-linux-x86_64/config/
vi kibana.yml 

server.host: 0.0.0.0
elasticsearch.hosts: ["http://192.168.1.174:9200"]
i18n.locale: "zh-CN"

vi跳到最后一行shift +G
或者gg到第一行

4.启动
cd kibana-7.9.0-linux-x86_64/bin/

sh kibana &
或者 ./kibana     

关闭  netstat -alnp | grep 5601

http://192.168.1.174:5601/app/home  

--------------------------logstash-------------------------------------
1 修改配置
cd logstash-7.9.0/config/
vi logstash.yml 
新增如下配置
path.data: /home/softpackage/logstash-7.9.0/data
path.logs: /home/softpackage/logstash-7.9.0/logs
这个 logs要创建文件夹

然后,新建配置文件logstash.conf,并配置
cd logstash-7.9.0/config/
vi logstash.conf 

input {
    file {
         path => "/home/soft/logstash-7.9.0/logs/*.log"
        start_position => beginning
    }
}
filter {

}
output {
    elasticsearch {
    hosts => "localhost:9200"
    }

或者
input { stdin {} } 
 output { elasticsearch { hosts => ["localhost:9200"] index => "logstash-test-%{+YYYY.MM.dd}" } }


重新加权限:chown -R elsearch:elsearch ./logstash-7.9.0

2 启动
cd /home/softpackage/logstash-7.9.0/bin
sh logstash -f  /home/softpackage/logstash-7.9.0/config/logstash.conf &
或者  nohup ./logstash -f /home/soft/logstash-7.9.0/config/logstash.conf  "">>yunxing.log &

记得有jdk哦
最后到这里去看日志是否启动:/home/softpackage/elk/mylog/*.log


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值