Prerequisites: We're assuming you already have MongoDB, Apache2, and Java up and running on your Linux box (Ubuntu in our specific case, but at least Debian should be very similar).
First you'll need to set up the server (we're using the lastest version in this example, but this will obviously change in the future) - this is very straight forward:
- wget https://github.com/downloads/Graylog2/graylog2-server/graylog2-server-0.9.5p1.tar.gz
- tar xvfz graylog2-server-0.9.5p1.tar.gz
- cd graylog2-server-0.9.5p1/
- sudo cp graylog2.conf.example /etc/graylog2.conf
- Edit the settings according to your MongoDB installation: sudo pico /etc/graylog2.conf
- cd bin/
- sudo ./graylog2ctl start
- ps aux | grep gray
- sudo touch /etc/init.d/graylog2-server
- sudo pico /etc/init.d/graylog2-server
#! /bin/sh
### BEGIN INIT INFO
# Provides: Starts Graylog2 Server
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Graylog2 Server
# Description: Server aggregating the logs
### END INIT INFO
# Author: Philipp Krenn
# Aktionen
case "$1" in
start)
cd /usr/local/graylog2-server/bin/
./graylog2ctl start
;;
stop)
cd /usr/local/graylog2-server/bin/
./graylog2ctl stop
;;
restart)
cd /usr/local/graylog2-server/bin/
./graylog2ctl restart
;;
esac
exit 0 - sudo update-rc.d graylog2-server defaults
- Get the required dependencies: sudo apt-get update && sudo apt-get install ruby1.8 rubygems rake make libopenssl-ruby ruby-dev build-essential git-core
- cd ~
- Get the Graylog2 frontend: wget https://github.com/downloads/Graylog2/graylog2-web-interface/graylog2-web-interface-0.9.5p2.tar.gz
- tar xvfz graylog2-web-interface-0.9.5p2.tar.gz
- Get the latest Ruby Gems to bundle the installation: wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.5.tgz
- tar xvfz rubygems-1.8.5.tgz
- cd rubygems-1.8.5/
- sudo ruby setup.rb
- sudo gem update
- sudo gem install bundler
- cd ~/graylog2-web-interface-0.9.5p2/
- bundle install
- bundle show
- Apache2's base directory is /var/www/, so let's create /var/rails/ and put the Rails files there. We'll then link the Apache2 directory to the Rails application.
- sudo mkdir /var/rails/
- sudo mkdir /var/rails/graylog2
- sudo cp -R ./* /var/rails/graylog2/
- Install Apache2's Passenger module, which integrates Rails applications.
- sudo apt-get install libapache2-mod-passenger
- sudo gem install passenger
- sudo passenger-install-apache2-module
- The previous step ran the module's installer, which will do quite some work for you. Additionally it will tell you which dependencies are not yet met, in our case we had to add the following packages: sudo apt-get install libcurl4-openssl-dev libssl-dev zlib1g-dev apache2-prefork-dev libapr1-dev libaprutil1-dev
- Run the tool again and execute the steps it tells you to, except for the last one wanting you to change some configurations: sudo passenger-install-apache2-module
- Instead open up the following file and make sure only the given content is available there: sudo pico /etc/apache2/mods-available/passenger.conf
<ifmodule c="">
PassengerRoot /usr
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.7
PassengerRuby /usr/bin/ruby1.8
</ifmodule> - Do the same for another configuration file: sudo pico /etc/apache2/mods-available/passenger.load
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
- Now add your subdirectory to your Apache2's configuration (inside the VHost past): sudo pico /etc/apache2/sites-available/default
RailsBaseURI /graylog2
- Link the public/ directory of your Rails application to the one you set up in Apache2's configuration: sudo ln -s /var/rails/graylog2/public/ /var/www/graylog2
- Change the configuration, this must the be same as the server configuration: sudo pico /var/www/graylog/config/mongoid.yml
- Finally restart Apache2: sudo /etc/init.d/apache2 restart
UPDATE: As noted by Lennart (https://twitter.com/#!/_lennart/status/88330653246038016) you need to manually create your indexes: In /var/rails/graylog2 run the command sudo rake db:mongoid:create_indexes RAILS_ENV=production and you're good to go.
Great writeup and I hope you enjoy Graylog2.
ReplyDeleteJust a simple thing I'd like to point out: modern ubuntu uses upstart to manage daemons and the init system you have written the script for is included for backwards compatibility.
You can find the upstart script and simple instructions for graylog2 server at https://github.com/Graylog2/graylog2-server/tree/develop/misc/upstart
Cheers
Mick
Thanks!
ReplyDeleteI've seen the upstart script, but being a Debian user and after reading http://wiki.ubuntuusers.de/upstart#Kritik I stuck with the init system. However, you're probably right I should take a step forward the next time ;-).
You may be interested to know that I have made Ubuntu 10.04(Lucid) packages available.
ReplyDeleteYou can find my HOWTO written around these packages at http://www.lunix.com.au/blog/graylog2/
Feel free to re-use any of the content.
Mick
@aussielunix
Hi,
ReplyDeleteI am installed everything as you wrote but web interface not working for me. I just see the index of the public folder that i can browse but web interface not running. What am i missing any idea?
Thanks
Peter
Apache should throw up an error - are there any log entries in /var/log/apache2/error.log?
ReplyDeleteHi,
ReplyDeleteyou have to link the whole graylog2-web-interface directory to /var/www/ and point to public in the vhost config. Because passenger needs to access above public.
And this is not needed
RailsBaseURI /graylog2
after i found out this i installed 3 server already
You mean instead of "sudo ln -s /var/rails/graylog2/public/ /var/www/graylog2" it should be "sudo ln -s /var/rails/graylog2/ /var/www/graylog2"?
ReplyDeleteIn my working installation I'm linking to the public directory. If this isn't working for you, I'm glad you found an alternative, working approach.
I had trouble with it. For getting the webinterface to work I had to manually customize app/views/layouts/application.html.erb (the path to the application.js) and public/assets/application.js (the line with $.get("/health/currentthroughput", function(json) {).
ReplyDeleteHope this two customizations are enough for the alternative subdirectory.