Archive

Archive for December, 2009

How to install and configure Bacula

December 25th, 2009

Bacula : –   It comes by night and sucks the vital essence from your computers..

Introduction:

Bacula is an on-linebased back up tool. Which is used to backup files from different servers into back up server where the bacula is running. For setup this backup tool across network first you have to install bacula server package on backup server machine where you are storing your backup contents ,and install bacula client daemon on all other servers from where we are going to backup data.


Bacula has five main components.

1.Director daemon

This daemon co-ordinate all working of backup,and through its configuration file we can specify all these things.

2.File daemon

This daemon works in all clients from that client we are backup data. Director daemon connect to this daemon after authentication and backup the files from this client.

3.Storage daemon

This daemon is for store the backup data from client in to hard disk of backup server,usually this daemon and director daemon works in the same backup server. director works as intermediate between the file daemon and storage daemon.

4.Console daemon

This is a terminal to control all works.This console connect to director daemon and using its commands we can define all things related with backup .

5.Catalog Database

The database used here is for store all information related to the backup, including the file indexing.Commonly used database for bacula is Mysql.


This figure shows how the different bacula daemon configuration files were linked together.

bacula

Install and Configure Bacula Server

You can install bacula from rpm packages or from Source compilation. Here we are focusing on the source method,which is tested and is working fine.

* Download latest version of bacula from bacula.org site .

Here we are using following versions


1. bacula-3.0.3.tar.gz (http://sourceforge.net/projects/bacula/files/bacula/3.0.3/bacula-3.0.3.tar.gz/download)

2. depkgs-18Feb09.tar.gz or later versions (http://sourceforge.net/projects/bacula/files/depkgs/18Feb09/depkgs-18Feb09.tar.gz/download)

This two packages are used to setup a bacula,In which you have to install depkgs-18Feb09.tar.gz first to solve remaining dependency problems before starting bacula-3.0.3.tar.gz. You should not hesitate to install depkgs-18Feb09.tar.gz ,it contains different packages ,in which you can install “mtx and qwt”. you need not install sqlite database because mysql is the default database.

tar -xzf depkgs-18Feb09.tar.gz
cd depkgs
make qwt
make mtx
gmake mtx-instal

Then Enter in to the bacula source directory and Use the following configurations settings to install bacula (Or You can use system default configuration)


 CFLAGS="-g -O2" \
./configure \
--sbindir=/usr/local/bacula/bin \
--sysconfdir=/usr/local/bacula/bin \
--with-pid-dir=/usr/local/bacula/bin/working \
--with-subsys-dir=/usr/local/bacula/bin/working \
--enable-smartalloc \
--with-mysql \
--with-working-dir=/usr/local/bacula/ \
 --with-dump-email=user.name=@????.se \     #The mail addresses is to mail all activities of your backup in to your inbox.
--with-job-email=user.name@????.se \
--with-smtp-host=localhost \
--enable-bat \
--with-qwt=/usr/local/qwt-5.0.2/        #path to qwt source folder( usually it is inside depkg folder that you are installed previously)</pre>

make

make install

make install-autostart   #only supported for the officially supported systems (Redhat/Fedora...).This will put all startup script into the /etc/init.d/ folder and corresponding syslinks , so automatically start corresponding daemon at  startup.

make distclean  # type this to clear all configuration settings if you are starting ./configure from beginning.

Now you are successful completed the installation of bacula server , then type

Then we have to setup the Database to store the catalog information.Most commonly used database is Mysql,and setup the corresponding users,databases and privileges for the bacula application.

 /etc/init.d/mysqld start 

Bacula installation has included some scripts to complete the initial database and other server setups, these scripts are under your bin folder of the installed directory.

cd <Installed path>/bin

./grant_mysql_privileges -u root -p

Create database

./create_mysql_database -u root -p
./make_mysql_tables -u root -p

create a directory called working under /usr/local/bacula/bin/

Afrer installation of bacula. navigate to installed folder and run bacula by typing

./bacula start

This will start all three daemons ( bacula-dir,bacula-sd and bacula-fd)

And then check ports where these daemons are listening.

default case:

daemon    |  port
===================
bacula-dir   9101
bacula-fd    9102
bacula-sd    9103

make sure that the above mentioned ports are added and opened in the csf.conf file of the server or in some other firewall settings

After successful installation to start the sample backup from same system where you installed all three daemons . Follow this simple tutorial :

http://www.bacula.org/en/rel-manual/Brief_Tutorial.html#TutorialChapter

To administrate  bacula it  provide a console or terminal named as bconsole . Using this console we can do all work from back end.

NB: For installation from source package, after detar you should read the README and INSTALL files. Most of the time this will helps you to complete installation.

Install and Configure Bacula Client

After downloading the source and depkgs do the depkgs installation as mentioned  above
Use these following  configuration to install client  :

CFLAGS="-g -O2" ./configure  --bindir=/usr/local/bacula/bin --sysconfdir=/usr/local/bacula/bin --with-pid-dir=/usr/local/bacula/bin/working --with-subsys-dir=/usr/local/bacula/bin/working --enable-smartalloc --with-working-dir=/usr/local/bacula/ --with-dump-email=user@yourdomain.com --with-job-email=user@yourdomain.com  --with-smtp-host=localhost  --with-qwt=../depkgs/qwt-5.0.2/(here path to qwt source) --enable-client-only

If your system is 64-bit(To know it use the command arch ) then add –libdir=/usr/local/lib64

make

make install

make install-autostart-fd     //It helps start client daemon at start up.

create a directory called working under /usr/local/bacula/bin/

start the file daemon using

/etc/init.d/bacula-fd start

add a new “client”and “job” in to the bacula-dir.conf

and set the password in the in the conf’s as shown in the above figure (Use above tutorial also)

Use Follwing configuration checking if you have any problems with the bacula setup

a) Client bacula-fd daemon listening to 9102
b) Edit bacula-fd.conf ,Change the Director name and password to Director name and client resource password in the  bacula-dir.conf
    file of the Server.
