Olá pessoal, faz um tempo que não publico nada por aqui, então estou trazendo este post sobre Exadata com OVM para tirar as teias de aranha do blog e contribuir com o Oracle Developers Community Appreciation Day que o Tim Hall, do Oracle-Base, organiza todo ano #ThanksODC 🙂
A ideia aqui é permitir que os VM Domains aumentem suas CPUs dinamicamente neste ambiente Exadata.

Alterando o arquivo de configuração da VM no Compute Node do Exadata
Primeiro de tudo você precisa alterar o arquivo de configuração da VM.
Existem 2 parâmetros relacionados a CPU neste arquivo. O parâmetro cpu define o número inicial de CPUs e o max_cpus é a quantidade máxima de CPUs que pode ser atribuída à VM.
No cenário atual temos os parâmetros cpu e max_cpus configurados com o mesmo valor, 12. Então, para conseguir aumentar os cores de CPU sem precisar reiniciar a VM, precisamos ter o parâmetro max_cpus com um valor maior que o do parâmetro cpu.
Vamos configurar o max_cpus para 68 e desligar a VM para que esse arquivo vm.cfg seja lido novamente. Lembre-se de que apenas reiniciar (reboot) a VM não é suficiente, pois o arquivo não é relido durante o reboot.
Vamos verificar a configuração atual da VM:
[root@exadb3 ~]# xm list -l vm5.loredata.com.br |grep cpus
(vcpus 12)
(cpus
(online_vcpus 12)
vcpus e online_cpus são iguais, então não conseguimos aumentar os cores de CPU online.
Primeira coisa, alterar o max_cpus para 68 no arquivo de parâmetros vm.cfg:
[root@exadb3 ~]# vi /EXAVMIMAGES/GuestImages/vm5.loredata.com.br/vm.cfg
acpi = 1
apic = 1
pae = 1
builder = 'hvm'
kernel = '/usr/lib/xen/boot/hvmloader'
device_model = '/usr/lib/xen/bin/qemu-dm'
# To make VMs with more than 12 vCPUs work on exadata server
# 1: Processor Info and Feature Bits
# This returns the CPU's stepping, model, and family information in EAX (also called the signature of a CPU),
# feature flags in EDX and ECX, and additional feature info in EBX.
# The format of the information in EAX is as follows:
# 3:0 - Stepping
# 7:4 - Model
# 11:8 - Family
# 13:12 - Processor Type
# 19:16 - Extended Model
# 27:20 - Extended Family
# Each register has 32 bits with 31st bit in the left end and 0 bit in the right end.
# edx register:
# 12 bit - Memory Type Range Registers. Force to 0 set uncached access mode to memory ranges.
# Each successive character represent a lesser-significant bit:
# '1' -> force the corresponding bit to 1
# '0' -> force to 0
# 'x' -> Get a safe value (pass through and mask with the default policy)
# 'k' -> pass through the host bit value
# 's' -> as 'k' but preserve across save/restore and migration
# 33222222222211111111110000000000
# 10987654321098765432109876543210
cpuid = ['1:edx=xxxxxxxxxxxxxxxxxxx0xxxxxxxxxxxx']
disk = ['file:/OVS/Repositories/eb37ee72b0e84062b2abc40cd67534eb/VirtualDisks/214ed0feb0a64e8ea7bd1bf96f8b4fac.img,xvda,w','file:/OVS/Repositories/eb37ee72b0e84062b2abc40cd67534eb/VirtualDisks/68140ae48d814c9f9afe453637053bbb.img,xvdb,w','file:/OVS/Repositories/eb37ee72b0e84062b2abc40cd67534eb/VirtualDisks/cba34f1848ba44b5b86c2a2a4dfb3ae7.img,xvdc,w','file:/OVS/Repositories/eb37ee72b0e84062b2abc40cd67534eb/VirtualDisks/85e41dddc2164434910b33e2280fc416.img,xvdd,w','file:/OVS/Repositories/eb37ee72b0e84062b2abc40cd67534eb/VirtualDisks/490bab94f8f343929bea4fd6328d708c.img,xvde,w','file:/OVS/Repositories/eb37ee72b0e84062b2abc40cd67534eb/VirtualDisks/392cb72d94aa411da152082c885be76b.img,xvdf,w']
memory = '65536'
maxmem = '65536'
OVM_simple_name = 'Exadata VM'
name = 'vm5.loredata.com.br'
OVM_os_type = 'Oracle Linux 6'
vcpus = 12
maxvcpus = 68
uuid = 'eb37ee72b0e84062b2abc40cd67534eb'
on_crash = 'restart'
on_reboot = 'restart'
serial = 'pty'
keymap = 'en-us'
vif = ['type=netfront,mac=00:16:3e:01:1f:8f,bridge=vmeth3.224','type=netfront,mac=00:16:3e:26:9d:ae,bridge=vmeth0','type=netfront,mac=00:16:3e:20:c4:f6,bridge=vmbondeth0.200']
timer_mode = 2
ib_pfs = ['03:00.0']
ib_pkeys = [{'pf':'03:00.0','port':'1','pkey':['0xffff',]},{'pf':'03:00.0','port':'2','pkey':['0xffff',]},]
Agora vamos parar o banco de dados que está rodando nesta VM:
[oracle@vm5 ~]$ srvctl stop database -d orcl
E desligar a VM:
[root@exadb3 ~]# xm shutdown vm5.loredata.com.br -w
Domain vm5.loredata.com.br terminated
All domains terminated
Depois de desligada é só iniciar de novo com o arquivo vm.cfg correto:
[root@exadb3 ~]# xm create /EXAVMIMAGES/GuestImages/vm5.loredata.com.br/vm.cfg -c
Using config file "/EXAVMIMAGES/GuestImages/vm5.loredata.com.br/vm.cfg"
Quando os recursos do CRS estiverem online novamente, inicie o banco de dados que foi parado anteriormente:
[oracle@vm5 ~]$ srvctl start database -d orcl
Vamos verificar se a mudança foi aplicada no restart da VM:
[root@exadb3 ~]# xm list -l vm5.loredata.com.br |grep cpus
(vcpus 68)
(cpus
(online_vcpus 12)
Aumentando os cores de CPU online
Agora, se quisermos aumentar os cores de CPU da VM online, basta fazer:
[root@exadb3 ~]# xm vcpu-set vm5.loredata.com.br 36
Vamos verificar se realmente mudou:
[root@exadb3 ~]# xm list -l vm5.loredata.com.br |grep cpus
(vcpus 68)
(cpus
(online_vcpus 36)
Legal! Funcionou como esperado.
Só mais uma coisa… depois que as CPUs são aumentadas online, ainda é preciso alterar o parâmetro cpu no arquivo vm.cfg para o próximo restart. Então vamos alterá-lo:
[root@exadb3 ~]# vi /EXAVMIMAGES/GuestImages/vm5.loredata.com.br/vm.cfg
acpi = 1
apic = 1
pae = 1
builder = 'hvm'
kernel = '/usr/lib/xen/boot/hvmloader'
device_model = '/usr/lib/xen/bin/qemu-dm'
# To make VMs with more than 12 vCPUs work on exadata server
# 1: Processor Info and Feature Bits
# This returns the CPU's stepping, model, and family information in EAX (also called the signature of a CPU),
# feature flags in EDX and ECX, and additional feature info in EBX.
# The format of the information in EAX is as follows:
# 3:0 - Stepping
# 7:4 - Model
# 11:8 - Family
# 13:12 - Processor Type
# 19:16 - Extended Model
# 27:20 - Extended Family
# Each register has 32 bits with 31st bit in the left end and 0 bit in the right end.
# edx register:
# 12 bit - Memory Type Range Registers. Force to 0 set uncached access mode to memory ranges.
# Each successive character represent a lesser-significant bit:
# '1' -> force the corresponding bit to 1
# '0' -> force to 0
# 'x' -> Get a safe value (pass through and mask with the default policy)
# 'k' -> pass through the host bit value
# 's' -> as 'k' but preserve across save/restore and migration
# 33222222222211111111110000000000
# 10987654321098765432109876543210
cpuid = ['1:edx=xxxxxxxxxxxxxxxxxxx0xxxxxxxxxxxx']
disk = ['file:/OVS/Repositories/eb37ee72b0e84062b2abc40cd67534eb/VirtualDisks/214ed0feb0a64e8ea7bd1bf96f8b4fac.img,xvda,w','file:/OVS/Repositories/eb37ee72b0e84062b2abc40cd67534eb/VirtualDisks/68140ae48d814c9f9afe453637053bbb.img,xvdb,w','file:/OVS/Repositories/eb37ee72b0e84062b2abc40cd67534eb/VirtualDisks/cba34f1848ba44b5b86c2a2a4dfb3ae7.img,xvdc,w','file:/OVS/Repositories/eb37ee72b0e84062b2abc40cd67534eb/VirtualDisks/85e41dddc2164434910b33e2280fc416.img,xvdd,w','file:/OVS/Repositories/eb37ee72b0e84062b2abc40cd67534eb/VirtualDisks/490bab94f8f343929bea4fd6328d708c.img,xvde,w','file:/OVS/Repositories/eb37ee72b0e84062b2abc40cd67534eb/VirtualDisks/392cb72d94aa411da152082c885be76b.img,xvdf,w']
memory = '65536'
maxmem = '65536'
OVM_simple_name = 'Exadata VM'
name = 'vm5.loredata.com.br'
OVM_os_type = 'Oracle Linux 6'
vcpus = 36
maxvcpus = 68
uuid = 'eb37ee72b0e84062b2abc40cd67534eb'
on_crash = 'restart'
on_reboot = 'restart'
serial = 'pty'
keymap = 'en-us'
vif = ['type=netfront,mac=00:16:3e:01:1f:8f,bridge=vmeth3.224','type=netfront,mac=00:16:3e:26:9d:ae,bridge=vmeth0','type=netfront,mac=00:16:3e:20:c4:f6,bridge=vmbondeth0.200']
timer_mode = 2
ib_pfs = ['03:00.0']
ib_pkeys = [{'pf':'03:00.0','port':'1','pkey':['0xffff',]},{'pf':'03:00.0','port':'2','pkey':['0xffff',]},]
Por hoje é só pessoal.
Espero que tenham gostado. Nos próximos dias vou publicar mais posts sobre Oracle VM.
Abraços,
Franky

Be careful with this. It works great, but afaik (And have been told) you pay the licenses on the hwm (high watermark) of the max vcpus. This is also stored in the enterprise manager repo or other tooling you need to use for trusted partitions.
That brings the advantage of cost savings by limiting licenses in danger.
Just something to think about.