Thursday May 12, 2016

Oracle VM 3.4 script: schedule and move VMs to a different repository

Moving VMs from one repository to an other can be something boring, mostly if your VM has many vdisks or if you have to move many vms.

On Oracle VM to completely move a VM you need to create a clone-customizer and specify target destination for each virtual-disk.

So, on activities like:

  • storage replacement (new repositories) ***
  • huge list of vms to move to a new repository
  • vms to move to a new repository with tens of virtual-disks
  • scheduled VM moving

a batch approach can help to address them with an automated script able to create the clone-customizer and move the entire vm (vm.cfg file and all virtual-disks) to the destination repository. 

*** In case of storage replacement this script does not manage the Oracle VM poolfs migration.

Moving a VM is a tricky operation and more checks are executed by the script before starting with it; these are all the checks executed by the script before starting the "move" operation:

  • Execute the first connection to the manager using "expect", needed in case of reboot of Oracle VM Manager or client host
  • Check VM Name is unique: you can have different VMs with the same name but we need to identify which one we have to move
  • Check Server-Pool name and VM membership: verify that VM we are going to move is part of the pool specified
  • Check target repository name: verify that target repository specified exists
  • Check OVS that guest the vm: verify which Oracle VM Server actually guest the VM and if this server has target repository presented
  • Check OVMCLI Release and features available: this script is compatible with Oracle VM 3.3 and 3.4
  • Check VM and all its components are not already on target repository: verify that everything is not already in place
  • Verify disk space available on target repository: verify that on target repository there is enough space to guest the VM
  • Check VM Status (running / stopped) and options specified (VM shutdown and VM restart)

Once all these checks are verified the script executes following steps:

  • Create Clone Customizer for VM moving
  • Prepare storage mappings for Clone Customizer created
  • Prepare network mappings for Clone Customizer created
  • Move VM to target repository and delete Clone Customizer
  • Verify VM moving completed successfully
  • Start the moved vm and verify it's started (optional)

Script "MoveVm.sh" v0.1 can be downloaded here.

"MoveVm.sh" script  has following characteristics:

  • Compatible with:
    • Oracle VM 3.3
    • Oracle VM 3.4
  • Requires
    • "expect" installed on the Linux system executing the script
    • able to reach port 10000 of Oracle VM Manager host

Script flowchart graphically is:

To see script syntax, just execute the script without any option:

The script won't move "Virtual Cd-Rom" (ISO files) and/or manage physical disks.

In the following example we have one VM (ol67test) where:

  • vm.cfg file is on repository named local_02
  • 3 virtual-disks are on repository named local_02
  • 1 virtual-cdrom is on repository named local_02
  • 1 physical-disk is owned by the guest
  • 2 vnic(s) are configured on two different networks

Following example will move the entire VM (vm configuration file and all virtual-disks) to repository named local_01.

Now the "moved" VM is configured with:

  • vm.cfg file is on repository named local_01
  • 3 virtual-disks are on repository named local_01
  • 1 virtual-cdrom remains on repository named local_02
  • 1 physical-disk is owned by the guest
  • 2 vnic(s) are configured as before

Log execution of this operation can be downloaded here

Obviously all this stuff can be scheduled and, thanks to this OVMCLI script, moving VMs won't be anymore a tedious operation.

Feedback and questions are obviously appreciated. 

Tuesday Jan 29, 2013

Oracle VM ocfs2 repositories: hot-extend in four easy steps!

Pay Attention: Starting from release 3.1.1 you can extend your repository by refreshing it in Oracle VM Manager.

 With release 3.1.1 or above, execute these two simple steps:

1.  refresh LUN containing the repository by "Storage" tab.

2.  refresh your repository

Official documentation: What's new in Oracle VM 3.1.1

Usually when our Oracle VM pool needs more disk space we create new repositories and then we proceed to create our new guests or we extend our virtual-disks.

Sometimes customers ask us to extend one repository instead of create a new one.

I would like to clarify that add one repository is always safer than extend an existing one; this blog post is purely demonstrative that "extend" is possible and it works; remember to take a full repository backup before to extend it.

This guide can be used on release 3.0.x. ( starting from release 3.1.1 extend repository by Oracle VM Manager is faster, safer and supported ).

In this example we will extend a repository of 250 GB to 300 GB. Here you'll find the four easy steps:

1. Extend the lun on the storage ( .... )

Identify the physical device to extend:

[root@ovm01 ~]# df -k /dev/mapper/3600143801259961a0000800001170000
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/3600143801259961a0000800001170000
                     262144000 235312128  26831872  90% /OVS/Repositories/0004fb0000030000480c7108c43bcaaa 

