Dies ist eine alte Version des Dokuments!


Logdatenanalyse mit graylog unter CentOS 7.x

Bild: graylog Logo Für die Überwachung unserer Systeme, genauer gesagt den Loginformationen, greifen wir auf das Projekt graylog zurück. Mit graylog haben wir ein sehr mächtiges Werkzeug in Händen, welches uns die Erfassung, Indizierung und Analyse von Logdateninformationen aus fast all unseren Systemen und Geräten zur Verfügung.

Für den produktiven Einsatz von graylog müssen wir noch ein paar Vorbereitungen treffen; nähere Hinweise dazu findet man in der Architektur-Dokumentation von graylog. Im folgendem Installations- und Konfigurationsbeispiel orientieren wir uns am Minimum setup.

Bevor wir nun mit der Installation von graylog beginnen, müssen wir noch nachfolgende Voraussetzungen schaffen.

Hier installieren wir die benötige Java Umgebung (min. 1.7) aus dem CentOS Base Repository.

graylog nutzt als Datenbank-Server die NoSQL-Datenbank MongoDB. Diese beziehen wir aus dem EPEL Repository, welches wir, falls noch nicht geschehen, in unser System wie hier beschrieben einbinden.

graylog nutzt als Suchmaschine/-server das Projekt Elasticsearch. Das benötigte aktuelle RPM beziehen wir direkt von elastic, die hierzu ein eigenes Repository anbieten.

ACHTUNG: Graylog 1.x doesn't support Elasticsearch 2.x! ⇒ https://github.com/Graylog2/graylog2-server/issues/1531#issuecomment-153648361

Zur Installation des Repositories selbst wir uns kein RPM angeboten. Daher werden wir kurzer Hand die benötigte Konfigurationsdatei für das Repository elasticsearch selbst anlegen.

 # vim /etc/yum.repos.d/elasticsearch.repo
/etc/yum.repos.d/elasticsearch.repo
# Django : 2015-12-21 - Repository elasticsearch 2.x ist nicht mit graylog 1.x kompatibel!
[elasticsearch-2.x]
name=Elasticsearch repository for 2.x packages
baseurl=http://packages.elastic.co/elasticsearch/2.x/centos
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/GPG-KEY-elasticsearch
priority = 20
enabled=0
 
# Django : 2015-12-28 - Repository elasticsearch für graylog-Installation
[elasticsearch-1.7]
name=Elasticsearch repository for 1.7.x packages
baseurl=http://packages.elastic.co/elasticsearch/1.7/centos
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1

Damit später nur verifizierte, also RPM-Pakete mit einer gültigen PGP-Signatur installiert werden können, benötigen wir noch den passenden PGP-Key von elasticsearch. Hinweise zum Bezug des Schlüssels und dessen Fingerprint finden wir auf der elasticsearch Dokumentationsseite. Wir holen uns nun den RPM-PGP-Key auf unseren Server.

 # wget https://packages.elastic.co/GPG-KEY-elasticsearch -P /etc/pki/rpm-gpg

Bevor wir diesen aber importieren, lassen wir uns den Fingerprint am Bildschirm ausgeben.

 # gpg --with-fingerprint /etc/pki/rpm-gpg/GPG-KEY-elasticsearch
pub  2048R/D88E42B4 2013-09-16 Elasticsearch (Elasticsearch Signing Key) <dev_ops@elasticsearch.org>
      Key fingerprint = 4609 5ACC 8548 582C 1A26  99A9 D27D 666C D88E 42B4
sub  2048R/60D31954 2013-09-16

Diesen Key fingerprint = 4609 5ACC 8548 582C 1A26 99A9 D27D 666C D88E 42B4 vergleichen wir nun mit den Angaben auf der elasticsearch Dokumentationsseite. Stimmen beide Fingerprints überein, steht dem Import des Schlüssels nicht's mehr entgegen.

 # rpm --import /etc/pki/rpm-gpg/GPG-KEY-elasticsearch

Graylog selbst werden wir später aus dem Repository von graylog installieren. So bleibt zum einen der Konfigurationsaufwand überschaubar und wir werden mit Updates versorgt, wenn Änderungen und/oder Erweiterungen am Programmcode von graylog notwendig werden. Die Integration des benötigten Repositories erfolgt direkt mit nachfolgendem Befehl:

 # yum localinstall https://packages.graylog2.org/repo/el/7/1.3/x86_64/graylog-1.3-repository-el7-1.3.0-1.noarch.rpm

Leider bietet uns graylog selbst keine Möglichkeit, den Fingerprint des PGP-Key /etc/pki/rpm-gpg/RPM-GPG-KEY-graylog mit der Key-ID=B1606F22 einzusehen. Wir müssen daher auf einen PGP-Keyserver ausweichen. Über die URL http://keyserver.nausch.org/pks/lookup?search=0xB1606F22&fingerprint=on erhalten wir in einem Browserfenster direkt den Fingerprint angezeigt. Diesen Fingerprint vergleichen wir nun mit dem des RPM-Pakets.

 # gpg --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-graylog
pub  2048R/B1606F22 2014-06-04 TORCH GmbH <packages@torch.sh>
      Key fingerprint = 28AB 6EB5 7277 9C2A D196  BE22 D44C 1D8D B160 6F22

Sind beide Werte gleich, können wir auch diesen PGP-Key wie gewohnt importieren.

 # rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-graylog

Da nun alle Voraussetzungen geschaffen sind, können wir uns an die Installation der einzelnen RPM-Pakete machen.

Als erstes installieren wir nun die OpenJDK Runtime Environment mit Hilfe von YUM.

 # yum install java-1.8.0-openjdk -y

Haben wir bereits eine installierte Java Umgebung installiert können wir mit folgendem Befehl abfragen ob die benötigte Version den Installationsvoraussetzungen (installiertes JAVA oder OpenJDK ab Version 1.7.0) von graylog genügt.

 # java -version
openjdk version "1.8.0_65"
OpenJDK Runtime Environment (build 1.8.0_65-b17)
OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)

Wollen wir wissen, welche Dateien und Verzeichnisse das Paket auf unseren Server packte, benutzen wir folgenden Befehl.

 # rpm -qil java-1.8.0-openjdk
Name        : java-1.8.0-openjdk
Epoch       : 1
Version     : 1.8.0.65
Release     : 3.b17.el7
Architecture: x86_64
Install Date: Mon 21 Dec 2015 12:46:44 PM CET
Group       : Development/Languages
Size        : 512633
License     : ASL 1.1 and ASL 2.0 and GPL+ and GPLv2 and GPLv2 with exceptions and LGPL+ and LGPLv2 and MPLv1.0 and MPLv1.1 and Public Domain and W3C
Signature   : RSA/SHA256, Wed 25 Nov 2015 03:45:32 PM CET, Key ID 24c6a8a7f4a80eb5
Source RPM  : java-1.8.0-openjdk-1.8.0.65-3.b17.el7.src.rpm
Build Date  : Sat 21 Nov 2015 04:29:16 AM CET
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://openjdk.java.net/
Summary     : OpenJDK Runtime Environment
Description :
The OpenJDK runtime environment.
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/jre/bin/policytool
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/jre/lib/amd64/libawt_xawt.so
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/jre/lib/amd64/libjawt.so
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/jre/lib/amd64/libjsoundalsa.so
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/jre/lib/amd64/libsplashscreen.so
/usr/share/applications/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64-policytool.desktop
/usr/share/icons/hicolor/16x16/apps/java-1.8.0.png
/usr/share/icons/hicolor/24x24/apps/java-1.8.0.png
/usr/share/icons/hicolor/32x32/apps/java-1.8.0.png
/usr/share/icons/hicolor/48x48/apps/java-1.8.0.png

Als nächstes erfolgt die Installation unserer MongoDB. Dank dem eingebundenen zugehörigen Repository erfolgt dies mit Hilfe von YUM.

 # yum install mongodb mongodb-server -y

Auch hier können wir uns einen Überblick verschaffen, welche Verzeichnisse angelegt und Dateien dort abgelegt wurden.

 # rpm -qil mongodb
Name        : mongodb               
Version     : 2.6.11                
Release     : 1.el7                 
Architecture: x86_64
Install Date: Wed 23 Dec 2015 10:19:36 AM CET
Group       : Applications/Databases
Size        : 137519320
License     : AGPLv3 and zlib and ASL 2.0
Signature   : RSA/SHA256, Thu 20 Aug 2015 07:39:20 PM CEST, Key ID 6a2faea2352c64e5
Source RPM  : mongodb-2.6.11-1.el7.src.rpm
Build Date  : Wed 19 Aug 2015 01:57:11 PM CEST
Build Host  : buildvm-08.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://www.mongodb.org
Summary     : High-performance, schema-free document-oriented database
Description :
Mongo (from "humongous") is a high-performance, open source, schema-free
document-oriented database. MongoDB is written in C++ and offers the following
features:
    * Collection oriented storage: easy storage of object/JSON-style data
    * Dynamic queries
    * Full index support, including on inner objects and embedded arrays
    * Query profiling
    * Replication and fail-over support
    * Efficient storage of binary data including large objects (e.g. photos
    and videos)
    * Auto-sharding for cloud-level scalability (currently in early alpha)
    * Commercial Support Available

A key goal of MongoDB is to bridge the gap between key/value stores (which are
fast and highly scalable) and traditional RDBMS systems (which are deep in
functionality).
/usr/bin/bsondump
/usr/bin/mongo
/usr/bin/mongodump
/usr/bin/mongoexport
/usr/bin/mongofiles
/usr/bin/mongoimport
/usr/bin/mongooplog
/usr/bin/mongoperf
/usr/bin/mongorestore
/usr/bin/mongosniff
/usr/bin/mongostat
/usr/bin/mongotop
/usr/share/doc/mongodb-2.6.11
/usr/share/doc/mongodb-2.6.11/README
/usr/share/licenses/mongodb-2.6.11
/usr/share/licenses/mongodb-2.6.11/APACHE-2.0.txt
/usr/share/licenses/mongodb-2.6.11/GNU-AGPL-3.0.txt
/usr/share/man/man1/bsondump.1.gz
/usr/share/man/man1/mongo.1.gz
/usr/share/man/man1/mongodump.1.gz
/usr/share/man/man1/mongoexport.1.gz
/usr/share/man/man1/mongofiles.1.gz
/usr/share/man/man1/mongoimport.1.gz
/usr/share/man/man1/mongooplog.1.gz
/usr/share/man/man1/mongoperf.1.gz
/usr/share/man/man1/mongorestore.1.gz
/usr/share/man/man1/mongosniff.1.gz
/usr/share/man/man1/mongostat.1.gz
/usr/share/man/man1/mongotop.1.gz
 # rpm -qil mongodb-server
Name        : mongodb-server
Version     : 2.6.11
Release     : 1.el7
Architecture: x86_64
Install Date: Wed 23 Dec 2015 10:19:25 AM CET
Group       : Applications/Databases
Size        : 20949371
License     : AGPLv3 and zlib and ASL 2.0
Signature   : RSA/SHA256, Thu 20 Aug 2015 07:37:34 PM CEST, Key ID 6a2faea2352c64e5
Source RPM  : mongodb-2.6.11-1.el7.src.rpm
Build Date  : Wed 19 Aug 2015 01:57:11 PM CEST
Build Host  : buildvm-08.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://www.mongodb.org
Summary     : MongoDB server, sharding server and support scripts
Description :
This package provides the mongo server software, mongo sharding server
software, default configuration files, and init scripts.
/etc/logrotate.d/mongodb
/etc/mongod.conf
/etc/mongos.conf
/etc/sysconfig/mongod
/etc/sysconfig/mongos
/usr/bin/mongod
/usr/bin/mongos
/usr/lib/systemd/system/mongod.service
/usr/lib/systemd/system/mongos.service
/usr/lib/tmpfiles.d/mongodb.conf
/usr/share/man/man1/mongod.1.gz
/usr/share/man/man1/mongos.1.gz
/var/lib/mongodb
/var/log/mongodb
/var/run/mongodb

Im nächsten Schritt installieren wir nun noch elasticsearch als Suchmaschine/-server.

 # yum install elasticsearch -y

Wollen wir wissen, welche Dateien und Verzeichnisse das Paket auf unseren Server packte, benutzen wir folgenden Befehl.

 # rpm -qil elasticsearch
Name        : elasticsearch                         
Version     : 1.7.4                                 
Release     : 1                                     
Architecture: noarch                                
Install Date: Mon 28 Dec 2015 02:05:49 PM CET       
Group       : Application/Internet                  
Size        : 31336448                              
License     : (c) 2009
Signature   : RSA/SHA1, Tue 15 Dec 2015 05:53:18 PM CET, Key ID d27d666cd88e42b4
Source RPM  : elasticsearch-1.7.4-1.src.rpm
Build Date  : Tue 15 Dec 2015 05:53:15 PM CET
Build Host  : monster
Relocations : /usr
Packager    : Elasticsearch
Summary     : elasticsearch
Description :
Elasticsearch - Open Source, Distributed, RESTful Search Engine
/etc/elasticsearch
/etc/elasticsearch/elasticsearch.yml
/etc/elasticsearch/logging.yml
/etc/init.d/elasticsearch
/etc/sysconfig/elasticsearch
/tmp/elasticsearch
/usr/lib/sysctl.d
/usr/lib/sysctl.d/elasticsearch.conf
/usr/lib/systemd/system/elasticsearch.service
/usr/lib/tmpfiles.d
/usr/lib/tmpfiles.d/elasticsearch.conf
/usr/share/elasticsearch/LICENSE.txt
/usr/share/elasticsearch/NOTICE.txt
/usr/share/elasticsearch/README.textile
/usr/share/elasticsearch/bin
/usr/share/elasticsearch/bin/elasticsearch
/usr/share/elasticsearch/bin/elasticsearch.in.sh
/usr/share/elasticsearch/bin/plugin
/usr/share/elasticsearch/lib/antlr-runtime-3.5.jar
/usr/share/elasticsearch/lib/apache-log4j-extras-1.2.17.jar
/usr/share/elasticsearch/lib/asm-4.1.jar
/usr/share/elasticsearch/lib/asm-commons-4.1.jar
/usr/share/elasticsearch/lib/elasticsearch-1.7.4.jar
/usr/share/elasticsearch/lib/groovy-all-2.4.4.jar
/usr/share/elasticsearch/lib/jna-4.1.0.jar
/usr/share/elasticsearch/lib/jts-1.13.jar
/usr/share/elasticsearch/lib/log4j-1.2.17.jar
/usr/share/elasticsearch/lib/lucene-analyzers-common-4.10.4.jar
/usr/share/elasticsearch/lib/lucene-core-4.10.4.jar
/usr/share/elasticsearch/lib/lucene-expressions-4.10.4.jar
/usr/share/elasticsearch/lib/lucene-grouping-4.10.4.jar
/usr/share/elasticsearch/lib/lucene-highlighter-4.10.4.jar
/usr/share/elasticsearch/lib/lucene-join-4.10.4.jar
/usr/share/elasticsearch/lib/lucene-memory-4.10.4.jar
/usr/share/elasticsearch/lib/lucene-misc-4.10.4.jar
/usr/share/elasticsearch/lib/lucene-queries-4.10.4.jar
/usr/share/elasticsearch/lib/lucene-queryparser-4.10.4.jar
/usr/share/elasticsearch/lib/lucene-sandbox-4.10.4.jar
/usr/share/elasticsearch/lib/lucene-spatial-4.10.4.jar
/usr/share/elasticsearch/lib/lucene-suggest-4.10.4.jar
/usr/share/elasticsearch/lib/sigar
/usr/share/elasticsearch/lib/sigar/libsigar-amd64-linux.so
/usr/share/elasticsearch/lib/sigar/libsigar-ia64-linux.so
/usr/share/elasticsearch/lib/sigar/libsigar-x86-linux.so
/usr/share/elasticsearch/lib/sigar/sigar-1.6.4.jar
/usr/share/elasticsearch/lib/spatial4j-0.4.1.jar
/usr/share/elasticsearch/plugins
/var/lib/elasticsearch
/var/log/elasticsearch
/var/run/elasticsearch

