Netflow/Sflow Visualization #1 Elasticsearch

Netflow/Sflow Visualization 가이드 1편 – Elasticsearch 설치

이 가이드는 IT 인프라 정보공유 오픈채팅 방의 @후추 님이 주신 정보를 바탕으로 문의 후 작성 하였습니다.

일을 하다 보면 특정 포트에 흐르는 트래픽에 대하여 파악이 필요할 때가 있습니다. 가령 어떤 IP 에 트래픽이 많이 발생하는지, 혹은 어떤 프로토콜이 많이 발생하는지 등을 확인 및 조치를 해야 하는 경우가 발생하게 됩니다.

트래픽 양이 적다면 port 에 mirror 를 걸고 wireshark 등으로 보면 됩니다. 하지만 만약 초당 Gbps 단위로 트래픽이 발생된다면 이러한 방법으로 분석하기에는 많은 어려움이 발생합니다.

이 때 사용할 수 있는 방법 중 하나로 Netflow(CISCO) 혹은 Sflow(표준) 를 사용할 수 있습니다. Netflow/Sflow 는 flow 정보를 특정 시간 동안 sampling 하여 정보를 보내줍니다.

이러한 정보를 사람이 보기 쉽게 몇 가지의 오픈소스들을 활용하여 시각화 하였습니다.

사용된 오픈 소스

opennms장비에서 보내오는 netflow/sflow 정보를 Elasticsearch에 저장
grafana 의 요청에 따라 netflow/sflow 의 정보를 전달
Elasticsearchopennms 에서 받은 netflow/sflow 의 정보를 저장하는 오픈 소스
Elasticsearch Plugin ( drift )function proportional_sum 을 사용 할 수 있게 해주는 plugin
Grafanaopennms 에서 받아온 netflow/sflow 의 정보를 시각화 하는 오픈 소스

Elasticsearch(이하 ES) 7.1.1 버전으로 설치를 진행하려 하였으나 아직 opennms 에서 ES 7 버전에 대하여 지원이 제대로 되지 않아 ES 6.8.1 버전으로 설치했습니다. 추후 ES 7 버전에 대하여 지원이 된다면 변경 부분에 대해서만 내용을 추가하도록 하겠습니다.

동작 방식

Netflow/sflow visualization

설치 환경

CentOS 7.6.1810 minimal
Elasticsearch 6.8.1 x 3 (Cluster 구조)
Opennms x 1
Grafana x 1

설치

의존성 패키지 설치

java 는 elasticsearch 설치에 필요하며 1.8.0 버전 이상을 설치해야 합니다. maven 은 ES plugin 인 drift 의 컴파일에 필요합니다.

[root@localhost]# yum -y install java maven unzip

ES 설치

ES 는 아파치 루씬(Apache Lucene) 기반의 오픈소스 분산 검색 엔진입니다. 총 3대의 장비로 클러스터를 구성하며 Master 노드 1, Data 노드 2대로 구성하겠습니다. ES 는 Plugin 의존성 때문에 특정 버전을 선택해서 설치해야 합니다.

1. ES 다운로드 및 설치

[root@localhost]# mkdir -p /usr/local/Server/elasticsearch-6.8.1
[root@localhost]# cd /usr/local/Server/elasticsearch-6.8.1
[root@localhost]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.1.rpm
[root@localhost]# yum install elasticsearch-6.8.1.rpm

ES 를 실행하기 전에 설정 변경이 필요합니다. (2 ~ 4)
참조 문서 : Important System Configuration | Elasticsearch Reference [7.11] | Elastic

2. limit.conf 수정

메모리 락, 프로세스 스레드, 파일 디스크립터의 제한을 변경합니다.

[root@localhost]# cat << EOF >> /etc/security/limits.conf
elasticsearch - nofile 65535
elasticsearch - nproc 4096
elasticsearch - memlock unlimited
EOF

3. sysctl.conf 수정

하나의 프로세스가 사용할 수 있는 메모리 맵 영역의 최대 수를 증가 시켜 줍니다.

[root@localhost]# cat << EOF >> /etc/sysctl.conf
vm.max_map_count = 262144
EOF

4. systemd 파일 수정

LimitMEMLOCK=infinity 값이 없으면 추가를 해주고 주석 처리가 되어 있다면 주석을 제거해 주시면 됩니다.
: vi /usr/lib/systemd/system/elasticsearch.service

LimitMEMLOCK=infinity

