Let’s begin installing some packages:
yum install qemu-kvm qemu-kvm-tools libvirt virt-manager
Install the opennebula-node-kvm rpm package (read my previous post for more information) as it’ll configure for you qemu and a policy allowing oneadmin user to use the virtualization api.
yum localinstall opennebula-node-kvm-4.0.1-1.x86_64.rpm
Start the libvirtd service and configure it to start at boot
#/etc/init.d/libvirtd start Starting daemon libvirtd: [ OK ] # chkconfig libvirtd on
Warning: if you’re using SELinux run this command so the authorized keys is accesible for passwordless login using ssh. Also, I’ve change the context for the /var/lib/one/datastore directory to avoid a Permission Denied error (/var/lib/one/datastores/0/0/disk.0: Permission denied) when trying to run a VM with KVM.
chcon -v --type=ssh_home_t /var/lib/one/.ssh/authorized_keys chcon -R --type=virt_image_t /var/lib/one/datastores
Create the /var/tmp/one directory and change the ownership
# mkdir /var/tmp/one # chown oneadmin:oneadmin /var/tmp/one
If you’re using server names, you have to be sure that there’s an entry in your DNS or /etc/hosts for the server name, e.g I have an entry in the /etc/hosts for my server haddock.macto.local
Now as the oneadmin user, let’s create the host with a KVM hypervisor and openvswitch.and check that no errors are shown. Also try to open a ssh to check that no password is used, this will insert your host in the known_hosts file and will prevent ” Host key verification failed” error when monitoring your host.
# su oneadmin $ ssh firstname.lastname@example.org The authenticity of host 'haddock.macto.local(192.168.1.20)' can't be established. RSA key fingerprint is .... Are you sure you want to continue connecting (yes/no)? yes $ exit $ onehost create haddock.macto.local -i kvm -v kvm -n ovswitch ID: 0 $ onehost list ID NAME CLUSTER RVM ALLOCATED_CPU ALLOCATED_MEM STAT 0 haddock.macto.l - 0 0 / 200 (0%) 0K / 5.6G (0%) on
OK status is on, and my host looks good in Sunstone GUI. Perfect.
If “err” is shown after executing the onehost list command, check /var/lib/one/oned.log for errors. I was having the following error because I haven’t installed opennebula-node-kvm after libvirt installation: “error: authentication failed: Authorization requires authentication but no agent is available”
If you’re running openvswitch you can avoid the following errors editing the sudoers file.
- sudo: sorry you must have a tty to run sudo
- sudo: Error deploying virtual machine: sudo: no tty present and no askpass program specified
Edit the sudoers file with visudo and comment the line “Defaults requiretty” , then add the following lines at the end of the file:
oneadmin ALL = NOPASSWD: /sbin/iptables
oneadmin ALL = NOPASSWD: /sbin/ebtables
oneadmin ALL = NOPASSWD: /usr/bin/ovs-vsctl
oneadmin ALL = NOPASSWD: /usr/bin/ovs-ofctl
I’ve also found sometimes this error:
WARNING **: Error connecting to bus: org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
I decided to reboot the machine and the monitor status changed to on.
Tomorrow I’ll explain how to run a virtual machine in OpenNebula.