Zu guter letzt installieren wir nun noch Pakete graylog sowie das Zusatzprogramm pwgen zum Generieren von Passwörtern, natürlich auch dieses mal mit Unterstützung von YUM.

 # yum install graylog-server graylog-web pwgen -y

Auch hier können wir uns einen Überblick verschaffen, welche Verzeichnisse angelegt und Dateien dort abgelegt wurden.

 # rpm -qil graylog-server
Name        : graylog-server
Version     : 1.3.2
Release     : 1
Architecture: noarch
Install Date: Wed 23 Dec 2015 10:41:06 AM CET
Group       : optional
Size        : 76865791
License     : GPLv3
Signature   : RSA/SHA1, Fri 18 Dec 2015 04:37:43 PM CET, Key ID d44c1d8db1606f22
Source RPM  : graylog-server-1.3.2-1.src.rpm
Build Date  : Fri 18 Dec 2015 04:37:25 PM CET
Build Host  : 861e2c96c63a
Relocations : /
Packager    : Graylog, Inc. <hello@graylog.org>
Vendor      : graylog
URL         : https://www.graylog.org/
Summary     : Graylog server
Description :
Graylog server
/etc/graylog/server/log4j.xml
/etc/graylog/server/server.conf
/etc/sysconfig/graylog-server
/usr/lib/systemd/system/graylog-server.service
/usr/share/graylog-server/bin/graylog-es-timestamp-fixup
/usr/share/graylog-server/bin/graylog-server
/usr/share/graylog-server/contentpacks/grok-patterns.json
/usr/share/graylog-server/graylog.jar
/usr/share/graylog-server/installation-source.sh
/usr/share/graylog-server/lib/sigar/libsigar-amd64-linux.so
/usr/share/graylog-server/lib/sigar/libsigar-x86-linux.so
/usr/share/graylog-server/plugin/usage-statistics-1.2.1.jar
 # rpm -qil graylog-web
Name        : graylog-web                                                       
Version     : 1.3.2                                                             
Release     : 1                                                                 
Architecture: noarch                                                            
Install Date: Wed 23 Dec 2015 10:41:08 AM CET                                   
Group       : optional                                                          
Size        : 46487307                                                          
License     : GPLv3                                                             
Signature   : RSA/SHA1, Fri 18 Dec 2015 04:39:01 PM CET, Key ID d44c1d8db1606f22
Source RPM  : graylog-web-1.3.2-1.src.rpm                                       
Build Date  : Fri 18 Dec 2015 04:38:50 PM CET                                   
Build Host  : e1ea7e6dc62a                                                      
Relocations : /                                                                 
Packager    : Graylog, Inc. <hello@graylog.org>                                 
Vendor      : graylog                                                           
URL         : https://www.graylog.org/                                          
Summary     : Graylog web                                                       
Description :                                                                   
Graylog web                                                                     
/etc/graylog/web/application.conf                                               
/etc/graylog/web/logback.xml                                                    
/etc/graylog/web/play.plugins                                                   
/etc/graylog/web/web.conf                                                       
/etc/sysconfig/graylog-web                                                      
/usr/lib/systemd/system/graylog-web.service                                     
/usr/share/graylog-web/README.md                                                
/usr/share/graylog-web/bin/graylog-web                                          
/usr/share/graylog-web/bin/graylog-web-interface                                
/usr/share/graylog-web/conf                                                     
/usr/share/graylog-web/lib/aopalliance.aopalliance-1.0.jar                      
/usr/share/graylog-web/lib/ch.qos.logback.logback-classic-1.1.1.jar             
/usr/share/graylog-web/lib/ch.qos.logback.logback-core-1.1.1.jar                
/usr/share/graylog-web/lib/com.fasterxml.classmate-1.1.0.jar                    
/usr/share/graylog-web/lib/com.fasterxml.jackson.core.jackson-annotations-2.6.2.jar
/usr/share/graylog-web/lib/com.fasterxml.jackson.core.jackson-core-2.6.2.jar       
/usr/share/graylog-web/lib/com.fasterxml.jackson.core.jackson-databind-2.6.2.jar   
/usr/share/graylog-web/lib/com.fasterxml.jackson.datatype.jackson-datatype-guava-2.6.2.jar
/usr/share/graylog-web/lib/com.fasterxml.jackson.datatype.jackson-datatype-joda-2.6.2.jar 
/usr/share/graylog-web/lib/com.github.fdimuccio.play2-sockjs_2.10-0.3.1.jar               
/usr/share/graylog-web/lib/com.google.code.findbugs.jsr305-3.0.1.jar
/usr/share/graylog-web/lib/com.google.guava.guava-18.0.jar
/usr/share/graylog-web/lib/com.google.inject.extensions.guice-assistedinject-4.0.jar
/usr/share/graylog-web/lib/com.google.inject.guice-4.0.jar
/usr/share/graylog-web/lib/com.ning.async-http-client-1.9.31.jar
/usr/share/graylog-web/lib/com.squareup.okhttp.okhttp-2.5.0.jar
/usr/share/graylog-web/lib/com.squareup.okio.okio-1.6.0.jar
/usr/share/graylog-web/lib/com.typesafe.akka.akka-actor_2.10-2.3.5.jar
/usr/share/graylog-web/lib/com.typesafe.akka.akka-slf4j_2.10-2.3.4.jar
/usr/share/graylog-web/lib/com.typesafe.config-1.2.1.jar
/usr/share/graylog-web/lib/com.typesafe.netty.netty-http-pipelining-1.1.2.jar
/usr/share/graylog-web/lib/com.typesafe.play.build-link-2.3.10.jar
/usr/share/graylog-web/lib/com.typesafe.play.play-cache_2.10-2.3.10.jar
/usr/share/graylog-web/lib/com.typesafe.play.play-datacommons_2.10-2.3.10.jar
/usr/share/graylog-web/lib/com.typesafe.play.play-exceptions-2.3.10.jar
/usr/share/graylog-web/lib/com.typesafe.play.play-functional_2.10-2.3.10.jar
/usr/share/graylog-web/lib/com.typesafe.play.play-iteratees_2.10-2.3.10.jar
/usr/share/graylog-web/lib/com.typesafe.play.play-java_2.10-2.3.10.jar
/usr/share/graylog-web/lib/com.typesafe.play.play-json_2.10-2.3.10.jar
/usr/share/graylog-web/lib/com.typesafe.play.play_2.10-2.3.10.jar
/usr/share/graylog-web/lib/com.typesafe.play.twirl-api_2.10-1.0.2.jar
/usr/share/graylog-web/lib/commons-beanutils.commons-beanutils-1.8.3.jar
/usr/share/graylog-web/lib/commons-codec.commons-codec-1.9.jar
/usr/share/graylog-web/lib/commons-logging.commons-logging-1.1.3.jar
/usr/share/graylog-web/lib/dom4j.dom4j-1.6.1.jar
/usr/share/graylog-web/lib/graylog-web-interface.graylog-web-interface-1.3.2-assets.jar
/usr/share/graylog-web/lib/graylog-web-interface.graylog-web-interface-1.3.2.jar
/usr/share/graylog-web/lib/io.netty.netty-3.10.4.Final.jar
/usr/share/graylog-web/lib/javassist.javassist--3.12.1.GA-3.12.1.GA.jar
/usr/share/graylog-web/lib/javax.el.javax.el-api-3.0.0.jar
/usr/share/graylog-web/lib/javax.inject.javax.inject-1.jar
/usr/share/graylog-web/lib/javax.transaction.jta-1.1.jar
/usr/share/graylog-web/lib/javax.validation.validation-api-1.1.0.Final.jar
/usr/share/graylog-web/lib/joda-time.joda-time-2.8.2.jar
/usr/share/graylog-web/lib/net.sf.ehcache.ehcache-core-2.6.8.jar
/usr/share/graylog-web/lib/org.apache.commons.commons-lang3-3.1.jar
/usr/share/graylog-web/lib/org.apache.shiro.shiro-core-1.2.4.jar
/usr/share/graylog-web/lib/org.apache.tomcat.tomcat-servlet-api-8.0.5.jar
/usr/share/graylog-web/lib/org.graylog2.graylog2-rest-client--1.3.2-1.3.2.jar
/usr/share/graylog-web/lib/org.graylog2.graylog2-rest-models-1.3.2.jar
/usr/share/graylog-web/lib/org.graylog2.play2-graylog2_2.10-1.2.1.jar
/usr/share/graylog-web/lib/org.hibernate.hibernate-validator-5.2.2.Final.jar
/usr/share/graylog-web/lib/org.javassist.javassist-3.19.0-GA.jar
/usr/share/graylog-web/lib/org.jboss.logging.jboss-logging-3.2.1.Final.jar
/usr/share/graylog-web/lib/org.joda.joda-convert-1.6.jar
/usr/share/graylog-web/lib/org.reflections.reflections-0.9.8.jar
/usr/share/graylog-web/lib/org.scala-lang.scala-library-2.10.4.jar
/usr/share/graylog-web/lib/org.scala-lang.scala-reflect-2.10.4.jar
/usr/share/graylog-web/lib/org.scala-stm.scala-stm_2.10-0.7.jar
/usr/share/graylog-web/lib/org.slf4j.jcl-over-slf4j-1.7.6.jar
/usr/share/graylog-web/lib/org.slf4j.jul-to-slf4j-1.7.6.jar
/usr/share/graylog-web/lib/org.slf4j.slf4j-api-1.7.12.jar
/usr/share/graylog-web/lib/org.springframework.spring-aop--4.0.3.RELEASE-4.0.3.RELEASE.jar
/usr/share/graylog-web/lib/org.springframework.spring-beans-4.0.3.RELEASE.jar
/usr/share/graylog-web/lib/org.springframework.spring-context-4.0.3.RELEASE.jar
/usr/share/graylog-web/lib/org.springframework.spring-core-4.0.3.RELEASE.jar
/usr/share/graylog-web/lib/org.springframework.spring-expression--4.0.3.RELEASE-4.0.3.RELEASE.jar
/usr/share/graylog-web/lib/org.yaml.snakeyaml-1.13.jar
/usr/share/graylog-web/lib/xerces.xercesImpl-2.11.0.jar
/usr/share/graylog-web/lib/xml-apis.xml-apis-1.4.01.jar
 # rpm -qil pwgen
Name        : pwgen
Version     : 2.07
Release     : 1.el7
Architecture: x86_64
Install Date: Mon 28 Dec 2015 09:54:47 AM CET
Group       : Applications/System
Size        : 37925
License     : GPL+
Signature   : RSA/SHA256, Sat 06 Dec 2014 03:49:56 PM CET, Key ID 6a2faea2352c64e5
Source RPM  : pwgen-2.07-1.el7.src.rpm
Build Date  : Fri 05 Dec 2014 06:56:18 PM CET
Build Host  : buildvm-08.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://sf.net/projects/pwgen
Summary     : Automatic password generation
Description :
pwgen generates random, meaningless but pronounceable passwords. These
passwords contain either only lowercase letters, or upper and lower case, or
upper case, lower case and numeric digits. Upper case letters and numeric
digits are placed in a way that eases memorizing the password.
/usr/bin/pwgen
/usr/share/doc/pwgen-2.07
/usr/share/doc/pwgen-2.07/changelog
/usr/share/doc/pwgen-2.07/copyright
/usr/share/man/man1/pwgen.1.gz

Nachdem wir die Installation aller benötigten Programmpakete erfolgreich abgeschlossen haben, können wir uns nun an die Installation der einzelnen Komponenten wagen.

Obwohl in der MongoDB nur Metainformationen gespeichert und vorgehalten werden, wollen wir diese NoSQL-Datenbank absichern, indem wir einen Datenbakbenutzer mit Passwort anlegen. Somit ist sichergestellt, dass kein unbefugter Daten der MongoDB abrufen, ändern odfer gar löschen kann.

Start des Daemon

Unsere Konfigurationsänderungen werden mit Hilfe von mongo der MongoDB Shell vorgenommen. Dieses JavaScript stellt die Benutzerschnittstelle zum eigentlichen MongoDN-Daemon zur Verfügung. Damit sich der Client mit dem Server auch verbinden kann, muss der Server natürlich laufen; wir starten also nun unsere NoSQL-Datenbank mit folgendem Befehl.

 # systemctl start mongod.service

Den Serverstatus können wir wie folgt abfragen.

 # systemctl status mongod.service

mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2015-12-23 11:05:55 CET; 57min ago
 Main PID: 23784 (mongod)
   CGroup: /system.slice/mongod.service
           └─23784 /usr/bin/mongod --quiet -f /etc/mongod.conf run

Dec 23 11:05:52 vml000117.dmz.nausch.org systemd[1]: Starting High-performance, schema-free document-oriented database...
Dec 23 11:05:52 vml000117.dmz.nausch.org mongod[23782]: about to fork child process, waiting until server is ready for connections.
Dec 23 11:05:52 vml000117.dmz.nausch.org mongod[23782]: forked process: 23784
Dec 23 11:05:55 vml000117.dmz.nausch.org systemd[1]: Started High-performance, schema-free document-oriented database.

Der erfolgreiche Start des Servers wird auch in dessen Logdatei protokolliert.

 # less /var/log/mongodb/mongod.log