5. 각 노드의 hostname  변경

Master 노드

[root@localhost]# hostnamectl set-hostname es-master-node
[root@localhost]# cat << EOF >> /etc/hosts
> 10.0.0.101 es-master-node
> 10.0.0.102 es-data-node1
> 10.0.0.103 es-data-node2
> EOF

Data 노드 1

[root@localhost]# hostnamectl set-hostname es-data-node1
[root@localhost]# cat << EOF >> /etc/hosts
> 10.0.0.101 es-master-node
> 10.0.0.102 es-data-node1
> 10.0.0.103 es-data-node2
> EOF

Data 노드 2

[root@localhost]# hostnamectl set-hostname es-data-node2
[root@localhost]# cat << EOF >> /etc/hosts
> 10.0.0.101 es-master-node
> 10.0.0.102 es-data-node1
> 10.0.0.103 es-data-node2
> EOF

6. ES Cluster 설정

공통 설정
: vi /etc/elasticsearch/elasticsearch.yml

cluster.name: umount-es-cluster
node.name: ${HOSTNAME}

network.host: 0.0.0.0
transport.tcp.port: 9300
transport.tcp.compress: true

http.port: 9200
http.cors.enabled: true
discovery.zen.minimum_master_nodes: 1
discovery.zen.ping_timeout: 10s
discovery.zen.ping.unicast.hosts: ["es-master-node:9300", "es-data-node1:9300", "es-data-node2:9300"]

Master 노드

node.master: true
node.data: false

Data 노드

node.master: false
node.data: true

7. ES 시작

[root@localhost]# systemctl enable elasticsearch
[root@localhost]# systemctl start elasticsearch

8. 확인
shell #> curl localhost:9200

{
  "name" : "es-master-node",
  "cluster_name" : "umount-es-cluster",
  "cluster_uuid" : "z-T6PEFLR-uwpF7F1ZB-ag",
  "version" : {
    "number" : "6.8.1",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "1fad4e1",
    "build_date" : "2019-06-18T13:16:52.517138Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

shell #> curl localhost:9200/_cluster/health?pretty=true

{
  "cluster_name" : "umount-es-cluster",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}

ES Plugin Drift 설치

Drift 설치

ES version 을 맞추기 위해 6.8.0 으로 되어 있는 값을 전부 6.8.1 로 변경합니다.

[root@localhost]# mkdir -p /usr/local/Server/elasticsearch-plugin-drift-6.8.1
[root@localhost]# cd /usr/local/Server/elasticsearch-plugin-drift-6.8.1
[root@localhost]# wget https://github.com/OpenNMS/elasticsearch-drift-plugin/archive/es-6.8.x.zip
[root@localhost]# unzip es-6.8.x.zip
[root@localhost]# cd elasticsearch-drift-plugin-es-6.8.x

: vi pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.opennms.elasticsearch</groupId>
    <artifactId>elasticsearch-drift-plugin</artifactId>
    <version>6.8.1-SNAPSHOT</version>

    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>9</version>
    </parent>

    <properties>
        <elasticsearch.version>6.8.1</elasticsearch.version>
[root@localhost]# mvn clean package
[root@localhost]# /usr/share/elasticsearch/bin/elasticsearch-plugin install file:///usr/local/Server/elasticsearch-plugin-drift-6.8.1/elasticsearch-drift-plugin-es-6.8.x/target/releases/elasticsearch-drift-plugin-6.8.1-SNAPSHOT.zip
[root@localhost]# systemctl restart elasticsearch

설치 확인

[root@localhost]# /usr/share/elasticsearch/bin/elasticsearch-plugin list
opennms-drift

shell #> curl ‘localhost:9200/_cat/plugins?v&s=component&h=name,component,version,description’

name           component     version        description
es-data-node2  opennms-drift 6.8.1-SNAPSHOT The Drift plugin exposes additional aggregations for analysis of Netflow data.
es-data-node1  opennms-drift 6.8.1-SNAPSHOT The Drift plugin exposes additional aggregations for analysis of Netflow data.
es-master-node opennms-drift 6.8.1-SNAPSHOT The Drift plugin exposes additional aggregations for analysis of Netflow data.

sflow/netflow 정보를 저장하는 ES 및 ES plugin 설치가 완료 되었습니다. 다음은 Opennms 설치를 해 보도록 하겠습니다.

You may also like...

Subscribe
Notify of
guest

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x