Netflow/Sflow Visualization 가이드 2편 – Opennms 설치
Netflow/Sflow Visualization #1 Elasticsearch | Umount Blog 에서 Netflow/Sflow 의 시각화를 위한 첫 단계로 Elasticsearch 설치를 진행 하였습니다. 이번에는 Opennms 설치를 진행해 보도록 하겠습니다.
Opennms 는 오픈소스로 구현된 NMS(Network Management System) 입니다. Backend DB 로는 Postgresql(이하 PG)를 사용하며 Grafana 와 연동이 가능합니다.
Opennms 설치
Opennms repo 설치
[root@localhost]# yum -y install https://yum.opennms.org/repofiles/opennms-repo-stable-rhel7.noarch.rpm
[root@localhost]# rpm --import https://yum.opennms.org/OPENNMS-GPG-KEY
[root@localhost]# yum -y install https://yum.opennms.org/repofiles/opennms-repo-stable-rhel7.noarch.rpm
[root@localhost]# rpm --import https://yum.opennms.org/OPENNMS-GPG-KEY
[root@localhost]# yum -y install https://yum.opennms.org/repofiles/opennms-repo-stable-rhel7.noarch.rpm
[root@localhost]# rpm --import https://yum.opennms.org/OPENNMS-GPG-KEY
Opennms 및 의존성 패키지 설치
[root@localhost]# yum -y install opennms yum-utils java-11-openjdk java-11-openjdk-devel
[root@localhost]# yum-config-manager --disable opennms-repo-stable-common,opennms-repo-stable-rhel7
[root@localhost]# yum -y install opennms yum-utils java-11-openjdk java-11-openjdk-devel
[root@localhost]# yum-config-manager --disable opennms-repo-stable-common,opennms-repo-stable-rhel7
[root@localhost]# yum -y install opennms yum-utils java-11-openjdk java-11-openjdk-devel
[root@localhost]# yum-config-manager --disable opennms-repo-stable-common,opennms-repo-stable-rhel7
PG 시작 및 설정
[root@localhost]# postgresql-setup initdb
[root@localhost]# systemctl enable postgresql
[root@localhost]# systemctl start postgresql
[root@localhost]# postgresql-setup initdb
[root@localhost]# systemctl enable postgresql
[root@localhost]# systemctl start postgresql
[root@localhost]# postgresql-setup initdb
[root@localhost]# systemctl enable postgresql
[root@localhost]# systemctl start postgresql
PG 계정 및 DB 생성
[root@localhost]# su - postgres
-bash-4.2$ createuser -P opennms
-bash-4.2$ createdb -O opennms opennms
[root@localhost]# su - postgres
-bash-4.2$ createuser -P opennms
-bash-4.2$ createdb -O opennms opennms
[root@localhost]# su - postgres
-bash-4.2$ createuser -P opennms
-bash-4.2$ createdb -O opennms opennms
PG Super User Password 변경
-bash-4.2$ psql -c "ALTER USER postgres WITH PASSWORD 'YOUR-POSTGRES-PASSWORD';"
-bash-4.2$ psql -c "ALTER USER postgres WITH PASSWORD 'YOUR-POSTGRES-PASSWORD';"
-bash-4.2$ exit
-bash-4.2$ psql -c "ALTER USER postgres WITH PASSWORD 'YOUR-POSTGRES-PASSWORD';"
-bash-4.2$ exit
PG Access Policy 변경
: vi /var/lib/pgsql/data/pg_hba.conf
host all all 127.0.0.1/32 md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
[root@localhost]# systemctl restart postgresql
[root@localhost]# systemctl restart postgresql
[root@localhost]# systemctl restart postgresql
Opennms Horizon Database 설정 변경
: vi /opt/opennms/etc/opennms-datasources.xml
<jdbc-data-source name="opennms"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/opennms"
password="4. 진행시 입력한 패스워드 " />
<jdbc-data-source name="opennms-admin"
database-name="template1"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/template1"
password="5. 진행시 입력한 패스워드 " />
<jdbc-data-source name="opennms"
database-name="opennms"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/opennms"
user-name="opennms"
password="4. 진행시 입력한 패스워드 " />
<jdbc-data-source name="opennms-admin"
database-name="template1"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/template1"
user-name="postgres"
password="5. 진행시 입력한 패스워드 " />
<jdbc-data-source name="opennms"
database-name="opennms"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/opennms"
user-name="opennms"
password="4. 진행시 입력한 패스워드 " />
<jdbc-data-source name="opennms-admin"
database-name="template1"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/template1"
user-name="postgres"
password="5. 진행시 입력한 패스워드 " />
Opennms Flow 관련 설정 변경
: vi /opt/opennms/etc/telemetryd-configuration.xml
<!-- SFlow listener & adapters -->
<listener name="SFlow-UDP-6343" class-name="org.opennms.netmgt.telemetry.listeners.UdpListener" enabled="true">
<parameter key="port" value="6343"/>
<parser name="SFlow-Parser" class-name="org.opennms.netmgt.telemetry.protocols.sflow.parser.SFlowUdpParser" queue="SFlow" />
<adapter name="SFlow-Adapter" class-name="org.opennms.netmgt.telemetry.protocols.sflow.adapter.SFlowAdapter" enabled="true">
<adapter name="SFlow-Telemetry" class-name="org.opennms.netmgt.telemetry.protocols.sflow.adapter.SFlowTelemetryAdapter" enabled="true">
<parameter key="script" value="/opt/opennms/etc/telemetryd-adapters/sflow-host.groovy"/>
<package name="SFlow-Default">
<rra>RRA:AVERAGE:0.5:1:2016</rra>
<rra>RRA:AVERAGE:0.5:12:1488</rra>
<rra>RRA:AVERAGE:0.5:288:366</rra>
<rra>RRA:MAX:0.5:288:366</rra>
<rra>RRA:MIN:0.5:288:366</rra>
<!-- SFlow listener & adapters -->
<listener name="SFlow-UDP-6343" class-name="org.opennms.netmgt.telemetry.listeners.UdpListener" enabled="true">
<parameter key="port" value="6343"/>
<parser name="SFlow-Parser" class-name="org.opennms.netmgt.telemetry.protocols.sflow.parser.SFlowUdpParser" queue="SFlow" />
</listener>
<queue name="SFlow">
<adapter name="SFlow-Adapter" class-name="org.opennms.netmgt.telemetry.protocols.sflow.adapter.SFlowAdapter" enabled="true">
</adapter>
<adapter name="SFlow-Telemetry" class-name="org.opennms.netmgt.telemetry.protocols.sflow.adapter.SFlowTelemetryAdapter" enabled="true">
<parameter key="script" value="/opt/opennms/etc/telemetryd-adapters/sflow-host.groovy"/>
<package name="SFlow-Default">
<rrd step="300">
<rra>RRA:AVERAGE:0.5:1:2016</rra>
<rra>RRA:AVERAGE:0.5:12:1488</rra>
<rra>RRA:AVERAGE:0.5:288:366</rra>
<rra>RRA:MAX:0.5:288:366</rra>
<rra>RRA:MIN:0.5:288:366</rra>
</rrd>
</package>
</adapter>
</queue>
<!-- SFlow listener & adapters -->
<listener name="SFlow-UDP-6343" class-name="org.opennms.netmgt.telemetry.listeners.UdpListener" enabled="true">
<parameter key="port" value="6343"/>
<parser name="SFlow-Parser" class-name="org.opennms.netmgt.telemetry.protocols.sflow.parser.SFlowUdpParser" queue="SFlow" />
</listener>
<queue name="SFlow">
<adapter name="SFlow-Adapter" class-name="org.opennms.netmgt.telemetry.protocols.sflow.adapter.SFlowAdapter" enabled="true">
</adapter>
<adapter name="SFlow-Telemetry" class-name="org.opennms.netmgt.telemetry.protocols.sflow.adapter.SFlowTelemetryAdapter" enabled="true">
<parameter key="script" value="/opt/opennms/etc/telemetryd-adapters/sflow-host.groovy"/>
<package name="SFlow-Default">
<rrd step="300">
<rra>RRA:AVERAGE:0.5:1:2016</rra>
<rra>RRA:AVERAGE:0.5:12:1488</rra>
<rra>RRA:AVERAGE:0.5:288:366</rra>
<rra>RRA:MAX:0.5:288:366</rra>
<rra>RRA:MIN:0.5:288:366</rra>
</rrd>
</package>
</adapter>
</queue>
저는 sflow 를 사용하므로 sflow 관련 설정만 enable 시켰습니다. 설정 파일에는 netflow v5, v9 에 대한 정보도 있으니 필요하시면 enable 시키시면 됩니다.
Opennms Flow persistence elastic 설정
: vi /opt/opennms/etc/org.opennms.features.flows.persistence.elastic.cfg
elasticUrl=http://es-master-node:9200
elasticIndexStrategy=daily
elasticUrl=http://es-master-node:9200
elasticIndexStrategy=daily
elasticUrl=http://es-master-node:9200
elasticIndexStrategy=daily
Opennms Horizon 실행
[root@localhost]# alternatives --config java
There are 2 programs which provide 'java'.
-----------------------------------------------
1 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.3.7-0.el7_6.x86_64/bin/java)
* +2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java)
Enter to keep the current selection[+], or type selection number: 1
[root@localhost]# /opt/opennms/bin/runjava -s
[root@localhost]# /opt/opennms/bin/install -dis
[root@localhost]# systemctl enable opennms
[root@localhost]# systemctl start opennms
[root@localhost]# /opt/opennms/bin/send-event.pl -p 'daemonName Telemetryd' uei.opennms.org/internal/reloadDaemonconfig
[root@localhost]# alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.3.7-0.el7_6.x86_64/bin/java)
* +2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java)
Enter to keep the current selection[+], or type selection number: 1
[root@localhost]# /opt/opennms/bin/runjava -s
[root@localhost]# /opt/opennms/bin/install -dis
[root@localhost]# systemctl enable opennms
[root@localhost]# systemctl start opennms
[root@localhost]# /opt/opennms/bin/send-event.pl -p 'daemonName Telemetryd' uei.opennms.org/internal/reloadDaemonconfig
[root@localhost]# alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.3.7-0.el7_6.x86_64/bin/java)
* +2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java)
Enter to keep the current selection[+], or type selection number: 1
[root@localhost]# /opt/opennms/bin/runjava -s
[root@localhost]# /opt/opennms/bin/install -dis
[root@localhost]# systemctl enable opennms
[root@localhost]# systemctl start opennms
[root@localhost]# /opt/opennms/bin/send-event.pl -p 'daemonName Telemetryd' uei.opennms.org/internal/reloadDaemonconfig
이전 버전의 java 가 설치되어 있다면 java 버전 11-openjdk 로 선택하기 위해서
alternatives --config java
alternatives --config java
명령어 실행 후 java 버전은 11-openjdk 로 선택해 주시면 됩니다.
만약
/opt/opennms/bin/install -dis
/opt/opennms/bin/install -dis
를 실행하고 마지막에
Upgrade completed successfully! 값이 나오지 않는다면 PG 계정의 패스워드를 변경해 보시길 바랍니다. 특정 특수 문자가 제대로 인식되지 않는 현상이 있는 것으로 보입니다.
Opennms 설정
OpenNMS 접속
http://<ip-or-fqdn-of-your-server>:8980/opennms
접속 하면 다음과 같은 화면이 나옵니다. 기본 ID/PW 는 admin/admin 입니다. 접속 후에는 반드시 패스워드를 변경하시기 바랍니다.
노드 추가
Opennms 는 노드를 추가하기 위해서는 Requisition 을 먼저 생성 후 그 안에 노드가 생성이 됩니다. 글로 설명하는 것 보다는 보는 것이 더 이해하기 편하므로 이미지를 첨부합니다.
1) admin에서 Configure OpenNMS 를 선택합니다.
2) Manage Provisioning Requisitions 을 선택합니다.
3) Add requisitions 을 선택합니다.
4) 생선된 requisitions을 확인합니다.
5) admin에서 Quick-add Node 를 선택합니다.
6) 생성한 Requisition와 Node 정보를 입력합니다. 편하게 하기 위해서 SNMP 정보도 입력합니다.
7) requisition 에 Node가 추가 된 것을 확인합니다.
Flow 및 flow persistence 활성화
[root@localhost]# ssh -p 8101 admin@localhost
admin@opennms> config:edit org.opennms.features.flows.persistence.elastic
admin@opennms> config:property-set elasticUrl http://es-master-node:9200
admin@opennms> config:update
admin@opennms> config:edit org.opennms.netmgt.flows.rest
admin@opennms> config:property-set flowGraphUrl 'http://Grafana 설치 IP:3000/dashboard/flows?node=$nodeId&interface=$ifIndex'
admin@opennms> config:update
[root@localhost]# systemctl restart opennms
[root@localhost]# ssh -p 8101 admin@localhost
admin@opennms> config:edit org.opennms.features.flows.persistence.elastic
admin@opennms> config:property-set elasticUrl http://es-master-node:9200
admin@opennms> config:update
admin@opennms> config:edit org.opennms.netmgt.flows.rest
admin@opennms> config:property-set flowGraphUrl 'http://Grafana 설치 IP:3000/dashboard/flows?node=$nodeId&interface=$ifIndex'
admin@opennms> config:update
ctrl+d exit
[root@localhost]# systemctl restart opennms
[root@localhost]# ssh -p 8101 admin@localhost
admin@opennms> config:edit org.opennms.features.flows.persistence.elastic
admin@opennms> config:property-set elasticUrl http://es-master-node:9200
admin@opennms> config:update
admin@opennms> config:edit org.opennms.netmgt.flows.rest
admin@opennms> config:property-set flowGraphUrl 'http://Grafana 설치 IP:3000/dashboard/flows?node=$nodeId&interface=$ifIndex'
admin@opennms> config:update
ctrl+d exit
[root@localhost]# systemctl restart opennms
ES 에 자료 저장 확인
shell #> curl -XGET ‘localhost:9200/_cat/indices?v&pretty’
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open netflow-2019-06-21 REQNKXerScOFy9U0tpEGKA 5 1 4999 0 3.9mb 1.9mb
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open netflow-2019-06-21 REQNKXerScOFy9U0tpEGKA 5 1 4999 0 3.9mb 1.9mb
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open netflow-2019-06-21 REQNKXerScOFy9U0tpEGKA 5 1 4999 0 3.9mb 1.9mb
Opennms 의 설치와 기본 설정이 완료 되었습니다. 다음에는 수집된 정보를 시각화 하는 Grafana 설치 및 구성을 하도록 하겠습니다.