2015-12-23T11:05:52.629+0100 [initandlisten] MongoDB starting : pid=23784 port=27017 dbpath=/var/lib/mongodb 64-bit host=vml000117.dmz.nausch.org
2015-12-23T11:05:52.630+0100 [initandlisten] db version v2.6.11
2015-12-23T11:05:52.630+0100 [initandlisten] git version: nogitversion
2015-12-23T11:05:52.630+0100 [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2015-12-23T11:05:52.630+0100 [initandlisten] build info: Linux buildvm-08.phx2.fedoraproject.org 4.1.4-100.fc21.x86_64 #1 SMP Tue Aug 4 03:25:05 UTC 2015 x86_64 BOOST_LIB_VERSION=1_53
2015-12-23T11:05:52.630+0100 [initandlisten] allocator: tcmalloc
2015-12-23T11:05:52.630+0100 [initandlisten] options: { command: [ "run" ], config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", unixDomainSocket: { pathPrefix: "/var/run/mongodb" } }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongodb" }, systemLog: { destination: "file", path: "/var/log/mongodb/mongod.log", quiet: true } }
2015-12-23T11:05:52.630+0100 [initandlisten]
2015-12-23T11:05:52.630+0100 [initandlisten] ** WARNING: Readahead for /var/lib/mongodb is set to 4096KB
2015-12-23T11:05:52.630+0100 [initandlisten] **          We suggest setting it to 256KB (512 sectors) or less
2015-12-23T11:05:52.630+0100 [initandlisten] **          http://dochub.mongodb.org/core/readahead
2015-12-23T11:05:52.644+0100 [initandlisten] journal dir=/var/lib/mongodb/journal
2015-12-23T11:05:52.644+0100 [initandlisten] recover : no journal files present, no recovery needed
2015-12-23T11:05:54.446+0100 [initandlisten] preallocateIsFaster=true 11.28
2015-12-23T11:05:55.340+0100 [initandlisten] allocating new ns file /var/lib/mongodb/local.ns, filling with zeroes...
2015-12-23T11:05:55.519+0100 [FileAllocator] allocating new datafile /var/lib/mongodb/local.0, filling with zeroes...
2015-12-23T11:05:55.519+0100 [FileAllocator] creating directory /var/lib/mongodb/_tmp
2015-12-23T11:05:55.532+0100 [FileAllocator] done allocating datafile /var/lib/mongodb/local.0, size: 64MB,  took 0.004 secs
2015-12-23T11:05:55.535+0100 [initandlisten] build index on: local.startup_log properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "local.startup_log" }
2015-12-23T11:05:55.535+0100 [initandlisten]     added index to empty collection
2015-12-23T11:05:55.535+0100 [initandlisten] command local.$cmd command: create { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0 numYields:0  reslen:37 195ms
2015-12-23T11:05:55.535+0100 [initandlisten] waiting for connections on port 27017

Standardmäßig öffnet der MongoDB-Daemon den Port 27017. Dies können wir wie folgt auch überprüfen:

 # netstat -tulpen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      184        19185      1460/mongod

Anpassung des Readahead-Parameters

Im Logfile finden wir eine Readahead-Warnmeldung mit dem Hinweis, dass die readahead-Einstellungen für das Block-Gerät auf dem die MongoDB gespeichert wurde nicht optimal zum Speichern der NoSQL-Datenbank MongoDB geeigent ist.

 2015-12-23T11:05:52.630+0100 [initandlisten] ** WARNING: Readahead for /var/lib/mongodb is set to 4096KB
 2015-12-23T11:05:52.630+0100 [initandlisten] **          We suggest setting it to 256KB (512 sectors) or less
 2015-12-23T11:05:52.630+0100 [initandlisten] **          http://dochub.mongodb.org/core/readahead

Zunächst suchen wir, auf welchem Blockdevice das Verzeichnis /var/lib/mongodb liegt.

 # mount | grep /var/lib/mongodb
/dev/vdc1 on /var/lib/mongodb type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

Fragen wir die Einstellungen unserer Blockdevices ab erhalten wir zunächst:

 # blockdev --report
RO    RA   SSZ   BSZ   StartSec            Size   Device
rw  8192   512  4096          0     10485760000   /dev/vda
rw  8192   512   512       2048       524288000   /dev/vda1
rw  8192   512  4096    1026048      9960423424   /dev/vda2
rw  8192   512  4096          0     21474836480   /dev/vdb
rw  8192   512   512       2048     21473787904   /dev/vdb1
rw  8192   512  4096          0     21474836480   /dev/vdc
rw  8192   512   512       2048     21473787904   /dev/vdc1
rw  8192   512  4096          0      1073741824   /dev/dm-0
rw  8192   512   512          0      6731857920   /dev/dm-1
rw  8192   512   512          0      2147483648   /dev/dm-2

Wir setzen nunmehr den Wert RA auf die empfohlene Größe von 256KB (512 sectors) für das Blockdevice /dev/vdc1 auf dem unsere MongoDB bespeichert wird.

 # blockdev --setra 256 /dev/vdc1

Fragen wir erneut die Einstellungen für /dev/vdc1 sehen wir, dass der Parameter RA nun den Wert von 256 hat.

 # blockdev --report | grep /dev/vdc1
rw   256   512   512       2048     21473787904   /dev/vdc1

Wenn abschließend starten wir nun den MongoDB-Daemon einmal durch, damit unsere Änderung auch wirksam werden kann.

 # systemctl restart mongod.service

Die Warnmeldung ist nunmehr verschwunden.

 # less /var/log/mongodb/mongod.log
2015-12-23T12:11:50.221+0100 [initandlisten] MongoDB starting : pid=16609 port=27017 dbpath=/var/lib/mongodb 64-bit host=vml000117.dmz.nausch.org
2015-12-23T12:11:50.221+0100 [initandlisten] db version v2.6.11
2015-12-23T12:11:50.221+0100 [initandlisten] git version: nogitversion
2015-12-23T12:11:50.221+0100 [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2015-12-23T12:11:50.221+0100 [initandlisten] build info: Linux buildvm-08.phx2.fedoraproject.org 4.1.4-100.fc21.x86_64 #1 SMP Tue Aug 4 03:25:05 UTC 2015 x86_64 BOOST_LIB_VERSION=1_53
2015-12-23T12:11:50.221+0100 [initandlisten] allocator: tcmalloc
2015-12-23T12:11:50.221+0100 [initandlisten] options: { command: [ "run" ], config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", unixDomainSocket: { pathPrefix: "/var/run/mongodb" } }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongodb" }, systemLog: { destination: "file", path: "/var/log/mongodb/mongod.log", quiet: true } }
2015-12-23T12:11:50.235+0100 [initandlisten] journal dir=/var/lib/mongodb/journal
2015-12-23T12:11:50.235+0100 [initandlisten] recover : no journal files present, no recovery needed
2015-12-23T12:11:51.759+0100 [initandlisten] preallocateIsFaster=true 13.14
2015-12-23T12:11:52.660+0100 [initandlisten] waiting for connections on port 27017

Die eben gemachte Konfigurationsberichtigung wird aber bei einem Reboot des Servers wieder verworfen. Wir müssen also dafür sorgen, dass der readahead-Wert bei einem Neustart des Systems auf den gewünschten Wert 256 gesetzt wird. Hierzu legen wir uns ein kleines Bash-Script an.

 #  vim /usr/local/bin/setra256
/usr/local/bin/setra256
#!/bin/bash
# Django : 2015-12-28
# Setzen des readahead Wertes auf 256KB (512 Sektoren)
/usr/sbin/blockdev --setra 256 /dev/vdc1

Nun müssen wir nur noch dafür sorgen, dass dieses Script bei einem Neustart gestartet wird. Dazu legen wir uns einen eigenen „kleinen Service“ an, in dem wir im Verzeichnis /etc/systemd/system/ eine systemd-Startscript anlegen.

 # vim /etc/systemd/system/setra256.service
/etc/systemd/system/setra256.service
[Unit]
Description=Initialize hardware monitoring sensors
After=syslog.target network.target
Before=mongod.service
 
[Service]
Type=oneshot
ExecStart=/usr/local/bin/setra256
 
[Install]
WantedBy=multi-user.target

Zu guter letzt führen wir noch einen Reload des Systemd-Daemon durch und wir haben künftig immer den richtig gesetzten readahead von 256 gesetzt.

 # systemctl daemon-reload

automatischer Start des Daemon

Damit der Daemon beim Hochfahren unseres Servers automatisch gestartet wird, nutzen wir folgenden Befehl.

 # systemctl enable mongod.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service.

Wollen wir wissen, ob die Autostartfunktion bereits gesetzt ist, verwenden wir diesen Aufruf.

 # systemctl is-enabled mongod.service
enabled

Datenbanknutzer anlegen

Wie bereits kurz erwähnt wollen wir unsere MongoDB absichern, indem wir einen Datenbakbenutzer mit Passwort anlegen. Dazu verbinden wir uns erst einmal mit der MongoDB Shell mongo.

 # mongo
MongoDB shell version: 2.6.11
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
> 

Zunächst wechseln wir zur Datenbank admin mit folgendem Aufruf.

> use admin
switched to db admin
>

Anschließend legen wir den Datenbankadministrator admin mit dem Passwort 5y510953rv3r53cr37 an.

> db.createUser({user:"admin",pwd:"5y510953rv3r53cr37",roles:[{role:"root",db:"admin"}]})
Successfully added user: {
        "user" : "admin",
        "roles" : [
                {
                        "role" : "root",
                        "db" : "admin"
                }
        ]
}
> 

Für den Zugriff von graylog auf die NoSQL-Datenbang MongoDB erstellen wir uns nun noch einen separaten Nutzer graylog-user mit dem zugehörigen Passwort 7h3FBI15n07ar0ckb4and. Bevor wir diesen Datenbank-Account anlegen, erstellen und wechseln wir noch zur Datenbank graylog.

> use graylog
switched to db graylog

Nun können wir auch unseren User graylog-user anlegen.

> db.createUser({user:"graylog-user",pwd:"7h3FBI15n07ar0ckb4and",roles:["readWrite"]})
Successfully added user: { "user" : "graylog-user", "roles" : [ "readWrite" ] }
> 

Wir haben die nötigen Definitionen erfolgreich zu Ende gebracht und nun können wir die MongoDB Shell mongo wieder verlassen.

> exit
bye

Zum Testen, ob unser Datenbanknutzer graylog-user sich auch erfolgreich mit der NoSQL-Datenbank graylog verbinden kann, melden wir uns mit dessen Daten an und fragen die vorhandenen Datenbanken ab.

 # mongo -u "graylog-user" -p "7h3FBI15n07ar0ckb4and" 127.0.0.1:27017/graylog
MongoDB shell version: 2.6.11
connecting to: 127.0.0.1:27017/test
> 

Die Tabellen der gewählten Datenbank kann man sich mit dem Befehl show collections anzeigen lassen.

> show collections
alarmcallbackconfigurations
alarmcallbackhistory
alerts
cluster_config
cluster_events
collectors
content_packs
dashboards
dead_letters
grok_patterns
index_failures
index_ranges
inputs
ldap_settings
nodes
notifications
roles
sessions
streamrules
streams
system.indexes
system_messages
users
>

Da der Zugriff klappte, können wir die Datenbankverbindung wieder beenden.

> exit
bye

Geben wir ein falsches Passwort ein, wird natürlich der Zugang verwehrt.

 # mongo -u "graylog-user" -p "7h3FBI15n07ar0ckb4and" 127.0.0.1:27017/graylog
MongoDB shell version: 2.6.11
connecting to: 127.0.0.1:27017/test
2015-12-23T13:08:02.381+0100 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1292
exception: login failed

Zum Abschluss unterbinden wir nun noch den Passwortlosen Zugang zur MongoDB. Der Parameter auth im Abschnitt General options der Konfigurationsdatei /etc/mongod.conf

 # vim /etc/mongod.conf
/etc/mongod.conf
##                                       
### Basic Defaults                       
##                                       
 
# Comma separated list of ip addresses to listen on (all local ips by default)
bind_ip = 127.0.0.1                                                           
 
# Specify port number (27017 by default)
#port = 27017                           
 
# Fork server process (false by default)
fork = true                             
 
# Full path to pidfile (if not set, no pidfile is created)
pidfilepath = /var/run/mongodb/mongod.pid                 
 
# Log file to send write to instead of stdout - has to be a file, not directory
logpath = /var/log/mongodb/mongod.log                                          
 
# Alternative directory for UNIX domain sockets (defaults to /tmp)
unixSocketPrefix = /var/run/mongodb                               
 
# Directory for datafiles (defaults to /data/db/)
dbpath = /var/lib/mongodb                        
 
# Enable/Disable journaling (journaling is on by default for 64 bit)
#journal = true                                                     
#nojournal = true                                                   
 
 
 
##
### General options
##                 
 
# Be more verbose (include multiple times for more verbosity e.g. -vvvvv) (v by default)
#verbose = v                                                                            
 
# Max number of simultaneous connections (1000000 by default)
#maxConns = 1000000                                          
 
# Log to system's syslog facility instead of file or stdout (false by default)
#syslog = true                                                                
 
# Syslog facility used for monogdb syslog message (user by defautl)
#syslogFacility = user                                             
 
# Append to logpath instead of over-writing (false by default)
#logappend = true                                             
 
# Desired format for timestamps in log messages (One of ctime, iso8601-utc or iso8601-local) (iso8601-local by default)
#timeStampFormat = arg                                                                                                 
 
# Private key for cluster authentication
#keyFile = arg                          
 
# Set a configurable parameter
#setParameter = arg           
 
# Enable http interface (false by default)
#httpinterface = true                     
 
# Authentication mode used for cluster authentication. Alternatives are (keyFile|sendKeyFile|sendX509|x509) (keyFile by default)
#clusterAuthMode = arg                                                                                                          
 
# Disable listening on unix sockets (false by default)
#nounixsocket = true                                  
 
# Run with/without security (without by default)
#auth = true                                    
#noauth = true                                  
# Django : 2015-12-23 - Passwortlose logins unterbinden
# default: #auth = true                                
#          #noauth = true                              
auth = true                                            
 
# Enable IPv6 support (disabled by default)
#ipv6 = true                               
 
# Allow JSONP access via http (has security implications) (false by default)
#jsonp = true                                                               
 
# Turn on simple rest api (false by default)
#rest = true                                
 
# Value of slow for profile and console log (100 by default)
#slowms = 100                                               
 
# 0=off 1=slow, 2=all (0 by default)
#profile = 0                        
 
# Periodically show cpu and iowait utilization (false by default)
#cpu = true                                                      
 
# Print some diagnostic system information (false by default)
#sysinfo = true                                              
 
# Each database will be stored in a separate directory (false by default)
#directoryperdb = true                                                   
 
# Don't retry any index builds that were interrupted by shutdown (false by default)
#noIndexBuildRetry = true                                                          
 
# Disable data file preallocation - will often hurt performance (false by default)
#noprealloc = true                                                                
 
# .ns file size (in MB) for new databases (16 MB by default)
#nssize = 16                                                
 
# Limits each database to a certain number of files (8 default)
#quota                                                         
 
# Number of files allowed per db, implies --quota (8 by default)
#quotaFiles = 8                                                 
 
# Use a smaller default file size (false by default)
#smallfiles = true                                  
 
# Seconds between disk syncs (0=never, but not recommended) (60 by default)
#syncdelay = 60                                                            
 
# Upgrade db if needed (false by default)
#upgrade = true                          
 
# Run repair on all dbs (false by default)
#repair = true                            
 
# Root directory for repair files (defaults to dbpath)
#repairpath = arg                                     
 
# Disable scripting engine (false by default)
#noscripting = true                          
 
# Do not allow table scans (false by default)
#notablescan = true                          
 
# Journal diagnostic options (0 by default)
#journalOptions = 0                        
 
# How often to group/batch commit (ms) (100 or 30 by default)
#journalCommitInterval = 100                                 
 
 
 
##
### Replication options
##                     
 
# Size to use (in MB) for replication op log (default 5% of disk space - i.e. large is good)
#oplogSize = arg                                                                            
 
 
 
##
### Master/slave options (old; use replica sets instead)
##                                                      
 
# Master mode
#master = true
 
# Slave mode
#slave = true
 
# When slave: specify master as <server:port>
#source = arg                                
 
# When slave: specify a single database to replicate
#only = arg                                         
 
# Specify delay (in seconds) to be used when applying master ops to slave
#slavedelay = arg                                                        
 
# Automatically resync if slave data is stale
#autoresync = true                           
 
 
 
##
### Replica set options
##                     
 
# Arg is <setname>[/<optionalseedhostlist>]
#replSet = arg
 
# Specify index prefetching behavior (if secondary) [none|_id_only|all] (all by default)
#replIndexPrefetch = all
 
 
 
##
### Sharding options
##
 
# Declare this is a config db of a cluster (default port 27019; default dir /data/configdb) (false by default)
#configsvr = true
 
# Declare this is a shard db of a cluster (default port 27018)  (false by default)
#shardsvr = true
 
 
 
##
### SSL options
##
 
# Use ssl on configured ports
#sslOnNormalPorts = true
 
# Set the SSL operation mode (disabled|allowSSL|preferSSL|requireSSL)
# sslMode = arg
 
# PEM file for ssl
#sslPEMKeyFile = arg
 
# PEM file password
#sslPEMKeyPassword = arg
 
# Key file for internal SSL authentication
#sslClusterFile = arg
 
# Internal authentication key file password
#sslClusterPassword = arg
 
# Certificate Authority file for SSL
#sslCAFile = arg
 
# Certificate Revocation List file for SSL
#sslCRLFile = arg
 
# Allow client to connect without presenting a certificate
#sslWeakCertificateValidation = true
 
# Allow server certificates to provide non-matching hostnames
#sslAllowInvalidHostnames = true
 
# Allow connections to servers with invalid certificates
#sslAllowInvalidCertificates = true
 
# Activate FIPS 140-2 mode at startup
#sslFIPSMode = true

Nun werden wir den MongoDB-Daemon einaml noch durchstarten, damit die durchgeführten Änderungen auch aktiv werden.

 # systemctl restart mongod.service

Ein Anmeldeversuch ohne Benutzerkennung samt Passwort ist ab sofort nicht mehr möglich.

In diesem Abschnitt werden wir nun den Suchserver elasticsearch, der auch die eigentlichen Nutztdaten von graylog vorhalten wird, konfigurieren.

In der Dokumentation von graylog im Abschnitt Architectural considerations finden wir folgenden Hinweis:


Elasticsearch nodes should have as much RAM as possible and the fastest disks you can get. Everything depends on I/O speed here.

Diesem Vorschlag wollen wir nun in die Tat umsetzen. Beim Blockdevice haben wir in unserem Konfigurationsbeispiel bereits ein RAID aus schnellen Server-SSD's verwendet. Nun werden wir dem elasticsearch-Daemon noch mehr an RAM zugestehen. Hierzu werden wir nun den Parameter vm.max_map_count anpassen. Zunächst aber fragen wird den aktuellen Wert von vm.max_map_count erst einmal ab.

 # sysctl vm.max_map_count
vm.max_map_count = 65530

In der Dokumentation von elasticsearch zum virtuellen Speicherverbrauch wird empfohlen, den großzügigen Wert von 262144 zu setzen. Während der Laufzeit des Systems können wir die Änderung mit folgendem Befehl vornehmen.

 # sysctl -w vm.max_map_count=262144
vm.max_map_count = 262144

Damit die Werteanpassung resetfest, also bei jedem Neustart des Servers auf den gewünschten Wert gesetzt wird, bearbeiten wir die Datei /etc/sysctl.conf.

 # vim /etc/sysctl.conf
/etc/sysctl.conf
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
#
# Django : 2015-12-23 - den virtuellen Speicherverbrauch von elasticsearch anpassen
vm.max_map_count=262144

elasticsearch.yml

Laut der Installationsdokumentation von graylog beschränkt sich die Konfiguration von elasticsearch auf das Setzen des cluster name. Den Node Name setzen wir im dem Zuge auf den Hoastname unseres Syslog-Servers.

The only important thing for Elasticsearch is that you set the exactly same cluster name (e. g. ``cluster.name: graylog``) that is being used by Graylog in the Elasticsearch configuration (``conf/elasticsearch.yml``).

Da aber in der Dokumentation Setup Configuration werden wir noch den Parameter mlockall auf true setzen.

 # vim /etc/elasticsearch/elasticsearch.yml
/etc/elasticsearch/elasticsearch.yml
##################### Elasticsearch Configuration Example #####################                                  
 
# This file contains an overview of various configuration settings,
# targeted at operations staff. Application developers should      
# consult the guide at <http://elasticsearch.org/guide>.           
#                                                                  
# The installation procedure is covered at                         
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/setup.html>.
#                                                                                
# Elasticsearch comes with reasonable defaults for most settings,                
# so you can try it out without bothering with configuration.                    
#                                                                                
# Most of the time, these defaults are just fine for running a production        
# cluster. If you're fine-tuning your cluster, or wondering about the            
# effect of certain configuration option, please _do ask_ on the                 
# mailing list or IRC channel [http://elasticsearch.org/community].              
 
# Any element in the configuration can be replaced with environment variables
# by placing them in ${...} notation. For example:                           
#                                                                            
#node.rack: ${RACK_ENV_VAR}                                                  
 
# For information on supported formats and syntax for the config file, see
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/setup-configuration.html>
 
 
################################### Cluster ###################################
 
# Cluster name identifies your cluster for auto-discovery. If you're running
# multiple clusters on the same network, make sure you're using unique names.
#                                                                            
# Django : 2015-12-28                                                        
# default: #cluster.name: elasticsearch                                      
cluster.name: graylog                                                        
 
 
#################################### Node #####################################
 
# Node names are generated dynamically on startup, so you're relieved
# from configuring them manually. You can tie this node to a specific name:
#                                                                          
# Django : 2015-12-28                                                      
# default: #node.name: "Franz Kafka"                                       
node.name: vml000117                                                       
 
# Every node can be configured to allow or deny being eligible as the master,
# and to allow or deny to store the data.                                    
#                                                                            
# Allow this node to be eligible as a master node (enabled by default):      
#                                                                            
#node.master: true                                                           
#                                                                            
# Allow this node to store data (enabled by default):                        
#                                                                            
#node.data: true                                                             
 
# You can exploit these settings to design advanced cluster topologies.
#                                                                      
# 1. You want this node to never become a master node, only to hold data.
#    This will be the "workhorse" of your cluster.                       
#                                                                        
#node.master: false                                                      
#node.data: true                                                         
#                                                                        
# 2. You want this node to only serve as a master: to not store any data and
#    to have free resources. This will be the "coordinator" of your cluster.
#                                                                           
#node.master: true                                                          
#node.data: false                                                           
#                                                                           
# 3. You want this node to be neither master nor data node, but             
#    to act as a "search load balancer" (fetching data from nodes,          
#    aggregating results, etc.)                                             
#                                                                           
#node.master: false                                                         
#node.data: false                                                           
 
# Use the Cluster Health API [http://localhost:9200/_cluster/health], the
# Node Info API [http://localhost:9200/_nodes] or GUI tools              
# such as <http://www.elasticsearch.org/overview/marvel/>,               
# <http://github.com/karmi/elasticsearch-paramedic>,                     
# <http://github.com/lukas-vlcek/bigdesk> and                            
# <http://mobz.github.com/elasticsearch-head> to inspect the cluster state.
 
# A node can have generic attributes associated with it, which can later be used
# for customized shard allocation filtering, or allocation awareness. An attribute
# is a simple key value pair, similar to node.key: value, here is an example:     
#                                                                                 
#node.rack: rack314                                                               
 
# By default, multiple nodes are allowed to start from the same installation location
# to disable it, set the following:                                                  
#node.max_local_storage_nodes: 1                                                     
 
 
#################################### Index ####################################
 
# You can set a number of options (such as shard/replica options, mapping
# or analyzer definitions, translog settings, ...) for indices globally, 
# in this file.                                                          
#                                                                        
# Note, that it makes more sense to configure index settings specifically for
# a certain index, either when creating it or by using the index templates API.
#                                                                              
# See <http://elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules.html> and
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html> 
# for more information.                                                                         
 
# Set the number of shards (splits) of an index (5 by default):
#                                                              
#index.number_of_shards: 5                                     
 
# Set the number of replicas (additional copies) of an index (1 by default):
#                                                                           
#index.number_of_replicas: 1                                                
 
# Note, that for development on a local machine, with small indices, it usually
# makes sense to "disable" the distributed features:                           
#                                                                              
#index.number_of_shards: 1                                                     
#index.number_of_replicas: 0                                                   
 
# These settings directly affect the performance of index and search operations
# in your cluster. Assuming you have enough machines to hold shards and        
# replicas, the rule of thumb is:                                              
#                                                                              
# 1. Having more *shards* enhances the _indexing_ performance and allows to    
#    _distribute_ a big index across machines.                                 
# 2. Having more *replicas* enhances the _search_ performance and improves the 
#    cluster _availability_.                                                   
#                                                                              
# The "number_of_shards" is a one-time setting for an index.                   
#                                                                              
# The "number_of_replicas" can be increased or decreased anytime,              
# by using the Index Update Settings API.                                      
#                                                                              
# Elasticsearch takes care about load balancing, relocating, gathering the     
# results from nodes, etc. Experiment with different settings to fine-tune     
# your setup.                                                                  
 
# Use the Index Status API (<http://localhost:9200/A/_status>) to inspect
# the index status.                                                      
 
 
#################################### Paths ####################################
 
# Path to directory containing configuration (this file and logging.yml):
#                                                                        
#path.conf: /path/to/conf                                                
 
# Path to directory where to store index data allocated for this node.
#                                                                     
#path.data: /path/to/data                                             
#                                                                     
# Can optionally include more than one location, causing data to be striped across
# the locations (a la RAID 0) on a file level, favouring locations with most free 
# space on creation. For example:                                                 
#                                                                                 
#path.data: /path/to/data1,/path/to/data2                                         
 
# Path to temporary files:
#                         
#path.work: /path/to/work 
 
# Path to log files:
#                   
#path.logs: /path/to/logs
 
# Path to where plugins are installed:
#                                     
#path.plugins: /path/to/plugins       
 
 
#################################### Plugin ###################################
 
# If a plugin listed here is not installed for current node, the node will not start.
#                                                                                    
#plugin.mandatory: mapper-attachments,lang-groovy                                    
 
 
################################### Memory ####################################
 
# Elasticsearch performs poorly when JVM starts swapping: you should ensure that
# it _never_ swaps.                                                             
#                                                                               
# Set this property to true to lock the memory:                                 
#                                                                               
# Django : 2015-12-28                                                           
# default: unset                                                                
bootstrap.mlockall: true                                                        
 
 
# Make sure that the ES_MIN_MEM and ES_MAX_MEM environment variables are set
# to the same value, and that the machine has enough memory to allocate     
# for Elasticsearch, leaving enough memory for the operating system itself. 
#                                                                           
# You should also make sure that the Elasticsearch process is allowed to lock
# the memory, eg. by using `ulimit -l unlimited`.                            
 
 
############################## Network And HTTP ###############################
 
# Elasticsearch, by default, binds itself to the 0.0.0.0 address, and listens
# on port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node
# communication. (the range means that if the port is busy, it will automatically
# try the next port).                                                            
 
# Set the bind address specifically (IPv4 or IPv6):
#                                                  
#network.bind_host: 192.168.0.1                    
 
# Set the address other nodes will use to communicate with this node. If not
# set, it is automatically derived. It must point to an actual IP address.  
#                                                                           
#network.publish_host: 192.168.0.1                                          
 
# Set both 'bind_host' and 'publish_host':
#                                         
#network.host: 192.168.0.1                
 
# Set a custom port for the node to node communication (9300 by default):
#                                                                        
#transport.tcp.port: 9300                                                
 
# Enable compression for all communication between nodes (disabled by default):
#                                                                              
#transport.tcp.compress: true                                                  
 
# Set a custom port to listen for HTTP traffic:
#                                              
#http.port: 9200                               
 
# Set a custom allowed content length:
#                                     
#http.max_content_length: 100mb       
 
# Disable HTTP completely:
#                         
#http.enabled: false      
 
 
################################### Gateway ###################################
 
# The gateway allows for persisting the cluster state between full cluster
# restarts. Every change to the state (such as adding an index) will be stored
# in the gateway, and when the cluster starts up for the first time,          
# it will read its state from the gateway.                                    
 
# There are several types of gateway implementations. For more information, see
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/modules-gateway.html>.
 
# The default gateway type is the "local" gateway (recommended):
#                                                               
#gateway.type: local                                            
 
# Settings below control how and when to start the initial recovery process on
# a full cluster restart (to reuse as much local data as possible when using shared
# gateway).                                                                        
 
# Allow recovery process after N nodes in a cluster are up:
#                                                          
#gateway.recover_after_nodes: 1                            
 
# Set the timeout to initiate the recovery process, once the N nodes
# from previous setting are up (accepts time value):                
#                                                                   
#gateway.recover_after_time: 5m                                     
 
# Set how many nodes are expected in this cluster. Once these N nodes
# are up (and recover_after_nodes is met), begin recovery process immediately
# (without waiting for recover_after_time to expire):                        
#                                                                            
#gateway.expected_nodes: 2                                                   
 
 
############################# Recovery Throttling #############################
 
# These settings allow to control the process of shards allocation between
# nodes during initial recovery, replica allocation, rebalancing,         
# or when adding and removing nodes.                                      
 
# Set the number of concurrent recoveries happening on a node:
#                                                             
# 1. During the initial recovery                              
#                                                             
#cluster.routing.allocation.node_initial_primaries_recoveries: 4
#                                                               
# 2. During adding/removing nodes, rebalancing, etc             
#                                                               
#cluster.routing.allocation.node_concurrent_recoveries: 2       
 
# Set to throttle throughput when recovering (eg. 100mb, by default 20mb):
#                                                                         
#indices.recovery.max_bytes_per_sec: 20mb                                 
 
# Set to limit the number of open concurrent streams when
# recovering a shard from a peer:                        
#                                                        
#indices.recovery.concurrent_streams: 5                  
 
 
################################## Discovery ##################################
 
# Discovery infrastructure ensures nodes can be found within a cluster
# and master node is elected. Multicast discovery is the default.     
 
# Set to ensure a node sees N other master eligible nodes to be considered
# operational within the cluster. This should be set to a quorum/majority of 
# the master-eligible nodes in the cluster.                                  
#                                                                            
#discovery.zen.minimum_master_nodes: 1                                       
 
# Set the time to wait for ping responses from other nodes when discovering.
# Set this option to a higher value on a slow or congested network          
# to minimize discovery failures:                                           
#                                                                           
#discovery.zen.ping.timeout: 3s                                             
 
# For more information, see
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/modules-discovery-zen.html>
 
# Unicast discovery allows to explicitly control which nodes will be used
# to discover the cluster. It can be used when multicast is not present, 
# or to restrict the cluster communication-wise.                         
#                                                                        
# 1. Disable multicast discovery (enabled by default):                   
#                                                                        
#discovery.zen.ping.multicast.enabled: false                             
# Django : 2015-12-28                                                    
# default: "enabled by default"                                          
discovery.zen.ping.multicast.enabled: false                              
 
#
# 2. Configure an initial list of master nodes in the cluster
#    to perform discovery when new nodes (master or data) are started:
#                                                                     
#discovery.zen.ping.unicast.hosts: ["host1", "host2:port"]            
# Django : 2015-12-28                                                 
# default: unset                                                      
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"]                  
 
 
# EC2 discovery allows to use AWS EC2 API in order to perform discovery.
#
# You have to install the cloud-aws plugin for enabling the EC2 discovery.
#
# For more information, see
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/modules-discovery-ec2.html>
#
# See <http://elasticsearch.org/tutorials/elasticsearch-on-ec2/>
# for a step-by-step tutorial.
 
# GCE discovery allows to use Google Compute Engine API in order to perform discovery.
#
# You have to install the cloud-gce plugin for enabling the GCE discovery.
#
# For more information, see <https://github.com/elasticsearch/elasticsearch-cloud-gce>.
 
# Azure discovery allows to use Azure API in order to perform discovery.
#
# You have to install the cloud-azure plugin for enabling the Azure discovery.
#
# For more information, see <https://github.com/elasticsearch/elasticsearch-cloud-azure>.
 
################################## Slow Log ##################################
 
# Shard level query and fetch threshold logging.
 
#index.search.slowlog.threshold.query.warn: 10s
#index.search.slowlog.threshold.query.info: 5s
#index.search.slowlog.threshold.query.debug: 2s
#index.search.slowlog.threshold.query.trace: 500ms
 
#index.search.slowlog.threshold.fetch.warn: 1s
#index.search.slowlog.threshold.fetch.info: 800ms
#index.search.slowlog.threshold.fetch.debug: 500ms
#index.search.slowlog.threshold.fetch.trace: 200ms
 
#index.indexing.slowlog.threshold.index.warn: 10s
#index.indexing.slowlog.threshold.index.info: 5s
#index.indexing.slowlog.threshold.index.debug: 2s
#index.indexing.slowlog.threshold.index.trace: 500ms
 
################################## GC Logging ################################
 
#monitor.jvm.gc.young.warn: 1000ms
#monitor.jvm.gc.young.info: 700ms
#monitor.jvm.gc.young.debug: 400ms
 
#monitor.jvm.gc.old.warn: 10s
#monitor.jvm.gc.old.info: 5s
#monitor.jvm.gc.old.debug: 2s
 
################################## Security ################################
 
# Uncomment if you want to enable JSONP as a valid return transport on the
# http server. With this enabled, it may pose a security risk, so disabling
# it unless you need it is recommended (it is disabled by default).
#
#http.jsonp.enable: true

elasticsearch.service

Damit Parameter bootstrap.mlockall auch richtig gesetzt werden kann, ist noch eine Änderung an dem Systemd-Startscript notwendig! Dieses werden wir nun noch anpassen; hierzu kopieren wir uns nun das entsprechende Script nach /etc/systemd/system/.

 # cp -a /usr/lib/systemd/system/elasticsearch.service /etc/systemd/system/

In dieser Datei setzen wir den Parameter LimitMEMLOCK auf infinity.

 # vim /etc/systemd/system/elasticsearch.service
/etc/systemd/system/elasticsearch.service
[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target
 
[Service]
Environment=ES_HOME=/usr/share/elasticsearch
Environment=CONF_DIR=/etc/elasticsearch
Environment=CONF_FILE=/etc/elasticsearch/elasticsearch.yml
Environment=DATA_DIR=/var/lib/elasticsearch
Environment=LOG_DIR=/var/log/elasticsearch
Environment=PID_DIR=/var/run/elasticsearch
EnvironmentFile=-/etc/sysconfig/elasticsearch
 
User=elasticsearch
Group=elasticsearch
 
ExecStart=/usr/share/elasticsearch/bin/elasticsearch \
                                                -Des.pidfile=$PID_DIR/elasticsearch.pid \
                                                -Des.default.path.home=$ES_HOME \
                                                -Des.default.path.logs=$LOG_DIR \
                                                -Des.default.path.data=$DATA_DIR \
                                                -Des.default.config=$CONF_FILE \
                                                -Des.default.path.conf=$CONF_DIR
 
# Connects standard output to /dev/null
StandardOutput=null
 
# Connects standard error to journal
StandardError=journal
 
# When a JVM receives a SIGTERM signal it exits with code 143
SuccessExitStatus=143
 
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65535
 
# Specifies the maximum number of bytes of memory that may be locked into RAM
# Set to "infinity" if you use the 'bootstrap.mlockall: true' option
# in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in /etc/sysconfig/elasticsearch
# Django : 2015-12-28
# default: # LimitMEMLOCK=infinity
LimitMEMLOCK=infinity
 
# Shutdown delay in seconds, before process is tried to be killed with KILL (if configured)
TimeoutStopSec=20
 
[Install]
WantedBy=multi-user.target
 
# Built for elasticsearch-1.7.4 (rpm)

Anschließend informieren wir den systemd über unser „updatesicheres“ Startscript.

 systemctl daemon-reload

Start des Daemon

Unsere Konfigurationsänderungen werden mit Hilfe von mongo der MongoDB Shell vorgenommen. Dieses JavaScript stellt die Benutzerschnittstelle zum eigentlichen MongoDN-Daemon zur Verfügung. Damit sich der Client mit dem Server auch verbinden kann, muss der Server natürlich laufen; wir starten also nun unsere NoSQL-Datenbank mit folgendem Befehl.

 # systemctl start mongod.service

Den Serverstatus können wir wie folgt abfragen.

 # systemctl status mongod.service

elasticsearch.service - Elasticsearch
   Loaded: loaded (/etc/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2015-12-28 14:20:23 CET; 1min 56s ago
     Docs: http://www.elastic.co
 Main PID: 32221 (java)
   CGroup: /system.slice/elasticsearch.service
           └─32221 /bin/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupan...

Dec 28 14:20:23 vml000117.dmz.nausch.org systemd[1]: Started Elasticsearch.
Dec 28 14:20:23 vml000117.dmz.nausch.org systemd[1]: Starting Elasticsearch...

Der erfolgreiche Start des Servers wird auch in dessen Logdatei protokolliert.

 # /var/log/elasticsearch/elasticsearch.log
[2015-12-28 14:20:24,201][INFO ][node                     ] [vml000117] version[1.7.4], pid[32221], build[0d3159b/2015-12-15T16:45:04Z]
[2015-12-28 14:20:24,202][INFO ][node                     ] [vml000117] initializing ...
[2015-12-28 14:20:24,323][INFO ][plugins                  ] [vml000117] loaded [], sites []
[2015-12-28 14:20:24,378][INFO ][env                      ] [vml000117] using [1] data paths, mounts [[/var/lib/elasticsearch (/dev/vdc1)]], net usable_space [24.3gb], net total_space [24.4gb], types [xfs]
[2015-12-28 14:20:29,846][INFO ][node                     ] [vml000117] initialized
[2015-12-28 14:20:29,846][INFO ][node                     ] [vml000117] starting ...
[2015-12-28 14:20:30,282][INFO ][transport                ] [vml000117] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/10.0.0.117:9300]}
[2015-12-28 14:20:30,352][INFO ][discovery                ] [vml000117] graylog/EdAnadZuTiOjxFR7_Kvdrg
[2015-12-28 14:20:33,462][INFO ][cluster.service          ] [vml000117] new_master [vml000117][EdAnadZuTiOjxFR7_Kvdrg][vml000117.dmz.nausch.org][inet[/10.0.0.117:9300]], reason: zen-disco-join (elected_as_master)
[2015-12-28 14:20:33,508][INFO ][http                     ] [vml000117] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/10.0.0.117:9200]}
[2015-12-28 14:20:33,508][INFO ][node                     ] [vml000117] started
[2015-12-28 14:20:33,541][INFO ][gateway                  ] [vml000117] recovered [0] indices into cluster_state
[2015-12-28 14:20:35,573][INFO ][cluster.service          ] [vml000117] added {[vml000117][4u6LKkewT-ClHj25SjY5gA][vml000117.dmz.nausch.org][inet[/10.0.0.117:9350]]{client=true, data=false, master=false},}, reason: zen-disco-receive(join from node[[vml000117][4u6LKkewT-ClHj25SjY5gA][vml000117.dmz.nausch.org][inet[/10.0.0.117:9350]]{client=true, data=false, master=false}])
[2015-12-28 14:20:44,296][INFO ][cluster.metadata         ] [vml000117] [graylog_0] creating index, cause [api], templates [graylog-internal], shards [1]/[0], mappings [message]
[2015-12-28 14:20:44,959][INFO ][cluster.metadata         ] [vml000117] [graylog_1] creating index, cause [api], templates [graylog-internal], shards [1]/[0], mappings [message]

