K8S 日志收集:ES 集群安装

Posted 不忘初心-铃

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了K8S 日志收集:ES 集群安装相关的知识,希望对你有一定的参考价值。

集群设备

ip role
192.168.19.93 master、data
192.168.19.94 data

安装java

elasticsearch 需要java环境

elasticsearch-6.x 要求java版本1.8.0_131 or later

rpm  -ivh http://192.168.19.111:8080/panjunbai/jdk-8u141-linux-x64.rpm

安装elasticsearch

可以使用yum源安装,也可以下载rpm包直接安装

cat /etc/yum.repos.d/elastic.repo 
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

yum install -y  elasticsearch
rpm -ivh http://192.168.19.111:8080/panjunbai/elasticsearch-6.2.4.rpm

配置elasticsearch通用配置

配置java运行内存大小,修改/etc/elasticsearch/jvm.options文件中-Xms -Xmx的值,为java虚拟机运行的内存最小和最大值,必须相同。其他使用默认值即可。

[[email protected] elasticsearch]# cat /etc/elasticsearch/jvm.options |grep "^-Xm"
-Xms6g
-Xmx6g

创建elasticsearch运行的日志路径和数据路径

[[email protected] elasticsearch]# mkdir /data/es-data
[[email protected] elasticsearch]# mkdir /data/es-log
[[email protected] elasticsearch]# chown -R elasticsearch.elasticsearch /data

192.168.19.93 elasticsearch 配置

[[email protected] elasticsearch]# cat elasticsearch.yml |grep -v "^#"
cluster.name: test-panjunbai
node.name: node-94
path.data: /data/es-data
path.logs: /data/es-log
network.host: 192.168.19.94
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.19.93", "192.168.19.94"]
discovery.zen.minimum_master_nodes: 1
node.master: true
node.data: true

192.168.19.94 elasticsearch 配置

[[email protected] elasticsearch]# cat elasticsearch.yml
cluster.name: test-panjunbai
node.name: node-93
path.data: /data/es-data
path.logs: /data/es-log
network.host: 192.168.19.93
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.19.93", "192.168.19.94"]
discovery.zen.minimum_master_nodes: 1
node.master: false
node.data: true

在192.168.19.93、192.168.19.94 启动elasticsearch

systemctl start elasticsearch

启动成功后访问结果

[[email protected] es-log]# curl 192.168.19.93:9200
{
  "name" : "node-93",
  "cluster_name" : "test-panjunbai",
  "cluster_uuid" : "joXSilqGTiyvah-VcIqlYQ",
  "version" : {
    "number" : "6.2.4",
    "build_hash" : "ccec39f",
    "build_date" : "2018-04-12T20:37:28.497551Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}


[[email protected] es-log]# curl 192.168.19.94:9200
{
  "name" : "node-94",
  "cluster_name" : "test-panjunbai",
  "cluster_uuid" : "joXSilqGTiyvah-VcIqlYQ",
  "version" : {
    "number" : "6.2.4",
    "build_hash" : "ccec39f",
    "build_date" : "2018-04-12T20:37:28.497551Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

以上是关于K8S 日志收集:ES 集群安装的主要内容,如果未能解决你的问题,请参考以下文章

k8s通过sidecar模式收集pod的容器日志至ELK

k8s集群日志收集

K8S日志收集:容器日志输出JSON,自动采集至ES

k8s日志收集解决方案

K8s容器日志实时收集FileBeat+ES+Kibana

k8s集群之日志收集EFK架构