"First they ignore you, then they laugh at you, then they fight you, then you win." M. Gandhi

La Fibra che Ride

Ubuntu 9.10 CountDown

Online LUN expansion and partition resizing without reboot under Linux

If you are in the need of expanding the LUN where your Linux is installed without rebooting the server, then may be that here you can find the right answer. Your Linux must be sufficiently recent to support features like LVM version 2, ext3 on-line resizing and so on.

My setup in tihs test is the following:

A Linux RedHat 5.3 64 bit Virtual Machine with a single 300 GB LUN /dev/sda in Raw Device Mapping mode (Physical Compatibility mode) under VMware 3.5 and a Compellent SAN. Inside the single disk there is one Volume Group (vg0) with serveral Logical Volumes.

The SAN guys expanded on-line the LUN from 300 to 500 GB (a 30″ operation :-) ).

To force the rescan of partition to get the kernel aware of the new size (supposing your LUN is /dev/sda):

# echo 1 > /sys/block/sda/device/rescan

and then in dmesg you’ll see:

SCSI device sda: 1048576000 512-byte hdwr sectors (536871 MB)
sda: Write Protect is off
sda: Mode Sense: 8f 00 00 08
SCSI device sda: drive cache: write through
sda: detected capacity change from 322122547200 to 536870912000

Now you have two choices at this point: expand the partition containing the current volume group or create a new partition and extend the current volume group. I sincerely prefer the latter, since resizing the partition with fdisk is a risky operation IMVHO.

Use fdisk to create a new partition of type LVM (0×8e) in the free space. But at this point you may have trouble in the kernel re-reading the partition table:

# sfdisk -R /dev/sda
BLKRRPART: Device or resource busy

So to inform the OS of the partition table changes use partprobe(8) command which comes with the parted packages.

Verify in /proc/partitions that the kernel has updated the partition table.

Now use pvcreate /dev/sda3, then vgextend vg0 /dev/sda3 and you are done! Verify with vgdisplay that the Free PE are consistent.

To make some more stress test I made the following:

While running this command on a newly created LVM partition /dev/vg0/TRASHME mounted on /TRASH:

# dd if=/dev/zero of=TTTT bs=1024k count=30000
..... dd is running....

I tried an online resizing of the Logical Volume and the ext3 partition inside it:

# lvextend -L+10G /dev/vg0/TRASHME
Extending logical volume TRASHME to 40.00 GB
Logical volume TRASHME successfully resized
# resize2fs /dev/vg0/TRASHME
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vg0/TRASHME is mounted on /TRASH; on-line resizing required
Performing an on-line resize of /dev/vg0/TRASHME to 10485760 (4k) blocks.
The filesystem on /dev/vg0/TRASHME is now 10485760 blocks long.

in the mean time dd finished his work:
30000+0 records in
30000+0 records out
31457280000 bytes (31 GB) copied, 175.612 seconds, 179 MB/s

Great! Remember to always backup your data before doing operations like this! YMMV.

((enjoy))

HOWTO Mysql Master Slave Resync

If you are using the nice master-slave replication feature of MySQL (available since early version 3.x if I remember well), it may happens that the slave may get out of sync for various reasons.
One typical error is like this:
090908 12:58:48 [ERROR] Error reading packet from server: Client requested master to start replication from impossible position ( server_errno=1236)
090908 12:58:48 [ERROR] Got fatal error 1236: ‘Client requested master to start replication from impossible position’ from master when reading data from binary log
this error can happen for example on the slave if the master crashes and the binlog isn’t updated correctly in the fsck recovery.

So here is a quick description of how to resynchronize the slave in a single master single slave configuration.

This procedure involves a stop of the slave server, while the master will have the tables in lock mode for the time of taking a snapshot/export of your databases to be copied on the slave.

Step 1. On the Slave
Issue the following commands to mysql:
STOP SLAVE; # stop the Slave I/O threads
RESET SLAVE; # forget about all the relay log files
/etc/init.d/mysql stop # stop the database

Step 2. On the Master
Issue the following commands to mysql:
mysql> RESET MASTER; # reset the bin log counter and wipe out bin log files
mysql> FLUSH TABLES WITH READ LOCK; # flush buffers and LOCK tables (both MyISAM and InnoDB)
mysql> show master status\G
*************************** 1. row ***************************
File: mysql-bin.000001
Position: 98
Binlog_Do_DB:
Binlog_Ignore_DB:
1 row in set (0.00 sec)

mysql>

Plaase take note of the file (mysql-bin.000001) and the position (98). You’ll need it later on the slave.