automatischer Start des Daemon

Damit der Daemon beim Hochfahren unseres Servers automatisch gestartet wird, nutzen wir folgenden Befehl.

 # systemctl enable elasticsearch.service
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.

Wollen wir wissen, ob die Autostartfunktion bereits gesetzt ist, verwenden wir diesen Aufruf.

 # systemctl is-enabled elasticsearch.service
enabled

Test

Zum Testen unserer Konfigurationseinstellungen nutzen wir die Nodes Info API.

 # curl localhost:9200/_nodes/process?pretty
{
  "cluster_name" : "graylog",
  "nodes" : {
    "EdAnadZuTiOjxFR7_Kvdrg" : {
      "name" : "vml000117",
      "transport_address" : "inet[/10.0.0.117:9300]",
      "host" : "vml000117.dmz.nausch.org",
      "ip" : "10.0.0.117",
      "version" : "1.7.4",
      "build" : "0d3159b",
      "http_address" : "inet[/10.0.0.117:9200]",
      "process" : {
        "refresh_interval_in_millis" : 1000,
        "id" : 32221,
        "max_file_descriptors" : 65535,
        "mlockall" : true
      }
    }
  }
}

Den Zustand des elastic-Servers kann man sich mit folgendem Aufruf anzeigen lassen.

 # curl localhost:9200/_cluster/health?pretty
{
  "cluster_name" : "graylog",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 2,
  "active_shards" : 2,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0
}