[root@ovm01 scripts]# multipath -ll /dev/mapper/3600143801259961a0000800001170000
3600143801259961a0000800001170000 dm-47 HP,HSV360
size=250G features='0' hwhandler='0' wp=rw
|-+- policy='round-robin 0' prio=1 status=active
| `- 2:0:0:29 sdhr 134:16  active ready running
|-+- policy='round-robin 0' prio=1 status=enabled
| `- 2:0:1:29 sdhs 134:32  active ready running
|-+- policy='round-robin 0' prio=1 status=enabled
| `- 2:0:2:29 sdht 134:48  active ready running
|-+- policy='round-robin 0' prio=1 status=enabled
| `- 2:0:3:29 sdhu 134:64  active ready running
|-+- policy='round-robin 0' prio=1 status=enabled
| `- 3:0:1:29 sdhw 134:96  active ready running
|-+- policy='round-robin 0' prio=1 status=enabled
| `- 3:0:0:29 sdhv 134:80  active ready running
|-+- policy='round-robin 0' prio=1 status=enabled
| `- 3:0:2:29 sdhx 134:112 active ready running
`-+- policy='round-robin 0' prio=1 status=enabled
  `- 3:0:3:29 sdhy 134:128 active ready running

By your storage admin tool ( also by Oracle VM plugin for your storage ) extend your physical device that hosts the repository.

2. Refresh physical size of your storage device 

A little code string that can help to prepare the job is:

# for i in `multipath -ll /dev/mapper/3600143801259961a0000800001170000| grep sd |sed -e 's:^..............::g' |awk '{print $1}'`; do echo "blockdev --rereadpt /dev/$i" ; done

You will get an output similar to that show below:

# blockdev --rereadpt /dev/sdhr
# blockdev --rereadpt /dev/sdhs 
# blockdev --rereadpt /dev/sdht 
# blockdev --rereadpt /dev/sdhu 
# blockdev --rereadpt /dev/sdhw 
# blockdev --rereadpt /dev/sdhv 
# blockdev --rereadpt /dev/sdhx 
# blockdev --rereadpt /dev/sdhy

Verify your output and check that the device paths are what you expect; after that execute it on your Oracle VM Server. 

Remember to execute this step on all your OracleVM Servers (OVS) that are part of your pool!!!

3. Refresh physical size of your multipath device

After refresh of all physical paths ( sd* in this case ) you have to refresh and verify the new size of the multipath-device; to accomplish this step execute the command above:

[root@ovm01 scripts]# multipathd -k"resize map 3600143801259961a0000800001170000"
ok


[root@ovmgv02 scripts]# multipath -ll /dev/mapper/3600143801259961a0000800001170000
3600143801259961a0000800001170000 dm-47 HP,HSV360
size=300G features='0' hwhandler='0' wp=rw
|-+- policy='round-robin 0' prio=1 status=active
| `- 2:0:0:29 sdhr 134:16  active ready running
|-+- policy='round-robin 0' prio=1 status=enabled
| `- 2:0:1:29 sdhs 134:32  active ready running
|-+- policy='round-robin 0' prio=1 status=enabled
| `- 2:0:2:29 sdht 134:48  active ready running
|-+- policy='round-robin 0' prio=1 status=enabled
| `- 2:0:3:29 sdhu 134:64  active ready running
|-+- policy='round-robin 0' prio=1 status=enabled
| `- 3:0:1:29 sdhw 134:96  active ready running
|-+- policy='round-robin 0' prio=1 status=enabled
| `- 3:0:0:29 sdhv 134:80  active ready running
|-+- policy='round-robin 0' prio=1 status=enabled
| `- 3:0:2:29 sdhx 134:112 active ready running
`-+- policy='round-robin 0' prio=1 status=enabled
  `- 3:0:3:29 sdhy 134:128 active ready running

Remember to execute this step on all your OracleVM Servers (OVS) that are part of your pool!!!

4. Verify actual repository size and extend the ocfs2 filesystem 

View actual repository size:
[root@ovm01 ~]# df -k /dev/mapper/3600143801259961a0000800001170000
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/3600143801259961a0000800001170000
262144000 235312128  26831872  90% /OVS/Repositories/0004fb0000030000480c7108c43bcaaa

Extend ocfs2 filesystem:
comment on "man" of tunefs.ocfs2:
option -S, --volume-size
Grow the size of the OCFS2 file system. If blocks-count is not specified, tunefs.ocfs2 extends the volume to the current size of the device.

So:
[root@ovm01 ~]# tunefs.ocfs2 -S /dev/mapper/3600143801259961a0000800001170000
NB: just run the command "tunefs.ocfs2" once, on one node part of the ocfs2 cluster.
View new repository size: 
[root@ovm01 ~]# df -k /dev/mapper/3600143801259961a0000800001170000
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/3600143801259961a0000800001170000
314572800 235315200  79257600  75% /OVS/Repositories/0004fb0000030000480c7108c43bcaaa
Refresh repository by OVM-Manager
By Oracle VM Manager refresh your repository to acknowledge the new repository size; here an example on Oracle VM Manager 3.2.1:

 

This article is dedicated to the person who keeps me up at night, little Joseph, my son, born January 9, 2013.

Comments and corrections are welcome.

Simon COTER 

About

Simon Coter is a Principal Product Manager for Oracle VM and VirtualBox.

Search

Categories
Archives
« June 2016
SunMonTueWedThuFriSat
   
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  
       
Today