c) Add server hostname to the /etc/hosts of the client system, inorder to ensure correct resolution.

d) Also check the ports 9102 to listen server request and 9103 to contact server storage daemon by typing

telnet server-hostname 9103 (from client )
telnet client-hostname 9102  (from server)

========================================================================================
Above procedure is the standard installation steps ; You can download and use the documentation (*.gz) package from bacula.org for more details.
========================================================================================

SET UP WEB BASED INTERFACE TO MONITOR BACULA( php and perl based)

—————————————————————————————————————-
( Install this package in your backup server where your bacula-server is installed)

1.Bweb web based comprehensive admin tool

Bweb developed up on perl,so in order to install bweb we need to install some perl dependencies files.
you can use cpan.
You can install this tool just following the INSTALL file under bacula-gui-XXX/bweb/. This file is more than enough to complete the installation of bweb.

2. bacula-gui-3.0.3.tar.gz

Download this package to setup web interface .

Detar this package and Read README to complete installtaion [in this package You need not type ‘make or make install’ , just

 ./configure --with-bacula=(path to bacula source folder)

Then copy the bacula-web from this source folder and place it in your document root of the apache.

NB: This gui was only tested with php 4.3.4 and php-5.0.4,later. you may get blank page while you are using later versions.check the error log and correct it (may be some permission error ). If you have any problem to install php 4.3.4 with your latest apache 2.2.* then go for apache 2.0.* versions.

Here we tested the following versions.
1.Install pear DB by typing “#pear install DB ”
2.apache 2.0.63
3.php-4.3.4

After installation web-servercopy copy folder bacula-web to its document root , then type : http://system-ip:/bacula-web

Some Error Fixes:

————————————

1.If your configuration of server and clients seems to be correct, but you still receiving  this error

eg:”: Fatal error: bsock.c:135 Unable to connect to Client: server.client.com-fd on server.client.com:9102. ERR=Interrupted system call ”

* Please check the firewall configurations,whether ports 9102 not blocked at client server and 9101or 9102 are not blocked at server .
* To check this telnet to destination port. If the system is installed with csf ,then check the TCP IN and OUT allowed ports.

VN:F [1.9.1_1087]
Rating: 8.8/10 (5 votes cast)
VN:F [1.9.1_1087]
Rating: +1 (from 1 vote)

Haridas N general, linux , ,

How to install nagios

December 7th, 2009

Below we give a brief description of how to install and configure Nagios.

To install Nagios make sure the following are installed and working properly in your machine


* httpd
* php
* gcc
* glibc
* glibc-common
* gd
* gd-devel
* png
* png-devel
* jpeg
* jpeg-devel
* zlib
* zlib-devel

Install Steps

1) Create a new user and group as root

Create a new user nagios.

useradd -m nagios

passwd nagios 

Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.

/usr/sbin/groupadd nagcmd

/usr/sbin/usermod -a -G nagcmd nagios

/usr/sbin/usermod -a -G nagcmd apache 

2) Download Nagios and the Nagios Plugins

Download the source code tarballs of both Nagios and the Nagios plugins.


wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.2.0/nagios-3.2.0.tar.gz/download
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.14/nagios-plugins-1.4.14.tar.gz/download

3) Compile and Install Nagios

Extract the Nagios source code.


tar xzf nagios-3.2.0.tar.gz
cd nagios-3.2.0

make sure that these libraries are already installed in the system .Otherwise install them using YUM


   * gd
    * gd-devel
    * png
    * png-devel
    * jpeg
    * jpeg-devel
    * zlib
    * zlib-devel 

Run the Nagios configure script, passing the name of the group:

 ./configure --with-command-group=nagcmd 

Compile the Nagios source code.

 make all 

Install binaries, init script, sample config files and set permissions on the external command directory.