Nachdem wir alle Vorbereitungen erfolgreich abgeschlossen haben, können wir uns nun der Konfiguration des graylog-server Daemons widmen.

/etc/sysconfig/graylog-server

Auf unserem System unter CentOS 7.x hatten wir als JAVA Runtime Enviroment das Paket openjdk in der Version 1.8 installiert. Ab Version 1.8 werden die beiden Parameter PermSize und MaxPermSize nicht mehr unterstützt. Wir werden daher in der Konfigurationsdatei /etc/sysconfig/graylog-server diese beiden Parameter bei den GRAYLOG_SERVERGRAYLOG_SERVER_JAVA_OPTS entfernen.

 # vim /etc/sysconfig/graylog-server
/etc/sysconfig/graylog-server
# Path to the java executable.
JAVA=/usr/bin/java
 
# Default Java options for heap and garbage collection.
#
# Django : 2015-12-28 - PermSize und MaxPermSize werden ab openjdk-1.8.0 nicht mehr unterstützt
# default: GRAYLOG_SERVER_JAVA_OPTS="-Xms1g -Xmx1g -XX:NewRatio=1 -XX:PermSize=128m -XX:MaxPermSize=256m -server -XX:+ResizeTLAB -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC -XX:-OmitStackTraceInFastThrow"
GRAYLOG_SERVER_JAVA_OPTS="-Xms1g -Xmx1g -XX:NewRatio=1 -server -XX:+ResizeTLAB -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC -XX:-OmitStackTraceInFastThrow"
 
# Pass some extra args to graylog-server. (i.e. "-d" to enable debug mode)
GRAYLOG_SERVER_ARGS=""
 
# Program that will be used to wrap the graylog-server command. Useful to
# support programs like authbind.
GRAYLOG_COMMAND_WRAPPER=""

/etc/graylog/server/server.conf

Die eigentliche Konfiguration unseres graylog-Servers wird in dessen Konfigurationsdatei /etc/graylog/server/server.conf vorgenommen.

Bevor wir diese öffnen und bearbeiten, erstellen wir uns noch zwei Dinge:

  1. Passwort-Hash
    Mit Hilfe des Passwort-Hash werden die Nutzerpassworte verschlüsselt. Diesen hash-Wert erstellen wir wie folgt:
     # pwgen -N 1 -s 128
    yCWAd48fvOmR7xAmcKezZ2C0v3mtaXCJjA7NfhBlSf98PTxHrf9SrCQDX2xgjCzrHpxoV5UNOEfQZsOP1gkWkYlDarD75tbtztPhR59O70yZchaJcyQTeHBZllQc8RcT
  2. Admin-Passwort
    Der administrative Benutzer admin benötigt noch ein zugehöriges Passwort, erzeugen wir nun mit folgendem Befehl.
    # echo -n N3v3r7ru57Y0URg0v3rnm3n7 | sha256sum
    38337fd07fd4ee02548053d7bed3ee33e3e0c593c2802941e2349fc52e80b98d  -

Diese beiden Werte hinterlegen wir nun in der Konfigurationsdatei unseres graylog-Daemon und passen anschließend die Konfigurationsoptionen unserer Umgebung an. Änderungen an den Default-Werten sind mit Django : <Zeitstempel> gekennzeichnet

 # vim /etc/graylog/server/server.conf
/etc/graylog/server/server.conf
# If you are running more than one instances of graylog2-server you have to select one of these
# instances as master. The master will perform some periodical tasks that non-masters won't perform.
is_master = true                                                                                    
 
# The auto-generated node ID will be stored in this file and read after restarts. It is a good idea
# to use an absolute file path here if you are starting graylog2-server from init scripts or similar.
node_id_file = /etc/graylog/server/node-id                                                           
 
# You MUST set a secret to secure/pepper the stored user passwords here. Use at least 64 characters.
# Generate one by using for example: pwgen -N 1 -s 96                                               
# Django : 2015-12-28                                                                               
# default: password_secret =                                                                        
password_secret = yCWAd48fvOmR7xAmcKezZ2C0v3mtaXCJjA7NfhBlSf98PTxHrf9SrCQDX2xgjCzrHpxoV5UNOEfQZsOP1gkWkYlDarD75tbtztPhR59O70yZchaJcyQTeHBZllQc8RcT
 
# The default root user is named 'admin'
# Django : 2015-12-28                   
# default: #root_username = admin       
root_username = admin                   
 
# You MUST specify a hash password for the root user (which you only need to initially set up the
# system and in case you lose connectivity to your authentication backend)                       
# This password cannot be changed using the API or via the web interface. If you need to change it,
# modify it in this file.                                                                          
# Create one by using for example: echo -n yourpassword | shasum -a 256                            
# and put the resulting hash value into the following line                                         
# Django : 2015-12-28                                                                              
# default: root_password_sha2 =                                                                    
root_password_sha2 = 38337fd07fd4ee02548053d7bed3ee33e3e0c593c2802941e2349fc52e80b98d     
 
# The email address of the root user.
# Default is empty                   
# Django : 2015-12-28                
# default: #root_email = ""          
root_email = "graylog_admin@nausch.org"
 
# The time zone setting of the root user.
# The configured time zone must be parseable by http://www.joda.org/joda-time/apidocs/org/joda/time/DateTimeZone.html#forID-java.lang.String-
# Default is UTC                                                                                                                             
# Django : 2015-12-28                                                                                                                        
# default: #root_timezone = UTC                                                                                                              
root_timezone = Europe/Berlin                                                                                                                
 
# Set plugin directory here (relative or absolute)
plugin_dir = /usr/share/graylog-server/plugin     
 
# REST API listen URI. Must be reachable by other graylog2-server nodes if you run a cluster.
rest_listen_uri = http://127.0.0.1:12900/                                                    
 
# REST API transport address. Defaults to the value of rest_listen_uri. Exception: If rest_listen_uri
# is set to a wildcard IP address (0.0.0.0) the first non-loopback IPv4 system address is used.      
# If set, his will be promoted in the cluster discovery APIs, so other nodes may try to connect on   
# this address and it is used to generate URLs addressing entities in the REST API. (see rest_listen_uri)
# You will need to define this, if your Graylog server is running behind a HTTP proxy that is rewriting  
# the scheme, host name or URI.                                                                          
#rest_transport_uri = http://192.168.1.1:12900/                                                          
# Django : 2015-12-28                                                                                    
# default: unset                                                                                         
rest_transport_uri = http://127.0.0.1:12900/                                                             
 
# Enable CORS headers for REST API. This is necessary for JS-clients accessing the server directly.
# If these are disabled, modern browsers will not be able to retrieve resources from the server.   
# This is disabled by default. Uncomment the next line to enable it.                               
#rest_enable_cors = true                                                                           
# Django : 2015-12-28                                                                              
# default: unset                                                                                   
rest_enable_cors = true                                                                            
 
# Enable GZIP support for REST API. This compresses API responses and therefore helps to reduce
# overall round trip times. This is disabled by default. Uncomment the next line to enable it. 
#rest_enable_gzip = true                                                                       
# Django : 2015-12-28                                                                          
# default: unset                                                                               
rest_enable_gzip = true                                                                        
 
# Enable HTTPS support for the REST API. This secures the communication with the REST API with
# TLS to prevent request forgery and eavesdropping. This is disabled by default. Uncomment the
# next line to enable it.                                                                     
#rest_enable_tls = true                                                                       
 
# The X.509 certificate file to use for securing the REST API.
#rest_tls_cert_file = /path/to/graylog2.crt                   
 
# The private key to use for securing the REST API.
#rest_tls_key_file = /path/to/graylog2.key         
 
# The password to unlock the private key used for securing the REST API.
#rest_tls_key_password = secret                                         
 
# The maximum size of a single HTTP chunk in bytes.
#rest_max_chunk_size = 8192                        
 
# The maximum size of the HTTP request headers in bytes.
#rest_max_header_size = 8192                            
 
# The maximal length of the initial HTTP/1.1 line in bytes.
#rest_max_initial_line_length = 4096                       
 
# The size of the execution handler thread pool used exclusively for serving the REST API.
#rest_thread_pool_size = 16                                                               
 
# The size of the worker thread pool used exclusively for serving the REST API.
#rest_worker_threads_max_pool_size = 16                                        
 
# Embedded Elasticsearch configuration file
# pay attention to the working directory of the server, maybe use an absolute path here
#elasticsearch_config_file = /etc/graylog/server/elasticsearch.yml                     
 
