tuto:virtualisation:virt_install_cos5

Ceci est une ancienne révision du document !


Installation d'un hôte sous CentOS 5 pour héberger des machines virtuelles

Configurer les dépôts RPMForge, EPEL, ATRpms, fws (voir cette page)

Certains outils sont indispensables

yum --enablerepo=rpmforge install htop screen strace
yum --enablerepo=epel --enablerepo=fws install virt-stack

Pour avoir les dernières versions:

yum --enablerepo=epel --enablerepo=fws --enablerepo=fws-testing install virt-stack

Pour pouvoir connecter les VM sur le réseau local (ou les réseau locaux à l'hôte physique, il peut s'agir de DMZ, ou n'importe quel sous-réseau connecté à l'hôte physique), il faut que ces interfaces fassent partie d'un bridge (=switch virtuel)

cd /etc/sysconfig/network-scripts
cat <<EOF > ifcfg-eth0
DEVICE=eth0
HWADDR=00:16:76:D6:C9:45
ONBOOT=yes
BRIDGE=br0
EOF

En adaptant l'adresse mac (ici 00:16:76:D6:C9:45)

  • Pour un bridge configuré via DHCP:
cat <<EOF > ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
DELAY=0
EOF
  • Pour une configuration en IP fixe
cat <<EOF > ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
IPADDR=192.168.7.2
NETMASK=255.255.255.0
BROADCAST=192.168.7.255
NETWORK=192.168.7.0
ONBOOT=yes
DELAY=0
EOF

Le plus simple est d'utiliser un tunnel SSH. Pour cela, nous allons utiliser un compte avec des privilèges réduits:

groupadd libvirt
useradd -c 'Firewall Services' -m -d /home/fws -s /bin/bash fws
usermod -a -G libvirt fws

Éditer le fichier /etc/libvirt/libvirtd.conf et dé-commenter les lignes unix_sock_group et unix_sock_rw_perms

#################################################################
#
# UNIX socket access controls
#

# Set the UNIX domain socket group ownership. This can be used to
# allow a 'trusted' set of users access to management capabilities
# without becoming root.
#
# This is restricted to 'root' by default.
unix_sock_group = "libvirt"

# Set the UNIX socket permissions for the R/O socket. This is used
# for monitoring VM status only
#
# Default allows any user. If setting group ownership may want to
# restrict this to:
#unix_sock_ro_perms = "0777"

# Set the UNIX socket permissions for the R/W socket. This is used
# for full management of VMs
#
# Default allows only root. If PolicyKit is enabled on the socket,
# the default will change to allow everyone (eg, 0777)
# 
# If not using PolicyKit and setting group ownership for access
# control then you may want to relax this to:
unix_sock_rw_perms = "0770"
 
# Set the name of the directory in which sockets will be found/created.
#unix_sock_dir = "/var/run/libvirt"
 
#################################################################

Ces modifications permettent à tout les utilisateurs membre du groupe libvirt de contrôler entièrement libvirt (accès rw sur le socket rw). Pour appliquer les changements, il faut redémarrer libvirt:

/etc/init.d/libvirtd restart
su - fws
cd
mkdir -p .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys

Puis placer votre clef publique dans le fichier authorized_keys

Le monitoring sera assuré par Zabbix. Un proxy sera installé sur la machine physique pour pouvoir remonter les info de toutes les machines virtuelles

yum --enablerepo=rpmforge --enablerepo=fws install zabbix-agent zabbix-proxy-sqlite3 --exclude=*i386
  • tuto/virtualisation/virt_install_cos5.1282840754.txt.gz
  • Dernière modification: 26/08/2010 18:39
  • de dani