make install

make install-init

make install-config

make install-commandmode 

4) Customize Configuration

After installation the default configuration file can be found in the directory /usr/local/nagios/etc/. Also edit your contact information

 vi /usr/local/nagios/etc/objects/contacts.cfg

5) Configure the Web Interface

Install the Nagios web config file in the Apache conf.d directory.

 make install-webconf 

Create a nagiosadmin account for logging into the Nagios web interface.

 htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 

Restart Apache to make the new settings take effect.

 /etc/init.d/httpd restart 

6) Compile and Install the Nagios Plugins

Extract the Nagios plugins source code.

 tar xzf nagios-plugins-1.4.14.tar.gz

cd nagios-plugins-1.4.14 

Compile and install the plugins.

 ./configure --with-nagios-user=nagios --with-nagios-group=nagios
make

make install

7) Start Nagios

Add Nagios to the list of system services and have it automatically start when the system boots.

 chkconfig --add nagios

chkconfig nagios on 

Verify the default Nagios configuration files.

 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 

If there are no errors, start Nagios.

 service nagios start

8) Modify SELinux Settings

This step is important if the Selinux is not in the Permissive mode it shows error like this

See if SELinux is in Enforcing mode.

getenforce

Put SELinux into Permissive mode.

setenforce 0

To make this change permanent, you’ll have to modify the settings in /etc/selinux/config and reboot.

9) Login to the Web Interface
You should now be able to access the Nagios web interface at the URL below. You’ll be prompted for the username (nagiosadmin) and password(nagios) you specified earlier.

http://localhost/nagios/ 

10) Add hosts to be monitored

There are object configuration files in which you can define hosts, host groups, contacts, contact groups, services, etc. You can split your object definitions across several config files if you wish, or keep them all in a single config file.

For convinience we created two files hosts.cfg and services.cfg under the directory /usr/local/nagios/etc/objects/ and add the file path to /usr/local/nagios/etc/nagios.cfg as

cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg 

Then create a simple script to add hosts, named add_host_service.sh by adding the following lines.

## script begins here
#!/bin/bash
echo "Enter Host Name"
read name
echo "Enter IP Address of $name"
read ip_add

echo "
define host{
        use                     linux-server
        host_name               $name
        alias                   $name
        address                 $ip_add
        }
" >> /usr/local/nagios/etc/objects/hosts.cfg

echo "
define service {
host_name                       $name
service_description             HTTP
check_command                   check_http
use                             generic-service
notification_interval           1
}
define service {
host_name                       $name
service_description             POP
check_command                   check_pop
use                             generic-service
notification_interval           1
}
define service {
host_name                       $name
service_description             SMTP
check_command                   check_smtp!-t 20
use                             generic-service
notification_interval           1
}
" >> /usr/local/nagios/etc/objects/services.cfg 

##script ends here

The above script will monitor three services HTTP, SMTP and POP. To monitor a new service add a new define service entry as shown above.

execute the above script by the command

sh add_host_service.sh

While the execution it will ask for the host name and the IP Address of the host to be added. After execution it will add a new host to nagios. To verify the nagios configuration for errors use the command

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

For the changes to take effect we must restart the nagios as follows.

killall nagios
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg

Now you can find the newly added hosts under the link Hosts in Nagios interface.

Happy Monitoring

Posted by
mmm1
Mobin
Jr Software Engineer
SparkSupport

&

paesPaes
Jr Software Engineer
SparkSupport
VN:F [1.9.1_1087]
Rating: 10.0/10 (4 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)

admin general, linux

Qmail flush stuck queue

December 5th, 2009

Qmail is a wonderful MTA in all sense but its quite easy to have the troubles like your queue getting filled up and you don’t know how to flush the queue. I’ll give you some insights how to do that

If you have already downloaded qmHandle you can remove the mails by issuing the command

qmHandle -S'failure notice'

Here we have deleted all the mails with the subject “failure notice” change it as per your needs, but I don’t think qmHandle can work on a busy system and when the queue is quite large. By default qmHandle has to stop qmail first so make sure that qmailctl is correctly mentioned in the qmHandle script just another tip :)

Our installation of qmail was based on qmailrocks and here is the method we followed

You cannot simply stop qmail by issuing qmailctl stop

you need to stop by the command

svc -d /service/*
svc -d /service/*/log

then kill all qmail process

pgrep |xargs kill -9

now go to qmail queue directory

cd /var/qmail/queue/
find mess -type f -exec rm -rf {} ;
find info -type f -exec rm -rf {} ;
find remote -type f -exec rm -rf {} ;

Now enable qmail service

svc -u /service/*
svc -u /service/*/log

now tail the log files

 tail -f /var/log/qmail/qmail-smtpd/current also tail -f /var/log/qmail/qmail-send/current and see how it goes.
VN:F [1.9.1_1087]
Rating: 9.7/10 (3 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)

Shijil T S Mailservice, linux