# Graylog will use multiple indices to store documents in. You can configured the strategy it uses to determine
# when to rotate the currently active write index.                                                             
# It supports multiple rotation strategies:                                                                    
#   - "count" of messages per index, use elasticsearch_max_docs_per_index below to configure                   
#   - "size" per index, use elasticsearch_max_size_per_index below to configure                                
# valid values are "count", "size" and "time", default is "count"                                              
# Django : 2015-12-28                                                                                          
# default: rotation_strategy = count                                                                           
rotation_strategy = time                                                                                       
 
# (Approximate) maximum number of documents in an Elasticsearch index before a new index
# is being created, also see no_retention and elasticsearch_max_number_of_indices.      
# Configure this if you used 'rotation_strategy = count' above.                         
# Django : 2015-12-28                                                                   
# default: elasticsearch_max_docs_per_index = 20000000                                  
 
# (Approximate) maximum size in bytes per Elasticsearch index on disk before a new index is being created, also see
# no_retention and elasticsearch_max_number_of_indices. Default is 1GB.                                            
# Configure this if you used 'rotation_strategy = size' above.                                                     
#elasticsearch_max_size_per_index = 1073741824                                                                     
 
# (Approximate) maximum time before a new Elasticsearch index is being created, also see
# no_retention and elasticsearch_max_number_of_indices. Default is 1 day.               
# Configure this if you used 'rotation_strategy = time' above.                          
# Please note that this rotation period does not look at the time specified in the received messages, but is
# using the real clock value to decide when to rotate the index!                                            
# Specify the time using a duration and a suffix indicating which unit you want:                            
#  1w  = 1 week                                                                                             
#  1d  = 1 day                                                                                              
#  12h = 12 hours                                                                                           
# Permitted suffixes are: d for day, h for hour, m for minute, s for second.                                
#elasticsearch_max_time_per_index = 1d                                                                      
# Django : 2015-12-28                                                                                       
# default: unset                                                                                            
elasticsearch_max_time_per_index = 1d                                                                       
 
# Disable checking the version of Elasticsearch for being compatible with this Graylog release.
# WARNING: Using Graylog with unsupported and untested versions of Elasticsearch may lead to data loss!
#elasticsearch_disable_version_check = true                                                            
 
# Disable message retention on this node, i. e. disable Elasticsearch index rotation.
#no_retention = false                                                                
 
# How many indices do you want to keep?
# Django : 2015-12-28                  
# default: elasticsearch_max_number_of_indices = 20
elasticsearch_max_number_of_indices = 30           
 
# Decide what happens with the oldest indices when the maximum number of indices is reached.
# The following strategies are availble:                                                    
#   - delete # Deletes the index completely (Default)                                       
#   - close # Closes the index and hides it from the system. Can be re-opened later.        
retention_strategy = delete                                                                 
 
# How many Elasticsearch shards and replicas should be used per index? Note that this only applies to newly created indices.
# Django : 2015-12-28                                                                                                       
# default: elasticsearch_shards = 4                                                                                         
elasticsearch_shards = 1                                                                                                    
elasticsearch_replicas = 0                                                                                                  
 
 
# Prefix for all Elasticsearch indices and index aliases managed by Graylog.
# Django : 2015-12-28                                                       
# default: elasticsearch_index_prefix = graylog2                            
elasticsearch_index_prefix = graylog                                        
 
# Name of the Elasticsearch index template used by Graylog to apply the mandatory index mapping.
# # Default: graylog-internal                                                                   
#elasticsearch_template_name = graylog-internal                                                 
 
# Do you want to allow searches with leading wildcards? This can be extremely resource hungry and should only
# be enabled with care. See also: https://www.graylog.org/documentation/general/queries/                     
allow_leading_wildcard_searches = false                                                                      
 
# Do you want to allow searches to be highlighted? Depending on the size of your messages this can be memory hungry and
# should only be enabled after making sure your Elasticsearch cluster has enough memory.                               
allow_highlighting = false                                                                                             
 
# settings to be passed to elasticsearch's client (overriding those in the provided elasticsearch_config_file)
# all these                                                                                                   
# this must be the same as for your Elasticsearch cluster                                                     
#elasticsearch_cluster_name = graylog2                                                                        
# Django : 2015-12-28                                                                                         
# default: unset                                                                                              
elasticsearch_cluster_name = graylog                                                                          
 
# you could also leave this out, but makes it easier to identify the graylog2 client instance
#elasticsearch_node_name = graylog2-server                                                   
# Django : 2015-12-28                                                                        
# default: unset                                                                             
elasticsearch_node_name = vml000117                                                          
 
# we don't want the graylog2 server to store any data, or be master node
# Django : 2015-12-28                                                   
# default: #elasticsearch_node_master = false                           
#          #elasticsearch_node_data = false                             
elasticsearch_node_master = false                                       
elasticsearch_node_data = false                                         
 
# use a different port if you run multiple Elasticsearch nodes on one machine
#elasticsearch_transport_tcp_port = 9350                                     
 
# we don't need to run the embedded HTTP server here
# Django : 2015-12-28                               
# default: #elasticsearch_http_enabled = false      
elasticsearch_http_enabled = false                  
 
# Django : 2015-12-28
# default: #elasticsearch_discovery_zen_ping_multicast_enabled = false
elasticsearch_discovery_zen_ping_multicast_enabled = false            
 
# Django : 2015-12-28
# default: #elasticsearch_discovery_zen_ping_unicast_hosts = 127.0.0.1:9300
elasticsearch_discovery_zen_ping_unicast_hosts = 127.0.0.1:9300            
 
# Change the following setting if you are running into problems with timeouts during Elasticsearch cluster discovery.
# The setting is specified in milliseconds, the default is 5000ms (5 seconds).                                       
#elasticsearch_cluster_discovery_timeout = 5000                                                                      
 
# the following settings allow to change the bind addresses for the Elasticsearch client in graylog2
# these settings are empty by default, letting Elasticsearch choose automatically,                  
# override them here or in the 'elasticsearch_config_file' if you need to bind to a special address 
# refer to http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/modules-network.html  
# for special values here                                                                           
#elasticsearch_network_host =                                                                       
#elasticsearch_network_bind_host =                                                                  
#elasticsearch_network_publish_host =                                                               
 
# The total amount of time discovery will look for other Elasticsearch nodes in the cluster
# before giving up and declaring the current node master.                                  
#elasticsearch_discovery_initial_state_timeout = 3s                                        
 
# Analyzer (tokenizer) to use for message and full_message field. The "standard" filter usually is a good idea.
# All supported analyzers are: standard, simple, whitespace, stop, keyword, pattern, language, snowball, custom
# Elasticsearch documentation: http://www.elasticsearch.org/guide/reference/index-modules/analysis/            
# Note that this setting only takes effect on newly created indices.                                           
elasticsearch_analyzer = standard                                                                              
 
# Global request timeout for Elasticsearch requests (e. g. during search, index creation, or index time-range
# calculations) based on a best-effort to restrict the runtime of Elasticsearch operations.                  
# Default: 1m                                                                                                
#elasticsearch_request_timeout = 1m                                                                          
 
# Time interval for index range information cleanups. This setting defines how often stale index range information
# is being purged from the database.                                                                              
# Default: 1h                                                                                                     
#index_ranges_cleanup_interval = 1h                                                                               
 
# Batch size for the Elasticsearch output. This is the maximum (!) number of messages the Elasticsearch output
# module will get at once and write to Elasticsearch in a batch call. If the configured batch size has not been
# reached within output_flush_interval seconds, everything that is available will be flushed at once. Remember 
# that every outputbuffer processor manages its own batch and performs its own batch write calls.              
# ("outputbuffer_processors" variable)                                                                         
output_batch_size = 500                                                                                        
 
# Flush interval (in seconds) for the Elasticsearch output. This is the maximum amount of time between two
# batches of messages written to Elasticsearch. It is only effective at all if your minimum number of messages
# for this time period is less than output_batch_size * outputbuffer_processors.                              
output_flush_interval = 1                                                                                     
 
# As stream outputs are loaded only on demand, an output which is failing to initialize will be tried over and
# over again. To prevent this, the following configuration options define after how many faults an output will
# not be tried again for an also configurable amount of seconds.                                              
output_fault_count_threshold = 5                                                                              
output_fault_penalty_seconds = 30                                                                             
 
# The number of parallel running processors.
# Raise this number if your buffers are filling up.
processbuffer_processors = 5                       
outputbuffer_processors = 3                        
 
#outputbuffer_processor_keep_alive_time = 5000
#outputbuffer_processor_threads_core_pool_size = 3
#outputbuffer_processor_threads_max_pool_size = 30
 
# UDP receive buffer size for all message inputs (e. g. SyslogUDPInput).
#udp_recvbuffer_sizes = 1048576                                         
 
# Wait strategy describing how buffer processors wait on a cursor sequence. (default: sleeping)
# Possible types:                                                                              
#  - yielding                                                                                  
#     Compromise between performance and CPU usage.                                            
#  - sleeping                                                                                  
#     Compromise between performance and CPU usage. Latency spikes can occur after quiet periods.
#  - blocking                                                                                    
#     High throughput, low latency, higher CPU usage.                                            
#  - busy_spinning                                                                               
#     Avoids syscalls which could introduce latency jitter. Best when threads can be bound to specific CPU cores.
processor_wait_strategy = blocking                                                                               
 
# Size of internal ring buffers. Raise this if raising outputbuffer_processors does not help anymore.
# For optimum performance your LogMessage objects in the ring buffer should fit in your CPU L3 cache.
# Start server with --statistics flag to see buffer utilization.                                     
# Must be a power of 2. (512, 1024, 2048, ...)                                                       
ring_size = 65536                                                                                    
 
inputbuffer_ring_size = 65536
inputbuffer_processors = 2   
inputbuffer_wait_strategy = blocking
 
# Enable the disk based message journal.
message_journal_enabled = true          
 
# The directory which will be used to store the message journal. The directory must me exclusively used by Graylog and
# must not contain any other files than the ones created by Graylog itself.                                           
message_journal_dir = /var/lib/graylog-server/journal                                                                 
 
# Journal hold messages before they could be written to Elasticsearch.
# For a maximum of 12 hours or 5 GB whichever happens first.          
# During normal operation the journal will be smaller.                
#message_journal_max_age = 12h                                        
#message_journal_max_size = 5gb                                       
 
#message_journal_flush_age = 1m
#message_journal_flush_interval = 1000000
#message_journal_segment_age = 1h        
#message_journal_segment_size = 100mb    
 
# Number of threads used exclusively for dispatching internal events. Default is 2.
#async_eventbus_processors = 2                                                     
 
# EXPERIMENTAL: Dead Letters
# Every failed indexing attempt is logged by default and made visible in the web-interface. You can enable
# the experimental dead letters feature to write every message that was not successfully indexed into the 
# MongoDB "dead_letters" collection to make sure that you never lose a message. The actual writing of dead
# letter should work fine already but it is not heavily tested yet and will get more features in future   
# releases.                                                                                               
dead_letters_enabled = false                                                                              
 
# How many seconds to wait between marking node as DEAD for possible load balancers and starting the actual
# shutdown process. Set to 0 if you have no status checking load balancers in front.                       
lb_recognition_period_seconds = 3                                                                          
 
# Every message is matched against the configured streams and it can happen that a stream contains rules which
# take an unusual amount of time to run, for example if its using regular expressions that perform excessive backtracking.
# This will impact the processing of the entire server. To keep such misbehaving stream rules from impacting other        
# streams, Graylog limits the execution time for each stream.                                                             
# The default values are noted below, the timeout is in milliseconds.                                                     
# If the stream matching for one stream took longer than the timeout value, and this happened more than "max_faults" times
# that stream is disabled and a notification is shown in the web interface.                                               
#stream_processing_timeout = 2000                                                                                         
#stream_processing_max_faults = 3                                                                                         
 
# Length of the interval in seconds in which the alert conditions for all streams should be checked
# and alarms are being sent.                                                                       
#alert_check_interval = 60                                                                         
 
# Since 0.21 the graylog2 server supports pluggable output modules. This means a single message can be written to multiple
# outputs. The next setting defines the timeout for a single output module, including the default output module where all 
# messages end up.                                                                                                        
#                                                                                                                         
# Time in milliseconds to wait for all message outputs to finish writing a single message.                                
#output_module_timeout = 10000                                                                                            
 
# Time in milliseconds after which a detected stale master node is being rechecked on startup.
#stale_master_timeout = 2000                                                                  
 
# Time in milliseconds which Graylog is waiting for all threads to stop on shutdown.
#shutdown_timeout = 30000                                                           
 
# MongoDB connection string
# See http://docs.mongodb.org/manual/reference/connection-string/ for details
# Django : 2015-12-28                                                        
# default: mongodb_uri = mongodb://localhost/graylog2                        
mongodb_uri = mongodb://graylog-user:R7xAmcKezZ2C0v3mtaXCJjA7Nf@127.0.0.1:27017/graylog
 
# Authenticate against the MongoDB server
#mongodb_uri = mongodb://grayloguser:secret@localhost:27017/graylog2
 
# Use a replica set instead of a single host
#mongodb_uri = mongodb://grayloguser:secret@localhost:27017,localhost:27018,localhost:27019/graylog2
 
# Increase this value according to the maximum connections your MongoDB server can handle from a single client
# if you encounter MongoDB connection problems.                                                               
mongodb_max_connections = 100                                                                                 
 
# Number of threads allowed to be blocked by MongoDB connections multiplier. Default: 5
# If mongodb_max_connections is 100, and mongodb_threads_allowed_to_block_multiplier is 5,
# then 500 threads can block. More than that and an exception will be thrown.             
# http://api.mongodb.org/java/current/com/mongodb/MongoOptions.html#threadsAllowedToBlockForConnectionMultiplier
mongodb_threads_allowed_to_block_multiplier = 5                                                                 
 
# Drools Rule File (Use to rewrite incoming log messages)
# See: https://www.graylog.org/documentation/general/rewriting/
#rules_file = /etc/graylog/server/rules.drl                    
 
# Email transport
#transport_email_enabled = false
#transport_email_hostname = mail.example.com
#transport_email_port = 587                 
#transport_email_use_auth = true            
#transport_email_use_tls = true             
#transport_email_use_ssl = true             
#transport_email_auth_username = you@example.com
#transport_email_auth_password = secret         
#transport_email_subject_prefix = [graylog2]    
#transport_email_from_email = graylog2@example.com
#                                                 
# Django : 2015-12-28                             
# default: unset                                  
transport_email_enabled = true                    
transport_email_hostname = smtp.dmz.nausch.org    
transport_email_port = 25                         
transport_email_use_auth = false                  
transport_email_use_tls = false                   
transport_email_use_ssl = false                   
transport_email_auth_username = graylog-admin@nausch.org
transport_email_auth_password = 6zmNsgdrD4x1!                
transport_email_subject_prefix = [graylog]              
transport_email_from_email = graylog-admin@nausch.org   
 
# Specify and uncomment this if you want to include links to the stream in your stream alert mails.
# This should define the fully qualified base url to your web interface exactly the same way as it is accessed by your users.
#transport_email_web_interface_url = https://graylog2.example.com                                                            
# Django : 2015-12-28                                                                                                        
# default: transport_email_web_interface_url = https://graylog2.example.com                                                  
transport_email_web_interface_url = https://panopticon.nausch.org                                                            
 
# The default connect timeout for outgoing HTTP connections.
# Values must be a positive duration (and between 1 and 2147483647 when converted to milliseconds).
# Default: 5s
#http_connect_timeout = 5s
 
# The default read timeout for outgoing HTTP connections.
# Values must be a positive duration (and between 1 and 2147483647 when converted to milliseconds).
# Default: 10s
#http_read_timeout = 10s
 
# The default write timeout for outgoing HTTP connections.
# Values must be a positive duration (and between 1 and 2147483647 when converted to milliseconds).
# Default: 10s
#http_write_timeout = 10s
 
