Wednesday, June 16, 2010

MySQL Replication Monitoring using Nagios

Dear All,

This article will be focussed on how to setup MySQL replication monitoring using Nagios. I assume that you already have Nagios and MySQL replication setup and running on any of the Linux machine.

I have developed a script which can be used with Nagios and allows you to monitor replication status.

Here are the steps you need to follow:

1. Define remote host in your nagios host configuration file or create a new conifugration file with extension .cfg

   define host{
          use                        generic-host         
          host_name            backupdb            # You can set any name here
          alias                      backupdb            # and here
          address          # IP address of your remote slave server

2. Define command to be used in commands.cfg.

  define command{
        command_name check_slavestatus
        command_line /path/to/shell/ -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -p $ARG3$

3. Define service in your nagios host file.

  define service{
        use                               generic-service
        host_name                   backupdb
        service_description     MySQL Live Server Replication Status
        check_command   check_slavestatus!3306!user!password

Restart Nagios after you will done with the above configuration.

This is how your Nagios will display the MySQL replication monitoring information.

Please contact me for the shell script to configure the Nagios as described above.


Wednesday, May 5, 2010

Setup Postfix Virtual Domains

In this article, I assume that postfix has been already setup on the server and running. Here I am going to describe how to setup postfix virtual domains using hash tables. The mailboxes will also be separate accounts and not unix system accounts.

Edit /etc/postfix/ file and add the following parameters.

1.  virtual_mailbox_domains=/etc/postfix/vdomains
    Here, /etc/postfix/vdomains is the file which contains names of the domains to be setup virtually and handled by postfix. Remember to enter one domain per line.

2. virtual_mailbox_base=/home/vmail
    It tells the postfix system about the base directory of the mail store. It can be any directory on the unix system.

3. virtual_mailbox_maps=hash:/etc/postfix/vmaps
   Here I have created a lookup file that maps email addresses to their mailboxes. A virtual mailbox will looks like the following.                    
  Remember to create the hash table of the file using the following command:
     #postmap /etc/postfix/vmaps

4. Setup mailbox file ownership using following directives in
     virtual_uid_maps= ( check /etc/passwd for uid )
     virtual_gid_maps= ( check /etc/group for gid )

5. Create required folders under /home/vmail,  e.g. for domain and user webmaster, the directory structure will looks like the following:
     #mkdir  /home/vmail/
     #mkdir  /home/vmail/
     #mkdir -p  /home/vmail/{cur,new}

6. Change ownership and folder permissions.
    #chown  -R postfix.postfix  /home/vmail/
    #chmod  -R  775  /home/vmail/

7. Reload postfix system to implement the changes done above.
    #postfix reload

Thats it! Your postfix system has been configured to support multiple domains now.


Sunday, May 2, 2010

Configure VNC server on remote linux system.

Here I am going to explain how to setup VNC server on remote Linux system running ubuntu server.

Step 1: Make sure you are able to get connected with remote server using SSH.

Step 2: Install ubuntu desktop package on the server that will provide gnome environment.
#aptitude install ubuntu-desktop

Step 3: Install tightvnserver on the server.
#aptitude install tightvncserver

Step 4: Reconfigure XServer.
#dpkg-reconfigure xserver-org

Step 5: Run the VNC Server using following command.
#vncserver :1 -geometry 1024x768 -depth 16 -pixelformat rgb565
It will start VNC server at display 1.

Step 6: Use following command in order to stop/kill running VNC instance.
#vncserver -kill :1

Step 7: Use any of your favorite VNC client to get connected with VNC server using following syntax:

That's it! Were you expecting some more complicated steps? Sorry to disappoint you :)