Não vou me deter muito aos detalhes a ideia aqui é fazer uma "receita" e tornar o post em uma tarefa prática.
Bom, após a instalação do S.O. teremos que executar os seguintes passos:
--------------------------------------------------------------------------------------------------------------------------
1. Alterar o modo de funcionamento do SELinux de "Enforcing" para "Permissive".
[root@localhost ~]# vim /etc/selinux/config
SELINUX=Permissive
[root@localhost ~]# setenforce 0
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
2. Desabilitar temporariamente o firewall.
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
3. Instalar o repositório oficial do Xen via YUM bem como os pacotes necessários para a virtualização.
[root@localhost ~]# yum install centos-release-xen
[root@localhost ~]# yum install kernel-xen xen xen-libs xen-devel xen-libs libvirt virt-viewer python-virtinst libvirt-daemon-xen
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
4. Executar o script que adicionará a entrada do Xen no GRUB.
[root@localhost ~]# /usr/bin/grub-bootxen.sh
[root@localhost ~]# reboot
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
5. Procurar a interface principal a qual será a interface ponte para o Xen
[root@localhost ~]# ip route show | grep 'default' | awk '{print $5}'
em1
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
6. Criar a interface bridge (xenbr0)
[root@localhost ~]# nmcli con add type bridge con-name xenbr0 ifname xenbr0
[root@localhost ~]# nmcli con modify xenbr0 bridge.stp no
[root@localhost ~]# nmcli con modify xenbr0 bridge.hello-time 0
6.1. Verificar o nome da interface principal (No caso é a em1)
[root@localhost ~]# nmcli con show
NOME UUID TIPO DISPOSITIVO
xenbr0 49586081-0873-4991-844f-7376785df72d bridge xenbr0
em1 f2b77882-0402-410f-9bed-438f3f36d00e 802-3-ethernet em1
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
7. Configurar a interface em1 como "slave" da xenbr0
[root@localhost ~]# nmcli con modify "em1" connection.master xenbr0 connection.slave-type bridge
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
8. Inserir as informações de rede como: IP, gateway e DNS para o novo arquivo ifcfg-xenbr0
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-xenbr0
BOOTPROTO=none
IPADDR0=10.0.0.111
PREFIX0=24
GATEWAY0=10.0.0.1
DNS1=10.0.0.253
DNS2=10.0.0.254
DOMAIN=meudominio.com.br
[root@localhost ~]# reboot
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
No Xen temos a possibilidade de executar 2 tipos de virtualização Hardware Virtual Machine (HVM) e ParaVirtual Machine (PVM).
9. Neste passo daremos inicio a criação e configuração de um guest, criando um arquivo de configuração "modelo", que a priori será no formato de HVM.
[root@localhost ~]# cd /etc/xen
[root@localhost xen]# vim modelo
vcpus = '2'
memory = '2048'
disk = [
'phy:/dev/vg/modelo,xvda,w',
'file:/opt/iso/CentOS-7-x86_64-Minimal-1511.iso,hdc:cdrom,r'
]
boot='dc'
name = 'modelo'
vif = [ 'ip=x.x.x.x,mac=xx:xx:xx:xx:xx:xx,bridge=xenbr0' ]
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
kernel = "hvmloader"
builder = 'hvm'
vfb = [ "type=vnc, vncpasswd=, vnclisten=0.0.0.0" ]
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
10. Iniciar VM
[root@localhost xen]# xl create -c modelo
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
[root@localhost xen]# vncviewer :0
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
[root@localhost xen]# vim modelo
name = 'modelo'
vcpus = '2'
memory = '2048'
bootloader = "/usr/lib64/xen/bin/pygrub"
disk = [
'phy:/dev/vg/modelo,xvda,w',
]
boot='c'
vif = [ 'ip=x.x.x.x,mac=xx:xx:xx:xx:xx:xx,bridge=xenbr0' ]
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
#kernel = "hvmloader"
#builder = 'hvm'
vfb = [ "type=vnc, vncpasswd=, vnclisten=0.0.0.0" ]
Pronto, finalizamos a criação de uma VM em PVM!
4. Executar o script que adicionará a entrada do Xen no GRUB.
[root@localhost ~]# /usr/bin/grub-bootxen.sh
[root@localhost ~]# reboot
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
5. Procurar a interface principal a qual será a interface ponte para o Xen
[root@localhost ~]# ip route show | grep 'default' | awk '{print $5}'
em1
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
6. Criar a interface bridge (xenbr0)
[root@localhost ~]# nmcli con add type bridge con-name xenbr0 ifname xenbr0
[root@localhost ~]# nmcli con modify xenbr0 bridge.stp no
[root@localhost ~]# nmcli con modify xenbr0 bridge.hello-time 0
6.1. Verificar o nome da interface principal (No caso é a em1)
[root@localhost ~]# nmcli con show
NOME UUID TIPO DISPOSITIVO
xenbr0 49586081-0873-4991-844f-7376785df72d bridge xenbr0
em1 f2b77882-0402-410f-9bed-438f3f36d00e 802-3-ethernet em1
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
7. Configurar a interface em1 como "slave" da xenbr0
[root@localhost ~]# nmcli con modify "em1" connection.master xenbr0 connection.slave-type bridge
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
8. Inserir as informações de rede como: IP, gateway e DNS para o novo arquivo ifcfg-xenbr0
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-xenbr0
BOOTPROTO=none
IPADDR0=10.0.0.111
PREFIX0=24
GATEWAY0=10.0.0.1
DNS1=10.0.0.253
DNS2=10.0.0.254
DOMAIN=meudominio.com.br
[root@localhost ~]# reboot
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
No Xen temos a possibilidade de executar 2 tipos de virtualização Hardware Virtual Machine (HVM) e ParaVirtual Machine (PVM).
9. Neste passo daremos inicio a criação e configuração de um guest, criando um arquivo de configuração "modelo", que a priori será no formato de HVM.
[root@localhost ~]# cd /etc/xen
[root@localhost xen]# vim modelo
vcpus = '2'
memory = '2048'
disk = [
'phy:/dev/vg/modelo,xvda,w',
'file:/opt/iso/CentOS-7-x86_64-Minimal-1511.iso,hdc:cdrom,r'
]
boot='dc'
name = 'modelo'
vif = [ 'ip=x.x.x.x,mac=xx:xx:xx:xx:xx:xx,bridge=xenbr0' ]
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
kernel = "hvmloader"
builder = 'hvm'
vfb = [ "type=vnc, vncpasswd=, vnclisten=0.0.0.0" ]
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
10. Iniciar VM
[root@localhost xen]# xl create -c modelo
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
11. Iniciar o VNC Client para que possamos interagir com a VM num primeiro momento dando inicio a instalação do S.O.
[root@localhost xen]# vncviewer :0
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
12. Não vou me deter a instalação do CentOS, haja vista a grande quantidade de tutoriais na Internet. Sendo assim, finalizada a instalção do S.O. vamos alterar o arquivo de configuração do guest de HVM para PVM
[root@localhost xen]# vim modelo
name = 'modelo'
vcpus = '2'
memory = '2048'
bootloader = "/usr/lib64/xen/bin/pygrub"
disk = [
'phy:/dev/vg/modelo,xvda,w',
]
boot='c'
vif = [ 'ip=x.x.x.x,mac=xx:xx:xx:xx:xx:xx,bridge=xenbr0' ]
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
#kernel = "hvmloader"
#builder = 'hvm'
vfb = [ "type=vnc, vncpasswd=, vnclisten=0.0.0.0" ]
Pronto, finalizamos a criação de uma VM em PVM!
Qualquer sugestão ou dúvida coloquem nos comentários.