# HTTP proxy for outgoing HTTP connections
#http_proxy_uri =
 
# Disable the optimization of Elasticsearch indices after index cycling. This may take some load from Elasticsearch
# on heavily used systems with large indices, but it will decrease search performance. The default is to optimize
# cycled indices.
#disable_index_optimization = true
 
# Optimize the index down to <= index_optimization_max_num_segments. A higher number may take some load from Elasticsearch
# on heavily used systems with large indices, but it will decrease search performance. The default is 1.
#index_optimization_max_num_segments = 1
 
# The threshold of the garbage collection runs. If GC runs take longer than this threshold, a system notification
# will be generated to warn the administrator about possible problems with the system. Default is 1 second.
#gc_warning_threshold = 1s
 
# Connection timeout for a configured LDAP server (e. g. ActiveDirectory) in milliseconds.
#ldap_connection_timeout = 2000
 
# Enable collection of Graylog-related metrics into MongoDB
# WARNING: This will add *a lot* of data into your MongoDB database on a regular interval (1 second)!
# DEPRECATED: This setting and the respective feature will be removed in a future version of Graylog.
#enable_metrics_collection = false
 
# Disable the use of SIGAR for collecting system stats
#disable_sigar = false
 
# Amount of time of inactivity after which collectors are flagged as inactive (Default: 1 minute)
#collector_inactive_threshold = 1m
 
# Amount of time after which inactive collectors are purged (Default: 14 days)
#collector_expiration_threshold = 14d
 
# The default cache time for dashboard widgets. (Default: 10 seconds, minimum: 1 second)
#dashboard_widget_default_cache_time = 10s
 
# Automatically load content packs in "content_packs_dir" on the first start of Graylog.
#content_packs_loader_enabled = true
 
# The directory which contains content packs which should be loaded on the first start of Graylog.
content_packs_dir = /usr/share/graylog-server/contentpacks
 
# A comma-separated list of content packs (files in "content_packs_dir") which should be applied on
# the first start of Graylog.
content_packs_auto_load = grok-patterns.json

Start des Daemon

Unsere Konfigurationsänderungen werden mit Hilfe von mongo der MongoDB Shell vorgenommen. Dieses JavaScript stellt die Benutzerschnittstelle zum eigentlichen MongoDN-Daemon zur Verfügung. Damit sich der Client mit dem Server auch verbinden kann, muss der Server natürlich laufen; wir starten also nun unsere NoSQL-Datenbank mit folgendem Befehl.

 # systemctl start graylog-server.service

Den Serverstatus können wir wie folgt abfragen.

 # systemctl status graylog-server.service

