Graylog
Материал из noname.com.ua
Устновка Graylog2 на CentOS 6.3
Добавлю epel репозиторий. У меня он локальный
/etc/yum.repos.d/epel.repo [epel] name=Extra Packages for Enterprise Linux 6 baseurl=http://172.16.250.1/cobbler/repo_mirror/epel/x86_64 failovermethod=priority enabled=1
или из сети
rpm -i http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
Установить mongodb
yum -y install mongodb.x86_64 mongodb-devel.x86_64 mongodb-server.x86_64
Ява и прочее необходимое барахло
yum -y install lsb gcc make java-1.6.0-openjdk curl-devel zlib-devel openssl-devel
Секрктничать с монго смысла пока не вижу, на всякий случай привожу как это сделать
Устанавливаем mongodb-server # yum -y install mongodb mongodb-server Создаем пользователя: # mongo MongoDB shell version: 1.8.2 connecting to: test > use admin switched to db admin > db.addUser('admin', 'Password') { "user" : "admin", "readOnly" : false, "pwd" : "Password" } > db.auth('admin', 'Password') 1 > use graylog2 switched to db graylog2 > db.addUser('grayloguser', 'Password') { "user" : "grayloguser", "readOnly" : false, "pwd" : "Password" } > db.auth('grayloguser', 'Password') 1 > exit bye Делаем Mongodb более безопастной /etc/mongodb.conf auth = true Перестартуем Mongodb # service mongod restart Добавляем в автозагрузку # chkconfig mongod on # chkconfig --list | grep mongod mongod 0:off 1:off 2:on 3:on 4:on 5:on 6:off
rvm remove 1.9.2 rvm pkg install openssl rvm install 1.9.2 --with-openssl-dir=$HOME/.rvm/usr
Устанавливаем Elasticsearch
Я решил собрать РПМку. на сайте подробная инструкция.https://github.com/tavisto/elasticsearch-rpms У меня (я делал по шагам_ все собралось сразу и без проблем.
rpm -ivh elasticsearch-0.19.0-1.el6.x86_64.rpm /etc/init.d/elasticsearch start chkconfig elasticsearch on
Graylog2.rpm
Сборка как обычно, спек конфиг и инит ниже:
SPEC
%define real_name graylog2-server %define version 0.9.6 %define vers 096 %define prefix /opt/%{real_name}/%{version} Name: %{real_name}-%{vers} Summary: Graylog2 is an log management solution that stores your logs in ElasticSearch. Version: %{version} Release: 1 AutoReqProv: on License: BSD Group: Applications/Searchengines URL: http://www.graylog2.org #Source: https://github.com/downloads/Graylog2/graylog2-server/%{real_name}-%{version}.tar.gz Source: %{real_name}-%{version}.tar.gz Source1: graylogd2 Source2: graylog2.conf Buildarch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build %if 0%{?suse_version} >= 1100 BuildRequires: -post-build-checks %endif %description Graylog2 is an open source log management solution that stores your logs in ElasticSearch. It consists of a server written in Java that accepts your syslog messages via TCP, UDP or AMQP and stores it in the database. The second part is a web interface that allows you to manage the log messages from your web browser. %prep %setup -q -n %{real_name}-%{version} %build %install %{__mkdir_p} %{buildroot}%{prefix} %{__mkdir_p} %{buildroot}%{_sysconfdir}/rc.d/init.d %{__install} -m 755 %{SOURCE1} %{buildroot}%{_sysconfdir}/rc.d/init.d/graylogd2 %{__install} -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/graylog2.conf %{__cp} -av ./* %{buildroot}%{prefix}/ %post cd %{prefix}/.. %{__ln_s} -f %{version} 0.9.latest %clean %{__rm} -rf %{buildroot} %files %defattr(-,root,root) %dir %{prefix} %{prefix} %{_sysconfdir}/rc.d/init.d/graylogd2 %config(noreplace) %{_sysconfdir}/graylog2.conf %changelog * Mon Sep 24 2012 Max Mazur <sirmax123@gmail.com> - Added init script, moved from DBA --> /opt, added config * Fri May 11 2012 Holger Manthey <holger.manthey@bertelsmann.de> - inital version
init script
cat graylogd2 #!/bin/bash # # graylog2-server - This script starts and stops the graylog2-server daemon # # chkconfig: - 85 15 # description: graylog2 is a syslog implementation that stores logs in MongoDB ### BEGIN INIT INFO # Provides: # Required-Start: $network # Required-Stop: $network # Default-Stop: 0 1 2 6 # Short-Description: Start/stop the graylog2-server daemon # Description: A syslog implementation that stores logs in MongoDB ### END INIT INFO # Source function library. . /etc/init.d/functions # Check networking . /etc/sysconfig/network [[ $NETWORKING == no ]] && exit 0 prog="graylog2-server" version="0.9.6" vers="096" prefix="/opt/${prog}/${version}/" jar="${prefix}/$prog.jar" lockfile="/var/lock/$prog" logfile="/var/log/graylog2.log" pidfile="/var/run/$prog.pid" JAVA_BIN="/usr/bin/java" unset pid gl2_run() { # Disable csh style history expansion for safety set +H daemon "( $JAVA_BIN -jar \"$jar\" >\"$logfile\" 2>&1 & echo \"\$!\" >\"$pidfile\" )" pid=$(<"$pidfile") sleep 1 if kill -0 "$pid" >/dev/null 2>&1 then return 0 else return 1 fi } gl2_status() { [[ -f $pidfile ]] && pid=$(<"$pidfile") [[ -z $pid ]] && return 1 if kill -0 "$pid" >/dev/null 2>&1 then return 0 else return 1 fi } status() { if gl2_status then echo $"$prog (pid $pid) is running..." return 0 else if [[ -f $lockfile ]] then echo $"$prog dead but subsys locked" return 2 fi echo $"$prog is stopped" return 3 fi } start() { [[ -r $jar ]] || exit 5 gl2_run >/dev/null 2>&1 if [[ $? -eq 0 ]] then retval=0 touch "$lockfile" success else retval=1 failure fi echo $"Starting $prog: " return "$retval" } stop() { killproc -p "$pidfile" if [[ $? -eq 0 ]] then retval=0 rm -f "$lockfile" success else retval=1 failure fi echo $"Stopping $prog: " return "$retval" } restart() { stop start } reload() { restart } force_reload() { restart } case "$1" in start) gl2_status && exit 0 $1 ;; stop) gl2_status || exit 0 $1 ;; restart) $1 ;; reload) gl2_status || exit 7 $1 ;; force-reload) force_reload ;; status) $1 ;; condrestart|try-restart) gl2_status || exit 0 restart ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" exit 2 esac exit $?