Tuesday, March 16, 2021

OVM -- license / CPU-cores alignment , CPU Pinning , CPU Affinity , OVM Manager + ovm_vmcontrol

As mentioned in my earlier posts (years ago), you need to have your computational resources aligned with your Oracle Database and Application licenses.. 

In virtualized Oracle environments (OVM and KVM), you have the ability to dedicate your cpu cores to your virtual machines and keep them aligned with the licenses you have for your applications and databases.. This can also be thought as a capacity on demand solution.. That is, you grow as you pay and you license only the cpu cores you use.. 

Doing such a configuration starts with analyzing the licenses you have. If you have CPU-core license, you take your license counts and divide it with the core factor (for intel it is 0.5) to get the maximum count of cpus that you can have with  those license you have.. For user named plus licenses, you also need to be sure that your user count is aligned with the user count defined in your named plus license.. But! again, you need to be aligned with the cpu count.. In other words, you can't have a 24 core machine to host a database or application which is licensed with 25 named users. So, there is a user count & cpu count alignment as well..

Okay enough with the intro : ) Check the articles below for more on this topic.

https://ermanarslan.blogspot.com/2017/03/rdbms-licensing-cpu-limits-for-named.html

https://ermanarslan.blogspot.com/2017/01/oda-quick-tip-for-cpu-vcpu-counts-named.html

In this blog post, I will give you the technical side for implementing license & cpu alignment in OVM environments..

So, as you can guess we configure Guest VM cpu resources according to the licenses we have.. But! not only that, we also neet do implement cpu pinning for the Guest VM to dedicate them to the specific CPU cores according to our license count.. Without this pinning action, it is not accepted to license only the cores that we use.. In other words, if you don't do this pinning action, you will need license all the cores on your Oracle VM server. (it is the same in KVM environments as well)

In order to configure the cpu cores of a guest machine and set CPU pinning, we use OVM Manager and Oracle VM Virtual Machine Control (ovm_vmcontrol utility.) -- supposing we are dealing with Oracle VM 3.4 and on-wards.. Note that, it is better to be on 3.4.3 and on-wards, because; on 3.4.1 and 3.4.2, CPU pinning with ovm_vmcontrol utility on running guest does not work.

We first start by setting the maximum number of virtual CPU cores (maxvcpu) and actual number of virtual cpu cores (vcpu) for our Guest VM.. We use OVM Manager for this task.

Note that, these numbers(maxvcpu and vcpu) are actually based on threads, not based actual physical cores.

In this context, if we have a 4 core intel - Linux machine and if we have hyper threading enabled, our host sees those cores as 8 threads. So, there in OVM Manager, we set maxvcpu and vcpu counts for a guest machine based on the thread count.

Note that, if we change maximum number of cpus for a Guest VM we need to reboot that vm after the value is changed.

Well.. Suppose we set the maxcpu to 4 and vcpu to 4.. With this config, we actually make or Guest VM  use 4 threads. However; in order to get benefit from capacity on demand (aligned Cpu cores and licenses), we need to set CPU pinning for those 4 threads as well and we do that by using ovm_vmcontrol.

A quick command toolbox for getting cpu related info from our OVM host -> 

xm info
xenpm get-cpu-topology
xm vcpu-list

In order to use the vm_vmcontrol, we need to download and install it first..


ovm_vmcontrol is delivered by -> Patch 13602094: ORACLE VM 3.0 UTILS RELEASES: 1.0.2, 2.0.1, 2.1.0

We install the tool on the OVM Manager host. (in my opinion, this is easiest installation method)

We unzip it in /u01/app/oracle/ovm-manager-3 directory and if the OS user of the OVM Manager has java installed, no further actions required.

Before using the tool, we check our cpu topology and get the info about our threads and physical cores.
Below, we see a a single socket server with 4 cores and 2 threads per core.

# xenpm get-cpu-topology
CPU core socket node
CPU0 0 0 0
CPU1 0 0 0
CPU2 1 0 0
CPU3 1 0 0
CPU4 2 0 0
CPU5 2 0 0
CPU6 3 0 0
CPU7 3 0 0

In the above outputs, the CPU lines represents the threads.. So CPU0 is thread 0 of core 0. CPU1 is thread 1 of core 0.. CPU 2 is the thread 0 of core 1 etc.. 

So we have 2 threads in each core.. So if we have 2 core license for this Guest VM, we need to pin those 4 vcpus (threads) to 2 physical cores..  for instance, to -> Core 0 and Core 1

In the above output, cpu 0,1,2,3 are the threads that correspond to core 0 and core 1 and that's why our ovm_vmcontrol command in this case will be similar to following;

 ./ovm_vmcontrol -u admin -p <admins_password> -h <ovm_managers_hostname> -v <guest_machine_name> -c setvcpu -s 0-3

Got the point right?

You can also get the cpu pinning related info for a vm using a ovm_vmcontrol command similar to following;

 ./ovm_vmcontrol -u admin -p <admins_password> -h <ovm_managers_hostname> -v <guest_machine_name> -c getvcpu

The command above lets you check the current pinning configuration of a vm..

" xm vcpu-list" also gives you that info in its output -- exactly the values under the column named Cpu affitinity.

# xm vcpu-list
Name ID VCPU CPU State Time(s) CPU Affinity
0003fb00000600007c351fa24276c63f 1 0 5 -b- 4676.8 0-3
Domain-0 0 0 0 -b- 932.1 any cpu
Domain-0 0 1 6 -b- 1168.0 any cpu

Some references in this context:

https://www.oracle.com/technetwork/server-storage/vm/ovm-hardpart-168217.pdf

https://docs.oracle.com/cd/E50245_01/E50251/html/vmadm-utils-vmcontrol.html

Set CPU Pinning for VMs on Oracle VM 3.4.1 and 3.4.2 (Doc ID 2213691.1)

https://docs.oracle.com/cd/E50245_01/E50251/html/vmadm-utils-vmcontrol.html

No comments :

Post a Comment

If you will ask a question, please don't comment here..

For your questions, please create an issue into my forum.

Forum Link: http://ermanarslan.blogspot.com.tr/p/forum.html

Register and create an issue in the related category.
I will support you from there.