graylog-server.service - Graylog server
   Loaded: loaded (/usr/lib/systemd/system/graylog-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2015-12-28 14:27:40 CET; 6s ago
     Docs: http://docs.graylog.org/
 Main PID: 5057 (graylog-server)
   CGroup: /system.slice/graylog-server.service
           ├─5057 /bin/sh /usr/share/graylog-server/bin/graylog-server
           └─5058 /usr/bin/java -Xms1g -Xmx1g -XX:NewRatio=1 -server -XX:+ResizeTLAB -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:+CMSClassUnloadingEnabled -XX:+UsePa...

Dec 28 14:27:40 vml000117.dmz.nausch.org systemd[1]: Started Graylog server.
Dec 28 14:27:40 vml000117.dmz.nausch.org systemd[1]: Starting Graylog server...

Der erfolgreiche Start des Servers wird auch in dessen Logdatei protokolliert.

 # /var/log/elasticsearch/elasticsearch.log
Dec 28 14:27:40 vml000117.dmz.nausch.org systemd[1]: Started Graylog server.
Dec 28 14:27:40 vml000117.dmz.nausch.org systemd[1]: Starting Graylog server...
[root@vml000117 yum.repos.d]# tailf /var/log/graylog-server/server.log
2015-12-28T14:27:55.595+01:00 INFO  [discovery] [vml000117] graylog/j4zrCy-gQpqKTAMqM_XGkg
2015-12-28T14:27:55.609+01:00 INFO  [RestApiService] Enabling CORS for REST API
2015-12-28T14:27:58.627+01:00 WARN  [discovery] [vml000117] waited for 3s and no initial state was set by the discovery
2015-12-28T14:27:58.627+01:00 INFO  [node] [vml000117] started
2015-12-28T14:27:59.138+01:00 INFO  [service] [vml000117] detected_master [vml000117][EdAnadZuTiOjxFR7_Kvdrg][vml000117.dmz.nausch.org][inet[/10.0.0.117:9300]], added {[vml000117][EdAnadZuTiOjxFR7_Kvdrg][vml000117.dmz.nausch.org][inet[/10.0.0.117:9300]],}, reason: zen-disco-receive(from master [[vml000117][EdAnadZuTiOjxFR7_Kvdrg][vml000117.dmz.nausch.org][inet[/10.0.0.117:9300]]])
2015-12-28T14:28:05.324+01:00 INFO  [IndexRotationThread] Deflector index <graylog_1> should be rotated, Pointing deflector to new index now!
2015-12-28T14:28:05.324+01:00 INFO  [Deflector] Cycling deflector to next index now.
2015-12-28T14:28:05.340+01:00 INFO  [Deflector] Cycling from <graylog_1> to <graylog_2>
2015-12-28T14:28:05.340+01:00 INFO  [Deflector] Creating index target <graylog_2>...
2015-12-28T14:28:06.218+01:00 INFO  [Deflector] Waiting for index allocation of <graylog_2>
2015-12-28T14:28:06.335+01:00 INFO  [Deflector] Done!
2015-12-28T14:28:06.335+01:00 INFO  [Deflector] Pointing deflector to new target index....
2015-12-28T14:28:06.531+01:00 INFO  [SystemJobManager] Submitted SystemJob <d4502600-ad66-11e5-8de7-5254005fa52f> [org.graylog2.indexer.ranges.CreateNewSingleIndexRangeJob]
2015-12-28T14:28:06.537+01:00 INFO  [CreateNewSingleIndexRangeJob] Calculating ranges for index graylog_1.
2015-12-28T14:28:06.610+01:00 INFO  [SystemJobManager] Submitted SystemJob <d4557d30-ad66-11e5-8de7-5254005fa52f> [org.graylog2.indexer.SetIndexReadOnlyJob]
2015-12-28T14:28:06.658+01:00 INFO  [SystemJobManager] Submitted SystemJob <d461b230-ad66-11e5-8de7-5254005fa52f> [org.graylog2.indexer.ranges.CreateNewSingleIndexRangeJob]
2015-12-28T14:28:06.658+01:00 INFO  [Deflector] Done!
2015-12-28T14:28:06.618+01:00 INFO  [CreateNewSingleIndexRangeJob] Calculating ranges for index graylog_2.
2015-12-28T14:28:06.720+01:00 INFO  [MongoIndexRangeService] Calculated range of [graylog_1] in [182ms].
2015-12-28T14:28:06.807+01:00 INFO  [CreateNewSingleIndexRangeJob] Created ranges for index graylog_1.
2015-12-28T14:28:06.807+01:00 INFO  [SystemJobManager] SystemJob <d4502600-ad66-11e5-8de7-5254005fa52f> [org.graylog2.indexer.ranges.CreateNewSingleIndexRangeJob] finished in 269ms.
2015-12-28T14:28:06.879+01:00 INFO  [MongoIndexRangeService] Calculated range of [graylog_2] in [180ms].
2015-12-28T14:28:06.930+01:00 INFO  [CreateNewSingleIndexRangeJob] Created ranges for index graylog_2.
2015-12-28T14:28:06.931+01:00 INFO  [SystemJobManager] SystemJob <d461b230-ad66-11e5-8de7-5254005fa52f> [org.graylog2.indexer.ranges.CreateNewSingleIndexRangeJob] finished in 312ms.
2015-12-28T14:28:08.315+01:00 INFO  [RestApiService] Adding security context factory: <org.graylog2.security.ShiroSecurityContextFactory@79ffbf1a>
2015-12-28T14:28:08.354+01:00 INFO  [RestApiService] Started REST API at <http://127.0.0.1:12900/>
2015-12-28T14:28:08.355+01:00 INFO  [ServiceManagerListener] Services are healthy
2015-12-28T14:28:08.357+01:00 INFO  [ServerBootstrap] Services started, startup times in ms: {InputSetupService [RUNNING]=5, OutputSetupService [RUNNING]=32, BufferSynchronizerService [RUNNING]=33, MetricsReporterService [RUNNING]=36, JournalReader [RUNNING]=45, KafkaJournal [RUNNING]=45, PeriodicalsService [RUNNING]=304, IndexerSetupService [RUNNING]=4286, RestApiService [RUNNING]=13364}
2015-12-28T14:28:08.360+01:00 INFO  [ServerBootstrap] Graylog server up and running.
2015-12-28T14:28:08.361+01:00 INFO  [InputSetupService] Triggering launching persisted inputs, node transitioned from Uninitialized [LB:DEAD] to Running [LB:ALIVE]

automatischer Start des Daemon

Damit der Daemon beim Hochfahren unseres Servers automatisch gestartet wird, nutzen wir folgenden Befehl.

 # systemctl enable graylog-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/graylog-server.service to /usr/lib/systemd/system/graylog-server.service.

Wollen wir wissen, ob die Autostartfunktion bereits gesetzt ist, verwenden wir diesen Aufruf.

 # systemctl is-enabled graylog-server.service
enabled

Die Konfiguration des graylog-server Daemons haben wir im vorherigen Kapitel erfolgreich abgeschlossen. Was nun noch fehlt, ist die graylog-web GUI. Die Installation des zugehörigen RPM-Paketes graylog-web hatten wir bereits im Abschnitt Installation von graylog erledigt.

/etc/sysconfig/graylog-web

Zunächst binden wir den Web-Server auf loclahost unseres Syslog-Hosts.

 # vim /etc/sysconfig/graylog-web
/etc/sysconfig/graylog-web
# HTTP server settings.
# Django : 2015-12-28
# default: GRAYLOG_WEB_HTTP_ADDRESS="0.0.0.0"
GRAYLOG_WEB_HTTP_ADDRESS="10.0.0.117"
GRAYLOG_WEB_HTTP_PORT="9000"
 
# Might be used to adjust the Java heap size. (i.e. "-Xms1024m -Xmx2048m")
GRAYLOG_WEB_JAVA_OPTS=""
 
# Pass some extra args to graylog-web. (i.e. "-d" to enable debug mode or "-java-home /usr/lib/jvm/java-1.8.0")
GRAYLOG_WEB_ARGS=""
 
# Program that will be used to wrap the graylog-web command. Useful to
# support programs like authbind.
GRAYLOG_COMMAND_WRAPPER=""

Apache Reverse-Proxy

Da der graylog-web-Daemon ohne Root-Rechte gestartet wird, können wir nur unprivilegierte Ports (Ports größer als 1024) definieren. Da wir aber die Graylog-Web-GUI auch von außen, über einen TLS geschützten Transportkanal ansprechen wollen, nutzen wir einen Apache-vHOST als Reverse-Proxy.

Dazu legen wir uns folgende vHOST-Datei an.

 # vim /etc/httpd/conf.d/graylog.conf
/etc/httpd/conf.d/graylog.conf
#                                                      
# Django : 2015-12-28                                  
#          vHost graylog                               
#                                                      
 
<VirtualHost 10.0.0.117:80>
    ServerAdmin webmaster@nausch.org
    ServerName graylog.nausch.org   
 
    RewriteEngine on
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
 
    # Welche Logdateien sollen beschrieben werden
    CustomLog logs/graylog_access.log combined   
    ErrorLog  logs/graylog_error.log             
</VirtualHost>                                   
<VirtualHost 10.0.0.117:443>                      
    ServerAdmin webmaster@nausch.org             
    ServerName graylog.nausch.org                
    ServerPath /                                 
 
    # Wer soll Zugriff auf die Webseite(n) bekommen?
    <Proxy *>                                       
        Options +FollowSymLinks +Multiviews -Indexes
        AllowOverride None                          
        AuthType Basic                              
        AuthName "Fuer den Zugriff auf den Webserver bitte Anmeldedaten eingeben!"
        AuthBasicProvider ldap                                                    
        AuthLDAPUrl ldaps://openldap.dmz.nausch.org:636/ou=People,dc=nausch,dc=org?uid
        AuthLDAPBindDN cn=Technischer_User,dc=nausch,dc=org                           
        AuthLDAPBindPassword "e1n531f!D4xIi57n393I1354u!"                       
        AuthLDAPBindAuthoritative on                                                  
        Require ldap-user django icinga2                                       
    </Proxy>                                                                          
 
    # Welcher Inhalt soll angezeigt bzw. auf welchen Server sollen die HTTP-Requests weitergeleitet werden?
    ProxyRequests Off                                                                                      
    ProxyPreserveHost On                                                                                   
    ProxyPass / http://127.0.0.1:9000/                                                                    
    ProxyPassReverse / http://127.0.0.1:9000/                                                             
 
    # Welche Logdateien sollen beschrieben werden
    CustomLog logs/graylog_access.log combined   
    ErrorLog  logs/graylog_error.log             
 
    # Absicherung der Übertragung mit Hilfe von TLS
    # Konfiguration bei Verwendung von mod_gnutls  
    <IfModule !mod_ssl.c>                          
        <IfModule mod_gnutls.c>                    
            # Django : 2015-10-29 - TLS-Verschlüsselung mit Hilfe von mod_gnutls
            GnuTLSEnable on                                                     
            # Definition der anzubietenden Protokolle und Ciphers               
            GnuTLSPriorities PFS:-VERS-TLS-ALL:+VERS-TLS1.2:-ARCFOUR-128:+COMP-NULL:+CURVE-SECP384R1:+CURVE-SECP521R1
            # Schlüsseldatei, mit der der CSR erstellt wurde                                                         
            GnuTLSKeyFile /etc/pki/tls/private/graylog.nausch.org.serverkey.pem                                      
            # Zertifikatsdatei inkl. ggf. notwendiger Zwischen- und Root-Zertifikaten                                
            # 1) Server-Zertifikat, 2) Intermediate-Root-Zertifikat und 3) Root-Zertifikat der CA
            GnuTLSCertificateFile /etc/pki/tls/certs/graylog.nausch.org.certificatechain_150612.pem
            # Definition der Schlüssellänge für DHE und ECDHE
            # DHE Schlüssel mit einer Schlüssellänge von 4096 Bit verwenden; dieser wird 1x pro Tag via cronjob
            # (/etc/cron.daily/edh_keygen) neu generiert und der Neustart des nginx-Daemon veranlasst!
            GnuTLSDHFile /etc/pki/tls/private/dh_4096.pem
            # Session-Tickets für Clients nicht anbieten (dieser könnte versuchen über Tickets die Session zu cachen).
            GnuTLSSessionTickets off
        </IfModule>
    </IfModule>
    # Konfiguration bei Verwendung von mod_ssl
    <IfModule mod_ssl.c>
        <IfModule !mod_gnutls.c>
           # Django : 2015-10-04 - TLS-Verschlüsselung mit Hilfe von mod_ssl
            SSLEngine on
            # Definition der anzubietenden Protokolle
            SSLProtocol All -SSLv2 -SSLv3
            # Definition der Cipher
            SSLCipherSuite "AES256+EECDH +AEAD"
            # Schlüsseldatei, mit der der CSR erstellt wurde
            SSLCertificateKeyFile /etc/pki/tls/private/graylog.nausch.org.serverkey.pem
            # Zertifikatsdatei, die von der CA signiert wurde
            SSLCertificateFile /etc/pki/tls/certs/graylog.nausch.org.certificate_150612.pem
            # Zertifikatsdatei des bzw. der Intermediate-Zertifikate(s)
            SSLCertificateChainFile /etc/pki/tls/certs/CAcert_class3.pem
            # Änderung der Cipherorder der Clienets verneinen
            SSLHonorCipherOrder on
            # TLS 1.0 Kompremmierung deaktivieren (CRIME attacks)
            SSLCompression off
        </IfModule>
    </IfModule>
 
    # special stuff ###
 
    # HTTP Strict Transport Security (HSTS), bei dem der Server dem Client im HTTP-Header mitteilt,
    # dass dieser nur noch verschlüsselt mit dem Server kommunizieren soll.
    Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"
 
    # This header enables the Cross-site scripting (XSS) filter built into most recent web browsers.
    # It's usually enabled by default anyway, so the role of this header is to re-enable the filter for
    # this particular website if it was disabled by the user.
    # https://www.owasp.org/index.php/List_of_useful_HTTP_headers
    Header set X-XSS-Protection "1; mode=block"
 
    # when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
    # to disable content-type sniffing on some browsers.
    # https://www.owasp.org/index.php/List_of_useful_HTTP_headers
    # currently suppoorted in IE > 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx
    # http://msdn.microsoft.com/en-us/library/ie/gg622941(v=vs.85).aspx
    # 'soon' on Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=471020
    Header set X-Content-Type-Options nosniff
 
    # config to don't allow the browser to render the page inside an frame or iframe
    # and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
    # if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
    # https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
    header set X-Frame-Options SAMEORIGIN
 
</VirtualHost>

Bevor wir die Änderungen am Apache Webseerver scharf schalten, testen wir unsere Konfiguration noch auf syntaktische Fehler.

 # apachectl -t
Syntax OK

Ist alles O.K. brauchen wir nur noch den Apache-Webserver einmal durchstarten.

 # systemctl restart httpd.service

/etc/graylog/web/web.conf

Die installationsspezifische kundenindividuelle Konfiguration der graylog-web GUI wird über dessen Konfigurationsdatei /etc/graylog/web/web.conf vorgenommen.

Wie schon bei der KOnfiguration des graylog-server's erstellen wir uns, vor der Bearbeitung der Konfigurationsdatei, noch einen Passwort-Hash, mit dem die Nutzerpassworte verschlüsselt werden. Diesen hash-Wert erstellen wir wie folgt:

 # pwgen -N 1 -s 128</code>
KM2OhCgRuTJe9f7bOr0uOtGcX45TB5kmF4L4Ty44bRUlu1y2qh0eDbs613Bv4QFk0ftGzuASpSW5DDBqpSKIlcdI39WdVHBSo33AoPZgKiABd7G7FduhKIMZVjiE7lod

Diese beiden Werte hinterlegen wir nun in der Konfigurationsdatei unseres graylog-web-Daemon und passen anschließend die Konfigurationsoptionen unserer Umgebung an. Änderungen an den Default-Werten sind mit Django : <Zeitstempel> gekennzeichnet

 # vim /etc/graylog/web/web.conf
/etc/graylog/web/web.conf
# graylog2-server REST URIs (one or more, comma separated) For example: "http://127.0.0.1:12900/,http://127.0.0.1:12910/"
# Django : 2015-12-28
# default: graylog2-server.uris=""
graylog2-server.uris="http://127.0.0.1:12900/"
 
# Learn how to configure custom logging in the documentation:
#    http://docs.graylog.org/en/latest/pages/installation.html#manual-setup-graylog-web-interface-on-linux
 
# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions. Set this to a long and randomly generated string.
# If you deploy your application to several instances be sure to use the same key!
# Generate for example with: pwgen -N 1 -s 96
# Django : 2015-12-28
# default: application.secret=""
application.secret="KM2OhCgRuTJe9f7bOr0uOtGcX45TB5kmF4L4Ty44bRUlu1y2qh0eDbs613Bv4QFk0ftGzuASpSW5DDBqpSKIlcdI39WdVHBSo33AoPZgKiABd7G7FduhKIMZVjiE7lod"
 
# Web interface timezone
# Graylog stores all timestamps in UTC. To properly display times, set the default timezone of the interface.
# If you leave this out, Graylog will pick your system default as the timezone. Usually you will want to configure it explicitly.
# timezone="Europe/Berlin"
# Django : 2015-12-28
# default: unset
timezone="Europe/Berlin"
 
# Message field limit
# Your web interface can cause high load in your browser when you have a lot of different message fields. The default
# limit of message fields is 100. Set it to 0 if you always want to get all fields. They are for example used in the
# search result sidebar or for autocompletion of field names.
field_list_limit=100
 
# Use this to run Graylog with a path prefix
#application.context=/graylog2
 
# You usually do not want to change this.
application.global=lib.Global
 
# Global timeout for communication with Graylog server nodes; default: 5s
#timeout.DEFAULT=5s
 
# Accept any server certificate without checking for validity; required if using self-signed certificates.
# Default: true
# graylog2.client.accept-any-certificate=true

Start des Daemon

Nun ist es an der Zeit den die Web-GUI graylog-web zu starten.

 # systemctl start graylog-web.service

Den Serverstatus können wir wie folgt abfragen.

 # systemctl status graylog-web.service

graylog-web.service - Graylog web interface
   Loaded: loaded (/usr/lib/systemd/system/graylog-web.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2015-12-28 15:21:52 CET; 11s ago
     Docs: http://docs.graylog.org/
 Main PID: 8767 (graylog-web)
   CGroup: /system.slice/graylog-web.service
           ├─8767 /bin/sh /usr/share/graylog-web/bin/graylog-web
           └─8768 java -Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m -Dconfig.file=/etc/graylog/web/web.conf -Dlogger.file=/etc/graylog/web/logback.xml -Dpidfile.path=/dev/...

Dec 28 15:21:52 vml000117.dmz.nausch.org systemd[1]: Started Graylog web interface.
Dec 28 15:21:52 vml000117.dmz.nausch.org systemd[1]: Starting Graylog web interface...
Dec 28 15:21:53 vml000117.dmz.nausch.org graylog-web[8767]: Play server process ID is 8768

Der erfolgreiche Start des Servers wird auch in dessen Logdatei protokolliert.

 # /var/log/graylog-web/application.log
2015-12-28T15:21:56.752+01:00 - [INFO] - from play in main
Application started (Prod)

2015-12-28T15:21:56.812+01:00 - [INFO] - from play in main
Listening for HTTP on /10.0.0.117:9000

automatischer Start des Daemon

Damit der Daemon beim Hochfahren unseres Servers automatisch gestartet wird, nutzen wir folgenden Befehl.

 # systemctl enable graylog-web.service
Created symlink from /etc/systemd/system/multi-user.target.wants/graylog-web.service to /usr/lib/systemd/system/graylog-web.service.

Wollen wir wissen, ob die Autostartfunktion bereits gesetzt ist, verwenden wir diesen Aufruf.

 # systemctl is-enabled graylog-web.service
enabled

graylog-web

Unter CentOS 7 wird als Standard-Firewall die dynamische firewalld verwendet. Ein großer Vorteil der dynamischen Paketfilterregeln ist unter anderem, dass zur Aktivierung der neuen Firewall-Regel(n) nicht der Daemon durchgestartet werden muss und somit alle aktiven Verbindungen kurz getrennt werden. Sondern unsere Änderungen können on-the-fly aktiviert oder auch wieder deaktiviert werden.

Laufen der Apache-Reverse-Proxy und der Graylog-Servers nicht auf dem gleichen Host, benötigen wir noch eine Firewall-Definition die diesen Kommunkikationsweg definiert. Dabei soll in unserem Konfigurationsbeispiel die Source-IP die 10.0.0.97 und die Destination-IP die Ip-Adresse 10.0.0.117 sein.

Mit Hilfe des Programms firewall-cmd legen wir nun eine permanente Regel in der Zone public, dies entspricht in unserem Beispiel das Netzwerk-Interface eth0 mit der IP 10.0.0.117 an. Als Source-IP geben wir die beiden IP-Adressen der Apache-Webservers, also die 10.0.0.117 und 10.0.0.97 an. Genug der Vorrede, mit nachfolgendem Befehl wird diese restriktive Regel angelegt.

 # firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="10.0.0.97/32" port protocol="tcp" port="9000" destination address="10.0.0.117/32" accept"
success

Zum Aktivieren brauchen wir nun nur einen reload des Firewall-Daemon vornehmen.

 # firewall-cmd --reload

Fragen wir nun den Regelsatz unserer iptables-basieten Firewall ab, finden wir in der Chain IN_public_allow unsere aktivierten Regeln.

 # iptables -nvL IN_public_allow
Chain IN_public_allow (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     tcp  --  *      *       10.0.0.97            10.0.0.117           tcp dpt:9000 ctstate NEW

syslog (Port 514)

Der graylog-server Daemon läuft mit den Rechten des Users graylog; daher kann der Dienst graylog-server nur Ports >1024 binden.

 # ps aux | grep graylog-server
graylog   1382  0.0  0.0 113116  1404 ?        Ss    2015   0:00 /bin/sh /usr/share/graylog-server/bin/graylog-server
graylog   1391  3.4 17.4 3875072 1396880 ?     Sl    2015 190:29 /usr/bin/java -Xms1g -Xmx1g -XX:NewRatio=1 -server -XX:+ResizeTLAB -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC -XX:-OmitStackTraceInFastThrow -jar -Dlog4j.configuration=file:///etc/graylog/server/log4j.xml -Djava.library.path=/usr/share/graylog-server/lib/sigar -Dgraylog2.installation_source=rpm /usr/share/graylog-server/graylog.jar server -f /etc/graylog/server/server.conf -np

Somit können wir keine bei der Definition von Eingangskanälen (Inputs) keine dieser privilegierte Ports direkt ansprechen. Bei vielen Netzwerkgeräten, wie Router, Switche oder Telefone kann man bei der Definition des Syslog-Dienstes nur den Namen bzw. IP-Adresse des Zielservers angeben, nicht aber die den vordefinierten Port 514.

Da wir aber aus Sicherheitsgründen keinenfalls den graylog Daemon mit root-Rechten wollen, müssen wir uns anders behelfen. Zunächst definieren wir uns einen input-Kanal und weisen diesem dem Port 10514.

BILD: graylog INPUT Definition

Nun werden wir mit Hilfe von iptables den Port 514 auf den zuvor definierten 10514 mappen. Dazu brauchen wir zwei Dinge:

  1. Masquerading
    Mit Hilfe des zugehörigen Kernel-Moduls werden ankommende Pakete auf Port 514 auf Port 10514 „umgerouted“ und ausgehende Pakte von Port 10514 wiederum als Absendeport 514 in den UDP/TCP-Paketen umgeschrieben. Die zugehörige firewalld-Regel zum Aktivieren von Masquerading lautet:
     # firewall-cmd --permanent --zone=public --add-masquerade
    success
  2. DNAT-Regel
    Aus Sicht unseres iptables-Filter wollen wir das Pakete auf den Ziel-Port 514 den der Client verwendet hat, auf auf den Port 10514 unseres graylog INPUTs umschreiben; dazu benötigen wir folgende Regel:
     # firewall-cmd --permanent --zone=public --add-forward-port=port=514:proto=udp:toport=10514
    success

Zum Schluß führen wir nun noch einen Reload des Daemon firewalld durch.

 # firewall-cmd --reload
success

Wenn wir jetzt einen Blick in die definierten INPUTs unseres graylog-Servers werfen, werden wir die angekommenen und verarbeiteten syslog-Meldungen unserer „syslog Port 514 only“-Geräte sehen.

Bild: graylog INPUT syslog UDP Port 514

Die Web-GUI unseres graylog-Servers erreichen wir über die URL, die wir bei der Konfiguration des Apache Reverse-Proxy definiert hatten: https://graylog.nausch.org

Bild: Graylog Web-GUI Login-Screen

Nach erfolgter Erstanmeldung befinden wir uns im „“Getting Started„ Fenster. Dort finden wir auch schon ein paar Online-Hilfe Punkte

Bild: Graylog Web-GUI Startfenster

Nachdem wir unseren graylog-Server erfolgreich vorbereitet haben, werden wir nun unsere Linux-Hosts so konfigurieren, dass diese ihre syslog-Meldungen zu unserem zentralem syslog-/graylog-Server senden.

Das Weiterleiten der Syslogmeldungen ist nicht sonderlich schwer zu konfigurieren. Das Wichtigste das es zu beachten gibt, ist, dass die Meldungen gemäß dem RFC 5424 formatiert werden.

Im ersten Konfigurationsbeispiel wollen wir die Syslog-Meldungen an den Port 514 per UDP1) an unseren graylog-Server senden. Dazu tragen wir am Ende der Konfigurationsdatei des rsyslog-Daemon folgende Zeile ein.

 # vim /etc/rsyslog.conf
# ### begin forwarding rule ###
# The statement between the begin ... end define a SINGLE forwarding
# rule. They belong together, do NOT split them. If you create multiple
# forwarding rules, duplicate the whole block!
# Remote Logging (we use TCP for reliable delivery)
#
# An on-disk queue is created for this action. If the remote host is
# down, messages are spooled to disk and sent when it is up again.
#$ActionQueueFileName fwdRule1 # unique name prefix for spool files
#$ActionQueueMaxDiskSpace 1g   # 1gb space limit (use as much as possible)
#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
#$ActionQueueType LinkedList   # run asynchronously
#$ActionResumeRetryCount -1    # infinite retries if host is down
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
#*.* @@remote-host:514
#
# Django : 2015-06-12
$template GRAYLOGRFC5424,"<%PRI%>%PROTOCOL-VERSION% %TIMESTAMP:::date-rfc3339% %HOSTNAME% %APP-NAME% %PROCID% %MSGID% %STRUCTURED-DATA% %msg%\n"
*.* @10.0.0.117:514;GRAYLOGRFC5424
#
# ### end of the forwarding rule ###

Zum Aktivieren der Konfigurationsänderung starten wir den rsyslog-Daemon einmal durch.

 # systemctl restart rsyslog.service

Möchte man die die Syslog-Meldungen an den Port 514 per TCP2) an den graylog-Server senden, unterscheidet sich die Konfiguration nur unwesentlich. In der Konfigurationszeile wird statt einem @ zwei @@ angegeben. Am Ende der Konfigurationsdatei des rsyslog-Daemon tragen wir folgende Zeile ein.

 # vim /etc/rsyslog.conf
# ### begin forwarding rule ###
# The statement between the begin ... end define a SINGLE forwarding
# rule. They belong together, do NOT split them. If you create multiple
# forwarding rules, duplicate the whole block!
# Remote Logging (we use TCP for reliable delivery)
#
# An on-disk queue is created for this action. If the remote host is
# down, messages are spooled to disk and sent when it is up again.
#$ActionQueueFileName fwdRule1 # unique name prefix for spool files
#$ActionQueueMaxDiskSpace 1g   # 1gb space limit (use as much as possible)
#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
#$ActionQueueType LinkedList   # run asynchronously
#$ActionResumeRetryCount -1    # infinite retries if host is down
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
#*.* @@remote-host:514
#
# Django : 2015-06-12
$template GRAYLOGRFC5424,"<%PRI%>%PROTOCOL-VERSION% %TIMESTAMP:::date-rfc3339% %HOSTNAME% %APP-NAME% %PROCID% %MSGID% %STRUCTURED-DATA% %msg%\n"
*.* @@10.0.0.117:514;GRAYLOGRFC5424
#
# ### end of the forwarding rule ###

Zum Aktivieren der Konfigurationsänderung starten wir den rsyslog-Daemon einmal durch.

 # systemctl restart rsyslog.service

Links


1)
User Datagram Protocol
2)
Transmission Control Protocol
Diese Website verwendet Cookies. Durch die Nutzung der Website stimmen Sie dem Speichern von Cookies auf Ihrem Computer zu. Außerdem bestätigen Sie, dass Sie unsere Datenschutzbestimmungen gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website.Weitere Information
  • centos/web_c7/graylog.1451923279.txt.gz
  • Zuletzt geändert: 04.01.2016 16:01.
  • von django