In Unix or Linux infra its pretty common scenarios when you have to move disks or storage LUNs from one server to another server with data on them intact. This is something which is happening in clusters automatically i.e. handled by cluster services. When primary node goes down, cluster services moves disk or luns from primary to secondary node and make secondary node available for use.
We are going to see how to do this manually using commands. This howto guide gives you insight of what cluster services do in background to move data across nodes in case of failures. We will be using LVM as our disk manager in this guide since its most widely used volume manager next to VxVM (Veritas Volume Manager).
Steps flow goes like this :
- Stop disk access on server1
- Remove disk / LUN from server1
- Present disk / LUN to server2
- Identify new disk / LUN on server2
- Import it into LVM
- Make it available to use on server2
Lets see these steps one by one in details with commands and their outputs. We will be moving mount point /data from server1 to server2. /data is mounted on /dev/vg01/lvol1.
1. Stop disk access on server1
Firstly, you have stop all user/app access to related mount point. In our case its /data. You can check if anyone accessing mount point and can kill it using fuser command.
Once you are sure no one is accessing mount point, go ahead and un-mount it.
2. Remove disk / LUN from server1
Now, we need to remove disk or LUN from LVM of server1 so that it can be detached from server gracefully. For this, we will be using vgexport command so that configuration backup can be imported on destination server.
To export VG, you need to de-activate volume group first and then export VG with map file. Transfer this map file to server2 with ftp or sftp so that it can be used while importing VG there.
Now, your VG is vanished from server1 i.e. related disk / LUN is no more associated with LVM of server1. Since VG ix exported only, data is intact on disk / LUN physically.
3. Present disk / LUN to server2
Now, you need to physically remove disk from server1 and physically attach it to server2. If its a LUN then remove mapping of LUN with server1 and map it to server2. You will require to do zoning at storage level and WWN of both servers.
At this stage, your disk / LUN are removed from server1 and now available/visible to server2. But, its not yet known to LVM of server2.
4. Identify new disk / LUN on server2
To identify this newly presented / mapped disk/LUN on server2, you need to scan hardware or FC. Once you get disk number for it (identified in kernel) proceed with next steps of LVM.
5. Import it in LVM
Now, we have disk / LUN identified on server2 along with VG map file from server1. Using this file and disk name, proceed with importing VG in server2.
First, Import VVG with vgimport command. In place of list_of_disk argument in above example you have to give your disk name. You can use any VG name here. Its not mandatory that you have to use VG name same as first server. After successful import, activate that VG with vgchange.
6. Make it available to use on server2
At this stage, you disk / LUN are available in LVM of server2 with all data on them intact. To make it avaibale for use we need to mount it on directory. Use mount command:
Add entry in /etc/fstab as well to make sure mount point gets mounted at boot too.
0 comments:
Post a Comment