Skip to content

Tag: debian 5

Monitoring MySQL with Munin on a DirectAdmin platform

Today I’ll be showing you how to monitor MySQL with Munin on a DirectAdmin platform. I’ve tested this setup for a customer on a CentOS box. It should be fairly easy to adapt this to Debian. You probably won’t even need to change credentials at all on a Debian box given the fact that it has an /etc/mysql/debian.cnf file by default. Although I’m not sure DirectAdmin puts it to good use. Any Debian/DirectAdmin users out there? Feel free to comment.

Let’s start off by checking the proper MySQL login credentials on our CentOS/RHEL box:

# cat /usr/local/directadmin/conf/mysql.conf
user=da_admin
passwd=removed

Easy enough. Let’s move on to installing munin and applying the credentials to the MySQL monitoring plugin. Munin isn’t available in the default repository. Not to worry, it’s in the Fedora Project’s EPEL repository for CentOS/RHEL. If you don’t have EPEL enabled yet be sure to check the excellent FAQ on the subject.

Or you could just move on to installing the repository.
For i386/i686:

 
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/
epel-release-5-3.noarch.rpm

For x86_64:

For x86_64: 
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/
epel-release-5-3.noarch.rpm

Now we can go on installing munin:

# yum install munin munin-node

Sadly this doesn’t install pull all the necessary dependencies. Not sure why the package maintainer missed out on this but it’s rather easy to fix it:

# yum install perl-Cache perl-Cache-Cache 
# yum install perl-IPC-ShareLite perl-DBD-MySQL

On to the credentials part. Edit the mysql plugin on line 132:

# vim +132 /usr/share/munin/plugins/mysql_

You should see something like this with the credentials left blank:

my %config = (
    'dsn'        => $ENV{'mysqlconnection'} || 'DBI:mysql:mysql',
    'user'       => $ENV{'mysqluser'}       || 'da_admin',
    'password'   => $ENV{'mysqlpassword'}   || 'removed',
);

As you can see I’ve already filled in the blanks.

Once the plugin has been configured we’re able to apply it. Before applying I’d suggest you take a look at what graphs are available:

# /usr/share/munin/plugins/mysql_ suggest
mysql_bin_relay_log
mysql_commands
mysql_connections
mysql_files_tables
mysql_innodb_bpool
mysql_innodb_bpool_act
mysql_innodb_insert_buf
mysql_innodb_io
mysql_innodb_io_pend
mysql_innodb_log
mysql_innodb_rows
mysql_innodb_semaphores
mysql_innodb_tnx
mysql_myisam_indexes
mysql_network_traffic
mysql_qcache
mysql_qcache_mem
mysql_replication
mysql_select_types
mysql_slow
mysql_sorts
mysql_table_locks
mysql_tmp_tables

To apply all of them simply run the following:

# cd /etc/munin/plugins
# ln -sf /usr/share/munin/plugins/mysql_ mysql_
# for i in `./mysql_ suggest`; \
do ln -sf /usr/share/munin/plugins/mysql_ $i; done

If you only need a few of them you can apply them this way:

# cd /etc/munin/plugins
# ln -sf /usr/share/munin/plugins/mysql_ mysql_
# ln -sf /usr/share/munin/plugins/mysql_ mysql_bin_relay_log
# ln -sf /usr/share/munin/plugins/mysql_ mysql_commands
# ln -sf /usr/share/munin/plugins/mysql_ mysql_connections
# ln -sf /usr/share/munin/plugins/mysql_ $any_other_graph

Be sure to reload munin-node:

# /etc/init.d/munin-node restart

And that’s it. Enjoy your graphs at http://127.0.0.1/munin. 🙂

Munin MySQL InnoDB graph

Install Xen and libvirt on Debian Lenny

This should be an easy to follow guide about how to install Xen on Debian 5. You should be able to copy/paste most parts of on your shell. Please run this only on a clean and up-to-date Debian system.

Alright let’s get to it quick ‘n dirty.

First of all make sure your Debian install actually is up-to-date:

# apt-get update; apt-get upgrade

Let’s see which Xen kernel images are available and pick the most recent one to install:

# apt-cache search xen | grep image | awk '{print $1}'
linux-image-2.6-xen-amd64
linux-image-xen-amd64
linux-image-2.6.26-1-xen-amd64
linux-image-2.6.26-2-xen-amd64
xen-linux-system-2.6.26-1-xen-amd64
xen-linux-system-2.6.26-2-xen-amd64
# apt-get install `apt-cache search xen-linux-system \
| sort | tail -1 | awk '{print $1}'`

Once this is done reboot your system, login again and run:

# uname -a
Linux elysium 2.6.26-2-xen-amd64 #1 SMP Thu Feb 11 02:57:18 UTC 2010 x86_64 GNU/Linux

As you can see, the system is running kernel 2.6.26-2 with the xen-amd64 patch set.
As of now we should have Dom-0 available:

# xm list
Name                   ID   Mem VCPUs      State   Time(s)
Domain-0               0  3885     2     r-----      8.5

Perfection!

Let’s move on to the network. By default there is no bridge available from the virtual machines towards the external network. It’s fairly easy to accomplish though:

# vim /etc/xen/xend-config.sxp

Look for the following line and uncomment it:

(network-script network-bridge)

And while we’re editing the xend-config.sxp file, change the following line:

(xend-unix-server no)

Into:

(xend-unix-server yes)

Be sure to reload the new settings:

# /etc/init.d/xend restart

If you don’t edit this line or if you don’t reload, you obviously won’t be able to install or manage your virtual machines. You’d get to see errors like this:

ERROR    internal error failed to connect to xend
Traceback (most recent call last):
  File "/usr/bin/virt-install", line 693, in
    main()
  File "/usr/bin/virt-install", line 508, in main
    conn = cli.getConnection(options.connect)
  File "/var/lib/python-support/python2.5/virtinst/cli.py", line 123, in getConnection
    return libvirt.open(connect)
  File "/usr/lib/python2.5/site-packages/libvirt.py", line 140, in open
    if ret is None:raise libvirtError('virConnectOpen() failed')
libvirtError: internal error failed to connect to xend

There are more options available to connect to xend.: xend-http-server, xend-tcp-xmlrpc-server, xend-unix-xmlrpc-server, xend-relocation-server.

The reason why I chose xend-unix-server over anything else is pretty straight forward. It only listens on the Unix socket layer which doesn’t need any other networking protocol to operate. You could compare it to connecting to localhost, but without the need for a networking device (e.g. lo0).

If you want to be able to manage this Xen server from a central node, be sure to change the appropriate management protocol. It’s beyond the scope of this howto, but I might post an howto on this subject later on this blog.

On to installing a virtual machine!

I for one am a big fan of abstraction layers. It makes life for a SysAdmin or DevOp so much easier if you’re able to run the same commands on different operating systems, platforms or architectures in general. That’s why I use libvirt. It’s a collection of libraries and tools that can be used to deploy virtual machines on different types of virtualization systems. Including but not limited to Xen, KVM and Qemu.

It’s also available as a Debian package, so installing it is very straight forward:

# apt-get install libvirt-bin virtinst

Once this is done we can install our first virtual machine:

# virt-install \
--name=test-debian-install \
--ram=1024 \
--file-size=10 \
--nographics \
--paravirt \
--file=/var/lib/xen/images/test-debian-install.img \
--location=http://ftp.belnet.be/debian/dists/lenny/main/\
installer-i386

It’s probably a good idea to store this as a shell script on your Xen host for future reference.
You should see a familiar installer within seconds after invoking the command.

Once the install has completed you should be greeted with your new virtual machine’s login prompt:

Debian GNU/Linux 5.0 test-debian-install hvc0

test-debian-install login:

To exit your virtual machine’s console, simply press Ctrl-]

Enjoy!