Upload
opennebula-project
View
1.935
Download
2
Embed Size (px)
Citation preview
OpenNebulaTutorial
© OpenNebula Project. Creative Commons Attribution-NonCommercial-ShareAlike License
Rev20171113
A Typical OpenNebula EnvironmentPlanning the Installation
• Repository of VM images• Multiple Backends (LVM, Ceph)
Monitoring,Virtualization, Storage and Network
• Provides physical resources for the VMs• Must have a hypervisor installed
Virtual LabThe Environment
lab-X-node1
OpenNebulaoned, sunstone, etc...
NFS Server
lab-X-node2
KVM & Libvirt
NFS Client
Bridge br0(ens4)
VM 1 VM 2 VM 3
lab-X-node3
KVM & Libvirt
NFS Client
Bridge br0(ens4)
VM 4 VM 5 VM 6
VM communication
DatastoreImages
4Installing and Basic Usage
Virtual LabAccessing the environment
● Each lab has 2 virtual machines:
○ lab-X-node1: opennebula & hypervisor
○ lab-X-node2: just the hypervisor
5Installing and Basic Usage
Virtual LabAccessing the environment
● You can ssh to your environment like this
$ ssh [email protected]
-L 9869:lab-X-node1:9869 \
-L 29876:lab-X-node1:29876
(password is 'onecourse!')
$ ssh lab-X-node1
(where 'X' is your lab number!)
6Installing and Basic Usage
Virtual Lab
http://putty.org/
8Installing and Basic Usage
(password is 'onecourse!')
(where 'X' is your lab number!)
Virtual Lab
9Installing and Basic Usage
Environment
● The root password for both lab nodes is opennebula● OpenNebula 5.4.3 is installed● Switch to the oneadmin account to use OpenNebula● Both nodes are registered and configured● Ubuntu 16.04 template available● Sunstone is available in your laptop
○ open: http://localhost:9869○ login / password: oneadmin / opennebula○ you must keep the ssh connection open!!!
10Installing and Basic Usage
Virtual LabAccessing the environment
From there, you can jump to the nodes: node2 and node3
[root@lab-1-node1 ~]# ssh lab-1-node2
The password is opennebula
11Installing and Basic Usage
Virtual LabInspecting the environment - Packages
Hands on (node1)
Let's see what packages have been installed:
$ rpm -qa | grep opennebula
These packages have already been installed from the repo located in /etc/yum.repos.d/opennebula.repo. They have been installed with yum install (you don't need to do this).
Check the packages installed in node2 or node3, they're not the same!
12Installing and Basic Usage
Virtual LabInspecting the environment - Services
Hands on (node1)
Let's see what services are running:
$ systemctl | grep opennebula
These services have been enabled to start automatically when the VM boots (systemctl enable <service>).
node2 and node3 has libvirt running.
13Installing and Basic Usage
Virtual LabInspecting the environment - Storage
Hands on (node1)
node1 is exporting /srv by NFS (check /etc/exports)
The datastores are shared:
$ file /var/lib/one/datastores/*
/var/lib/one/datastores/0: symbolic link to `/srv/0'
/var/lib/one/datastores/1: symbolic link to `/srv/1'
/var/lib/one/datastores/2: directory
Check /etc/fstab and file /var/lib/one/datastores/* in node2 and node3.
14Installing and Basic Usage
Virtual LabInspecting the environment - Network
Hands on (node2)
● node2 and node3 have a bridge br0● VMs will be connected to br0● br0 is linked to ens4● ens4 is the private communication between the VMs
Verify with these commands:
brctl show
cat /etc/sysconfig/network-scripts/ifcfg-br0
15Installing and Basic Usage
Virtual LabInspecting the environment - SSH access
Hands on (node1)
It is necessary to be able to ssh from any node to any other node without password as oneadmin
Verify:# Make sure you are oneadmin in node1
$ su - oneadmin
# ssh to the same node
$ ssh lab-X-node1 hostname
# ssh to the other nodes
$ ssh lab-X-node2 hostname
$ ssh lab-X-node3 hostname
16Installing and Basic Usage
Virtual LabInspecting the environment - OpenNebula Configuration
Configuration changes:
--- /etc/one/oned.conf.orig
+++ /etc/one/oned.conf
@@ -82 +82 @@
-DB = [ BACKEND = "sqlite" ]
+DB = [ BACKEND="mysql", SERVER="localhost", PORT=3306, USER="oneadmin", PASSWD="oneadmin", DB_NAME="opennebula" ]
--- /etc/one/sched.conf.orig
+++ /etc/one/sched.conf
@@ -74 +74 @@
-SCHED_INTERVAL = 30
+SCHED_INTERVAL = 5
17Installing and Basic Usage
Virtual LabInspecting the environment - OpenNebula Configuration
Configuration changes:
--- /etc/one/vmm_exec/vmm_exec_kvm.conf.orig
+++ /etc/one/vmm_exec/vmm_exec_kvm.conf
@@ -37 +37 @@
-DISK = [ driver = "raw" , cache = "none"]
+DISK = [ driver = "raw", cache = "unsafe", total_iops_sec = "50" ]
--- /etc/one/onegate-server.conf.orig
+++ /etc/one/onegate-server.conf
@@ -27 +27 @@
-:host: 127.0.0.1
+:host: 192.168.0.1
18Installing and Basic Usage
Virtual LabInspecting the environment - OpenNebula Password
The oneadmin password is located here:
$ cat /var/lib/one/.one/one_auth
oneadmin:opennebula
The first time OpenNebula starts, it sets the password from the contents of this file.
19Installing and Basic Usage
Virtual LabInstallation
Summary of the installation:
● Install the repo: /etc/yum.repos.d/opennebula.repo
● Install packages: yum install opennebula …
● Install gems: /usr/share/one/install_gems
● Enable OpenNebula services
● Configure Storage
● Configure Network
● Configure passwordless ssh access
● OpenNebula configuration files
20Installing and Basic Usage
CLIOpenNebula Interfaces
Hands on (node1)
Overview of the CLI (as oneadmin)
# su - oneadmin
$ oneuser show
$ oneuser –h
$ one[TAB]
All the CLI commands should be executed as the oneadmin user. Remember to switch to the oneadmin user always!
21Installing and Basic Usage
CLIOpenNebula Interfaces
$ one[TAB]
oneuser Manage Users oneimage Manage Images
onegroup Manage Groups onetemplate Manage Templates
oneacl Manage ACLs onevm Manage VMs
onehost Manage Hosts oneacct Accounting Tool
onecluster Manage Clusters onemarket Marketplace Tool
onevnet Manage Networks onedb DB Tool
onedatastore Manage Datastores oneflow Manage flows (services)
oneshowback Showback onemarketapp Import marketapps
onevdc Manage VDCs onevrouter Manage virtual routers
onevcenter Import vCenter reources onesecgroup Manage sec. groups
onezone Manage zones
22Installing and Basic Usage
Get User Information - SunstoneInstalling
Try out Sunstone!http://localhost:9869
Login: oneadminPassword: opennebula
23Installing and Basic Usage
Adding Hosts - SunstoneBasic Usage – Hosts
Hands on! (Sunstone)● Create one host in Sunstone:
● Type: KVM● Cluster: Default● Hostname: lab-X-node2
● Watch transition INIT => ON
● Click on the row for more information● Automatic gathering of monitoring data● Take a look at the graphs
24Installing and Basic Usage
Adding Hosts - CLIBasic Usage – Hosts
Hands on! (CLI)(as oneadmin in the Frontend – node1)
$ onehost –h$ onehost create –h
$ onehost create lab-X-node3 –i kvm -v kvm$ onehost list$ onehost top
# Wait for ON ... and then CTRL-C
$ onehost show lab-X-node3$ onehost show 1$ onehost show -x 1
25Installing and Basic Usage
Adding ImagesBasic Usage – ImagesHands on! (Sunstone)● Create a new Image
● Name: ubuntu-16.04● Path: http://192.168.122.1/ubuntu-16.04.qcow2● Advanced Options
● Bus: Virtio● Image mapping driver: qcow2
26Installing and Basic Usage
Overview Basic Usage - Datastores
27Installing and Basic Usage
Overview Basic Usage - Datastores
Hands on! (Sunstone)Datastore 0 (system) and Datastore 1 (default)Change the TM_MAD to qcow2 in both datastores.
28Installing and Basic Usage
Adding NetworksBasic Usage – Networks
Hands on! (Sunstone)
br0
VM VM
Node 2
ens4
br0
Node 3
ens4
VM VM
29Installing and Basic Usage
Adding NetworksBasic Usage – Networks
Hands on! (Sunstone)
General● Name: privateConfiguration● Bridge: br0Addresses● IP start: 192.168.0.100● Size: 100Context● Gateway: 192.168.0.1● DNS: 8.8.8.8
30Installing and Basic Usage
Adding TemplatesBasic Usage – Template
Hands on! (Sunstone)● A template is a Virtual Machine definition ready to be instantiated● It has CPU, Memory, Disks, NIC, Graphical Ports, etc…
General● Name: ubuntu-16.04● Logo: Ubuntu● Description: Testing VM● CPU: 0.3● Memory: 512 MB
Storage● Click ubuntu-16.04
Network● Click private
Input/Output● Enter your keymap. Leave as is
if using a US keyboard.MB, not GB
31Installing and Basic Usage
Adding TemplatesBasic Usage – Template
Hands on! (Sunstone)
Context● Check 'Add OneGate token'● Check 'Report Ready to OneGate''● In the Start script text area type:
touch /tmp/tutorial-test
● Check 'Encode script in Base64'● Custom vars → Key: PASSWORD, Value: opennebula
Click Create
32Installing and Basic Usage
SSH ContextualizationBasic Usage – adding SSH contextualization
Hands on!● Users should be able to access the VMs without password.
● Grab the SSH from here (in lab-X-node1):
cat /var/lib/one/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9nzF1clIaAji5k6eh+3W5GEopFKfuwSWmq88mAStNTX31rnqJeGCqSkw5VwgSdGaaPzPVc3jNvB3l… oneadmin@lab-X-node1
● Copy that key.
33Installing and Basic Usage
SSH ContextualizationBasic Usage – adding SSH contextualization
Hands on!● Paste that key into Sunstone:
34Installing and Basic Usage
InstantiatingBasic Usage – VMs
Hands on! (Sunstone)
● VNC ( root / opennebula )● Network configured using context
ip a
● ping the other machine● migrate the other machine (watch
ping)● live-migrate the other machine
(watch ping)
● Instantiate the template● Deploy 2 VMs● Leave the name blank● Open Virtual Machines● Watch the transition
PENDING => RUNNING● Deployed in different hosts
35Installing and Basic Usage
SSH ContextualizationBasic Usage – adding SSH contextualization
Hands on!● Deploy the VM and check that you can SSH from the node
# as oneadmin in lab-X-node1
ssh [email protected]...
● Obtain the correct IP from the VM information in Sunstone
36Installing and Basic Usage
ContextualizationBasic Usage – VMs
Hands on!Login to the first VM and look at contextualization
Take a look at the contextualization files:
root@ubuntu:~# head -n 11 /var/run/one-context/context.sh.local # Context variables generated by OpenNebulaDISK_ID='1'ETH0_CONTEXT_FORCE_IPV4=''ETH0_DNS=''ETH0_GATEWAY=''ETH0_GATEWAY6=''ETH0_IP='192.168.0.100'ETH0_IP6=''ETH0_IP6_PREFIX_LENGTH=''ETH0_IP6_ULA=''ETH0_MAC='02:00:c0:a8:00:64'
root@ubuntu:~# ls /etc/one-context.d/loc-05-grow-rootfs loc-16-gen-env net-15-hostnameloc-10-network loc-20-set-username-password net-97-start-scriptloc-10-network-pci loc-22-ssh_public_key net-98-execute-scriptsloc-11-dns loc-24-ssh_host_key net-99-report-readyloc-14-mount-swap net-11-fix-loopback
37Installing and Basic Usage
ContextualizationBasic Usage – VMs
Hands on!The file /tmp/tutorial-test has been created thanks to the START SCRIPT text
area:
root@ubuntu:~# ls /tmp/tutorial-test /tmp/tutorial-testroot@ubuntu:~#
38Installing and Basic Usage
Main VM actionsBasic Usage – VMs
suspend VM state saved. Kept in the host.
power off (--hard) Powers off a VM. Kept in the host.
stop VM state saved. Taken to the system datastore.
undeploy (--hard) Powers off a VM. Taken to the system datastore.
reboot (--hard) Reboots the VM.
recover --recreate Cleans the VM and moves it to PENDING.
terminate (--hard) Shuts down a VM, cleans host and VM is removed from OpenNebula.
recover --delete VM is immediately destroyed regardless of state. Recommended only for oneadmin.
39Installing and Basic Usage
Storage: Attach new disk● In the Images tab: Create new Image
● Name: data-100● Type: Generic storage datablock● Empty disk image● Size in MB: 100● Image mapping driver: qcow2● BUS: Virtio
● In the VM info / Storage tab● Attach disk: data-100
● VNC:
fdisk -l
Other VM actionsBasic Usage – VMs
Hands on! (Sunstone)
40Installing and Basic Usage
Other VM actionsBasic Usage – VMs
Hands on! (Sunstone)
● Capacity: Power off first, then resize VM capacity. Memory 768.
● Snapshot● Take (system) snapshot● Modify the VM● Revert
41Installing and Basic Usage
Chmod and Chown, UNIX Style!Permissions
Hands on! (Sunstone)
Make the all the resources previously created usable by everybody
Apply to all the images, templates and virtual networks.Owner could be changed too => chown, chgrp and chmod.
Take a look at Template → Share
42Installing and Basic Usage
Creating GroupsGroups
Hands on!
Admin: Click Create an administrator userUsername: students-adminPassword: …
Check the Permissions tab (no modifications)
43Installing and Basic Usage
Associated ACLsGroups
Hands on!
When a group is created, a new set of ACLs are introduced
44Installing and Basic Usage
VDCsThe Power of VDCs
45Installing and Basic Usage
Three ViewsOpenNebula Views
OpenNebula
Admin Group Admin
Cloud User
46Installing and Basic Usage
The Admin ViewOpenNebula Views
OpenNebula
Admin Group Admin
Cloud User
47Installing and Basic Usage
OpenNebula ViewsConfigure your Cloud from the Admin perspective
OpenNebula
Admin Group Admin
Cloud User
48Installing and Basic Usage
Group Admin ViewUsing Groups
Hands on!Login as students-admin
●Create a student●Assign Quotas (2 VM limit)
49Installing and Basic Usage
User the Cloud as a Cloud UserOpenNebula Views
OpenNebula
Admin Group Admin
Cloud User
50Installing and Basic Usage
Cloud ViewOpenNebula Views
Hands on!
Login as the student and instantiate a new VM
●Select the ubuntu-14.04 template
●Network private
● Explore the VM actions. Power Off and Save VM● With the oneadmin account see the new template and image● Other options: SSH Key, Quotas, Settings
51Installing and Basic Usage
Group Admin ViewUsing Groups
Hands on!Login as students-admin
52Installing and Basic Usage
Explore
FederationOpenNebula can scale by federation many OpenNebula instances.SchedulerThe OpenNebula Scheduler is extremely flexible. Write your own rules you want to guarantee that your vms end up wherever you need them.OneGateSend custom Metrics to OpenNebulaAppMarketDeliver appliances ready to be consumedCloudBurstingScale out your private resources to EC2vOneCloudvCloud Director Replacement with al the OpenNebula Cloud benefits
Other Features
53Installing and Basic Usage
We Will Be Happy to Clarify Any Question
Questions?