Now, don’t exit from the current mysql client, since you will release the lock, and we don’t want this. Take another shell and do the following:
- make a copy (gzipped tar for example) of the datafiles of MyISAM databases
- make an export of the InnoDB databases (via mysqldump –databases –lock-all-tables DBNAME1 [DBNAME2...] > dumpfile.sql ).
To reduce the down time of the master database, If you don’t have InnoDB databases and you are using LVM on the MySQL volume, you can for example take a snapshot instead of copying the datafiles (take the snapshot and then UNLOCK TABLES;).

Go back to the mysql client where you issued the “FLUSH TABLES WITH READ LOCK;” and type “UNLOCK TABLES;” or logout from the client.
Now the master is available again to mysql clients.

Step 3. Go back on the Slave
Verify that the slave mysql is STOPPED.
Copy the dumps and the archives of the databases you made in previous steps on the master to the slave.
Replace the datafiles of the MyISAM databases you got from the master. These steps may vary and can be done in different ways (scp of the datafiles, mysqldump from the slave connecting to the master and so on… that’s your choice :-) .
Edit /etc/my.cnf and insert “skip-slave-start” in the mysqld section of the file to avoid the start of the slave I/O threads.
Start the mysql instance on the slave. Delete the InnoDB databases and import them from the SQL dumps.
Now issue the following to mysql using the right parameters taken from SHOW MASTER STATUS\G above:
mysql> CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=98;
mysql> SLAVE START;

Verify that the the slave connects to the master and that is getting the binlog.
mysql> show slave status\G
....
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
....
Seconds_Behind_Master: 1634

Slave_IO_Running tells you that the slave is connected to the master, while Slave_SQL_Running says you that the slave is applying the binlog and updating the local datafiles. If they are both set to “Yes” all is fine, replication is working.
Seconds_Behind_Master is the “lag” in seconds from the slave to the master, and should decrease to 0 in a short time (depending also on the activity on the master from the UNLOCK TABLES instant).

Don’t forget to comment out the “skip-slave-start” in /etc/my.cnf so that next time mysql restart on the slave the I/O threads are automatically started.

That’s all folks, monitor the Seconds_Behind_Master status counter to know if the slave is getting out of sync.

Please refer to the MySQL Reference Manual about replication for more details.

To purge old binlog files I use this script running on the slave from root’s crontab once a week:

#!/bin/bash
CURRENT_LOGFILE=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | awk '$1 == "Master_Log_File:" {print $2}')
/usr/bin/mysql -h MASTER -e "PURGE MASTER LOGS TO '${CURRENT_LOGFILE}'"
exit $?

((enjoy))

Simple IPV4 to IPV6 address converter

A dirty 2 shell lines trick to convert a static IPV4 address in the corresponding IPV6:

ipv4=$( ip ad sh eth0 | grep "inet " | awk '{print $2}'| sed -e 's/\/.*//')
printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`

((enjoy))

Shiretoko IS Firefox, it’s only a User Agent issue

On my Ubunty Jaunty I’ve started to use the latest Firefox build using this PPA:
deb http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu jaunty main
but the Ubuntu Mozilla Team has decided to rebrand it as Shiretoko, and this seems to break some sites which relies on the User Agent string. Using the User Agent Switcher add-on for Shiretoko, ops… Firefox, is a nice trick. Another option is to use Ubuntuzilla.

((enjoy))

Google Patents World’s Simplest Home Page

Google Patents World’s Simplest Home Page

The first patent request was made on 2004, and now the Google Home Page has received a patent for “Graphical user interface for a display screen of a communications terminal”. Is Bing already violating this patent? :-)

((enjoy))

Testing Drivel

This is a test post using Drivel.

Does it work?

((enjoy))

The Art Of Community by Jono Bacon

The Art Of Community now available.

((enjoy))

http://www.jonobacon.org/2009/08/19/the-art-of-community-now-available/The

ATI Linux Proprietary Driver – Catalyst 9.8 RELEASED

It is available for download here (64 bit platform).

Updated instructions for Ubuntu installation  are as always here.

((enjoy))

Oracle In-Memory Database

Interesting links:

  • Oracle timesten in-Memory Database: http://www.oracle.com/database/timesten.html
  • Oracle in-Memory Database Cache: http://www.oracle.com/database/in-memory-database-cache.html

((enjoy))

IEEE 802.21: Media-Independent Handover Services

The IEEE 802.21 working group (see www.ieee802.org/21) recently finalized the first standard for dealing with handovers in heterogeneous networks, also called Media-Independent Handovers (MIH). The standard is expected to allow mobile users (and operators) to take full advantage of overlapping and diverse access networks. It provides a framework for efficiently discovering networks in range and executing intelligent heterogeneous handovers, based on their respective capabilities and current link conditions.

An interesting primer about this can be found on the last issue of “The Internet Protocol Journal”.

((enjoy))