Tuesday, July 28, 2009

Moving a pool to a different server

Today we are going to move a ZFS pool from one server to another. There are several ways we could execute this exercise:

a) we could create a pool on SCSI or SAS drives and physically move the drives from one server to another
b) we could create a pool on SAN disk and then ask the Storage team to rezone the disks to another server.
c) we could create a pool on a bunch of memory sticks and move the memory sticks.
d) we could create a pool on 64MB files and ftp the files from one server to the other.

Let's use option "d" (64MB files) because we don't need special hardware.


I encourage you to give this a try; you need a pair of servers; both servers should be setup with the same release of Solaris 10.

The servers I used are called gnat ant epoxy. One is sparc, the other is x86.

If you prefer to use two sparc boxes or two x86 boxes that is fine too.

gnat is a T2000 loaded with Solaris 10 08/07-sparc
epoxy is an X4200 loaded with Solaris 10 07/07-x86

First create a pool with two vdevs… each vdev will consist of a single 64MB file (no mirroring or raidz today)

gnat# mkfile 64M /tmp/file1
gnat# mkfile 64M /tmp/file2
gnat# zpool create ttt /tmp/file1 /tmp/file2

Now add a couple of file systems mounted under "/apps_test", and "/work_test".

Earlier this week we used one command to create file systems and a second command to rename the mount points.

Today we are combining the two steps into a single command to save typing.

gnat# zfs create -o mountpoint=/apps_test ttt/apps
gnat# zfs create -o mountpoint=/work_test ttt/work

gnat# df -h | egrep 'ttt|Filesystem'
Filesystem Size Used Available Capacity Mounted on
ttt 87M 24K 87M 1% /ttt
ttt/apps 87M 24K 87M 1% /apps_test
ttt/work 87M 24K 87M 1% /work_test

Write some data to the file systems.

gnat# echo "hello world #1" > /apps_test/testfile_in_apps
gnat# echo "hello world #2" > /work_test/testfile_in_work
gnat# ls -lR /*test*
/apps_test:
total 2
-rw-r--r-- 1 root root 15 Feb 8 15:21 testfile_in_apps
/work_test:
total 2
-rw-r--r-- 1 root root 15 Feb 8 15:22 testfile_in_work

Now export the pool.

This is similar to exporting a Veritas volume group… but we don't need to bother unmounting the file systems first.

The pool will be left in a state where it can be moved to another system.

gnat# zpool export ttt

If we were using real disk, we would now physically or logically move the disk to the other server.

But since we are using 64MB files, we can simply copy them to the /tmp directory on another server.

If you use ftp make sure to do a "binary" transfer! I used scp.

gnat# scp /tmp/file1 myusername@e_p_o_x_y:/tmp
...
gnat# scp /tmp/file2 myusername@e_p_o_x_y:/tmp
...
Log into the second server. Check that the files are intact:

epoxy# ls -l /tmp/file*
-rw------- 1 waltonch unixadm 67108864 Feb 8 15:31 /tmp/file1
-rw------- 1 waltonch unixadm 67108864 Feb 8 15:35 /tmp/file2

Now import the pool.

If we were using real disks, we could ask the zpool command to examine all new disks searching for "importable" pools.

But since we are using files, we need to tell the zpool command where to look. If you have a million files in /tmp this may take a while. If /tmp is relatively empty it should be quick.

epoxy# zpool import -d /tmp ttt

Now check it out:

epoxy# df -h | egrep 'ttt|Filesystem'
Filesystem Size Used Available Capacity Mounted on
ttt/apps 87M 26K 87M 1% /apps_test
ttt 87M 24K 87M 1% /ttt
ttt/work 87M 26K 87M 1% /work_test


epoxy# ls -lR /*test*
/apps_test:
total 2
-rw-r--r-- 1 root root 15 Feb 8 15:21 testfile_in_apps

/work_test:
total 2
-rw-r--r-- 1 root root 15 Feb 8 15:22 testfile_in_work

Many of us have exported Veritas volume groups from one machine and imported them into another.

But with veritas we had to create the mount points, edit the vfstab file, and manually mount the file systems.

ZFS did it all! And notice that ZFS did not complain going from sparc to x86. Pretty cool folks; pretty cool.

Now we must cleanup on both servers:
epoxy# zpool destroy ttt
epoxy# rmdir /apps_test
epoxy# rmdir /work_test
epoxy# rm /tmp/file*

gnat# rmdir /apps_test
gnat# rmdir /work_test
gnat# rm /tmp/file*


Readers who read this page, also read:




Bookmark and Share My Zimbio http://www.wikio.com

0 comments: