Saturday, July 16, 2011

How to Install Bugzilla in Debian

Here we are going install bugzilla 3.6.3 in Debian testing (all in one host). By the time of this writing bugzilla package was not available in testing release and one from stable failed to run in testing release. The option is to use it from sid release.

Install

  1. Since we are going install everything on one box we need two essential components: a web server and database server, apache and mysql serve this purpose quite well (if you have mysql already somewhere in the network you need mysql-client package instead).
    apt-get -y install apache2 mysql-server
    
  2. Add sid repository to your apt sources list and update package list:
    echo "deb http://ftp.debian.org/debian sid main" \
        >> /etc/apt/sources.list
    apt-get update
    # You should be able to find bugzilla3 package now
    apt-cache search bugzilla3
    
  3. Install bugzilla:
    apt-get install bugzilla3
    
    Configure database for bugzilla3 with 
    dbconfig-common? Yes
    
  4. Comment out sid repository in apt sources file
  5. You can now navigate to your bugzilla home page by simply entering:
    http://bugzilla-server-name/bugzilla3
    

Serving from Web Server Root

Default installation of bugzilla install it into bugzilla3 virtual directory. You can change it to be server from root directory:
  1. Set urlbase in /etc/bugzilla3/params:
    'urlbase' => ''
    
    or even better (this url is the common initial leading part of all Bugzilla urls):
    'urlbase' => 'http://bugzilla-server-name/'
    
  2. Disable default site in apache:
    a2dissite default
    
  3. Ensure the following in /etc/apache2/conf.d/bugzilla3.conf:
    <VirtualHost *:80>
        #Alias /bugzilla3 /usr/share/bugzilla3/web
        DocumentRoot /usr/share/bugzilla3/web
        SetEnv X_BUGZILLA_WEBPATH "/" 
    
        ...
    
    </VirtualHost>
    
  4. Let apache know about the changes we made:
    /etc/init.d/apache2 reload
    

Database backup/restore

During installation of bugzilla it creates a new database with name bugzilla3.
  1. Here is a small script to backup database:
    # Backup bugzilla database
    /etc/init.d/apache2 stop
    mysqldump -p bugzilla3 > backup.sql
    /etc/init.d/apache2 start
    
  2. ... and restore.
    # Restore bugzilla database
    /etc/init.d/apache2 stop
    mysql -p bugzilla3 < backup.sql
    /etc/init.d/apache2 start
    
Read more about bugzilla here.

Monday, July 11, 2011

How to shrink qcow2 file

While working with kvm/qemu virtual environment you might encounter need to shrink image file after a removal of unnecessary files, etc. You will be surprised that the space you freed in guest virtual machine is not actually released in host file. It's size remain the same. Here you will know how to shrink it to minimum.

Windows Guest

The idea here is simple, there are few things you have to do:
  1. Delete all unnecessary files, empty recycle bin
  2. Defragment drive (you might need to do this several times, until you see it "compacted" well)
  3. Use sdelete to zero free disk space. Please note that this operation will cause that all drive free space will be filled by zero, so the virtual machine image will grow to the maximum size.
    sdelete -c c:
    

Linux/FreeBSD Guest

dd if=/dev/zero of=./zero bs=1M
sync
rm -f ./zero
Note, the bs parameter is important, since it greatly reduce time necessary to complete this task.

Host

Convert image to the same format that is currently is (e.g. qcow2 => qcow2)... during this procedure it will release unused space.
qemu-img convert -O qcow2 w2k3.qcow2 \
 w2k3-shrinked.qcow2
The process is time consuming and each phase greatly depends on physical disk IO performance and available free space.

Sunday, July 3, 2011

Debian Samba Server

Samba is the protocol by which a lot of PC-related machines share files and printers.
apt-get install samba

Temporary File Space

We will create a simple network share tmp. All users in WORKGROUP will have read-write access. Let create a directory tree (under /srv/smb/) we are going to serve.
mkdir -p /srv/smb/tmp
Place the following in /etc/samba/smb.conf (backup the original file first):
[global]
workgroup = WORKGROUP
server string = Public File Server

# When clients connect to a share level security server, 
# they need not log onto the server with a valid 
# username and password before attempting to connect to
# a shared resource. Instead, the clients send 
# authentication information (passwords) on a per-share
# basis, at the time they attempt to connect to that 
# share.
security = share

# This parameter determines whether or not smbclient(8) 
# and other samba client tools will attempt to 
# authenticate itself to servers using the weaker 
# LANMAN password hash.
client lanman auth = no

# This parameter determines whether or not smbd(8) will 
# attempt to authenticate users or permit password 
# changes using the LANMAN password hash.
lanman auth = no

[tmp]
# If this parameter is yes for a service, then no 
# password is required to connect to the service.
public = yes
comment = Temporary File Space (cleaned up at midnight)
path = /srv/smb/tmp
read only = no
hide files = lost+found
Now from Windows machine you can access this share as \\samba-server-name\tmp. Here is a cron job to make daily clean ups (file /etc/cron.d/clean-samba-tmp):
#
# Regular cron jobs for removing everything 
# in samba tmp share
#
SHELL=/bin/sh

# Run daily at 1:35 AM
# m h dom mon dow user  command
35 1 * * * root /bin/rm -rf /srv/smb/tmp/*
See more configuration options here.

Thursday, June 23, 2011

Performance Monitoring in Linux

There are few useful tools that can help find out a bottleneck of your Linux box performance.

What to monitor first?

The system load is a measure of the amount of work that a computer system performs. You can use this command to read system load:
uptime
Here is a sample output:
... load average: 1.07, 1.63, 2.81
The three values of load average refer to the past 1, 5, and 15 minutes of system operation. These numbers should be read this way: the number represents how well a single CPU can handle load, thus if the number is 1 or less - it is pretty comfortable (the 4-CPU system works well at load number 4 or less); 1.5 - means at least 50% of load is not handled on time, it is queued for processing and is a subject for attention.

System Monitoring

Real time monitoring can be observed with top and htop commands. Command htop gives you more convenient way of what top does. Particularly it is handy to add two more columns (via 'F2' Setup) related to IO read and IO write.
htop
Processors related statistics with mpstat:
watch -n 1 mpstat

Disk Monitoring

IO can be a one of possible bottleneck of system performance degradation. The tool iotop tracks disk I/O by process, and prints a summary report that is refreshed every second.
iotop
Statistic for IO devices and partitions can be monitored with iostat:
watch -n 1 iostat

Who is waiting and blocked?

It is useful to know how the system load goes across processes, however most interest is related to processes that keep waiting for the operation to complete, thus cause delays. Here is a simple command to get this kind of report every second:
watch -n 1 "(ps aux | awk '\$8 ~ /D/  { print \$0 }')"

Network Monitoring

Intensive network related operation can cause the high load as well. Here is a tool that let you have a better idea of your network traffic utilization - iftop:
iftop

Saturday, June 4, 2011

Troubleshooting: Could not update .ICEauthority file

Here is the error message that might encounter duing gnome desktop startup.
Could not update .ICEauthority file 
/var/lib/gdm3/.ICEauthority
I have resolved this problem by simply removing that file and let gdm3 daemon re-create it. The commands below must be executed with root privileges.
/etc/init.d/gdm3 stop
rm /var/lib/gdm3/.ICEauthority*
/etc/init.d/gdm3 start
Note, restarting gdm not helps all the time, so try reboot computer instead.