Proxmox Cookbook - Sample Chapter
Proxmox Cookbook - Sample Chapter
ee
Proxmox Cookbook
Starting with a step-by-step installation of Proxmox nodes along with an illustrated tour of the
Proxmox graphical user interface, this book will get you up and running with the mechanisms
of Proxmox VE. Various entities such as cluster, storage, and firewall are also covered in an
easy-to-understand format. You will then explore various backup solutions and restore mechanisms.
Finally, we will walk through some advanced configurations for VM followed by a list of commands
used for the Proxmox and Ceph clusters through the CLI.
Proxmox Cookbook
Proxmox VE's intuitive interface, High Availability, and unique central management system puts it
on par with the world's best virtualization platforms and makes it the foremost choice for most
system administrators.
Sa
pl
e
and problems
problems efficiently
real-world problems
P U B L I S H I N G
Wasim Ahmed
Proxmox Cookbook
Over 60 hands-on recipes to perform server virtualization and
manage virtualized server solutions with Proxmox
P U B L I S H I N G
Wasim Ahmed
Preface
Proxmox is one of the biggest kept secrets in the world of virtualization. It stands tall with
other major virtualization players, such as VMWare, Xen, Hyper-V, and so on. Since the first
release of Proxmox in 2005, it has become the standard for open source hypervisors. It
is loaded with great features, such as clustering, High Availability, major storage plugins,
firewalls, full KVM/OpenVZ support, and a price that cannot be beaten by any other
virtualization product in the industry. Proxmox provides a rock solid platform to build virtual
environments that are scalable to any size and can be managed entirely from a single GUI. In
a matter of minutes, a standard Proxmox cluster can be raised and brought into production
without any licensing costs.
This book is written to get you familiar with Proxmox by following step-by-step procedures.
The steps are broken down in as simple manner as possible, thereby allowing you to cook
up a Proxmox cluster with minimal effort. This book can also be used as a quick reference to
fall back on when working with a Proxmox hypervisor. Illustrations have been used wherever
possible along with a hands-on approach that enables you to retain the knowledge you've
acquired for a longer period of time. Different topics and features are categorized in different
chapters, making this book an easy read.
Often, we lack a book that is a reference point to get things done quickly. Although there are
other books on Proxmox written in greater detail, a book, such as this one, was needed so
that you could be brought on board with regard to Proxmox in the least amount of time. Each
chapter is written with the aim of doing more and reading less.
Preface
Chapter 2, Getting to Know the Proxmox GUI, introduces the Proxmox graphical user interface
(GUI) through illustrations and guides you through the entire menu system of Proxmox.
Explanations of the functions of different categories of menus are also provided. Each menu
item of different categories has been presented with visual figures along with a description of
their functions.
Chapter 3, Cluster and VM Management, shows you how to create and configure a Proxmox
cluster from the ground up. Topics such as virtual machine creation, migration, and cloning
are also covered in this chapter. At the end of the chapter, you will be capable enough to
manage virtual machines in a Proxmox cluster.
Chapter 4, Network Configurations, shows different network components and how to
configure them in Proxmox. In this chapter, you will have a good understanding of how to a
create virtual network within a Proxmox cluster and how all the components come together
to form a complex network.
Chapter 5, Firewall Configurations, shows how to utilize the Firewall feature of Proxmox. Firewall
is a fairly new feature that has enhanced Proxmox significantly. In this chapter, you will learn
how to enable and configure a firewall for different entities, such as a data center, node,
and VM.
Chapter 6, Storage Configurations, shows different storage plugin options that are available
and how to attach them to a Proxmox cluster. Proxmox provides built-in plugins for a major
storage type. In this chapter, you will learn how to attach a shared storage with Proxmox
and configure it.
Chapter 7, Backup and Restore, shows you how to perform the backup and restore of a virtual
machine in a Proxmox cluster. Backup is an important requirement of any network. This
chapter shows you how to schedule regular backups, snapshots, and restore data in the event
of a disaster.
Chapter 8, Updating and Upgrading Proxmox, shows you the upgrade process to keep
a Proxmox node up to date at all times. Keeping a Proxmox node updated is important
for an issue-free environment. In this chapter, you will learn the proper procedure to
commit updates on a Proxmox node.
Chapter 9, Monitoring Proxmox, shows you the ways in which you can monitor Proxmox
and Ceph clusters using the Zabbix and Ceph dashboards. The steps involved in configuring
a host or virtual machine that needs to be monitored, are covered along with installation
of the Ceph dashboard. At the end of this chapter, you will know how to monitor and
configure notifications.
Preface
Chapter 10, Advanced Configurations for VMs, shows advanced configuration steps to add
features such as sound, PCI passthrough, and more. Advanced configuration extends the
ability of a VM beyond just the basics. This chapter shows steps to make this advanced
configuration work seamlessly.
Chapter 11, The CLI Command Reference, shows you several lists of the most commonly
used commands to manage different aspects of Proxmox, such as a cluster, storage, and
so on. This is a reference chapter for quickly finding the most commonly used commands.
Commands have been listed in different categories for an easy find.
Installing Proxmox
In this chapter, we are going to cover the following Proxmox basics:
Hardware requirements
A Proxmox subscription
Seeking support
Introduction
The Proxmox Virtual Environment (VE) is an open source multinode clustered hypervisor
built on Debian Linux, and is able to run on commodity hardware, thus eliminating any vendor
lock ins. Proxmox is freely available without any features locked. However, a subscription
type license is available to enable a enterprise repository to receive well-tested patches and
updates. Subscriptions are recommended for a production-level Proxmox environment.
A hypervisor is a software or firmware that creates a layer between native
hardware and an operating system to form a virtual environment to create
and run virtual machines. A hypervisor emulates the functions of physical
hardware to enable virtual machines to see them as physical resources.
Installing Proxmox
Proxmox can be configured to run a virtual environment of just a few nodes with virtual
machines or an environment with thousands of nodes. Supporting both KVM and OpenVZ
container-based virtual machines, Proxmox VE is a leading hypervisor today. Proxmox has an
extremely vibrant community ready to provide help to any free Proxmox users. Also, the expert
technical support team of Proxmox is equally capable of handling all corporate users with their
mission critical virtual environment.
As mentioned earlier, Proxmox is a multinode environment, meaning that many nodes can
form a single cluster where a virtual machine can be moved around to any node within the
cluster, thereby allowing a redundant virtual environment. Through a robust Graphical User
Interface (GUI), the entire Proxmox cluster can be managed. As of Proxmox VE 3.4, only one
cluster is manageable through the GUI.
Here are some of the notable features of the Proxmox VE:
A console can be accessed through secured VNC, SPICE, and HTML5-based noVNC.
It provides support for multiple authentication sources, such as local using Pluggable
Authentication Module (PAM), Microsoft ADS, and LDAP.
A Proxmox cluster file system (pmxcfs) can be used to store configuration files for
real-time replication on all nodes using corosync (http://en.wikipedia.org/
wiki/Corosync_%28project%29).
Unlike SOAP, REST is not a protocol but combination of various standards such
as HTTP, JSON, URI and XML. Visit http://www.restapitutorial.com for
information on REST based APIs.
It provides a built-in powerful firewall for host nodes and virtual machines.
It provides migration of VMs between physical hosts with or without shared storage.
It supports mainstream storage types, such as Ceph, NFS, ZFS, Gluster, and iSCSI.
Chapter 1
Hardware requirements
Proxmox can be installed on just about any commodity hardware, but in order to have a stable
platform, some attention is required when selecting nodes. A setup selected for Proxmox
learning can be underpowered and less expansive. While this setup is acceptable for very
small environments and home usage, it will not be adequate for production-level setups where
stability and redundancy is the minimum requirement.
Minimum hardware
Here are the minimum requirements to install Proxmox on a hardware node:
Memory: 1 GB RAM
Based on the minimum requirement of Proxmox, here are examples of Intel and AMD-based
hardware configurations that are suitable for learning:
Processor
Intel
AMD
Processor/CPU
Motherboard
Memory
Corsair 1 x 4 GB DDR3
Corsair 1 x 4 GB DDR3
Requirement
Recommended hardware
To have a stable performing Proxmox cluster, here are the hardware configurations that
are recommended:
16 GB RAM memory
Solid State Drives (SSD) for operating system or SSD for shared storage node
Installing Proxmox
For more details on fencing and HA visit https://pve.proxmox.
com/wiki/Fencing.
The following table lists the configurations of a server node that can be used in a
production environment:
Requirement
Hardware
Processor/CPU
Motherboard
Memory
Power supply
Redundant
Note that the example configurations are for reference only. Your requirement will vary
depending on the work load and expected performance. Adjust the hardware requirements
accordingly by keeping in mind that in a hypervisor more core counts will increase performance
of virtual machines rather than higher clock counts of a processor that is used. With a higher
core count, more threads can be distributed among processors.
It is worth mentioning here that it is better to select a CPU with a higher
cache amount for a node with large amount of memory to minimize the
main memory access and maximize the performance for each CPU cores.
Proxmox is a clustered hypervisor. In order to set up a cluster, a minimum of two nodes are
required. For the purpose of following through this book, when selecting hardware, be sure
to have enough components to set up two nodes.
Although a Proxmox cluster can be set up with just two nodes, a minimum of three nodes are
recommended for a production environment.
Chapter 1
In a cluster, a quorum is established with a minimum of three votes.
Each node is counted as single vote. The cluster health depends on this
democratic system where the majority vote wins. So, in a two node cluster,
when one node fails the other node can only cast one vote, creating an
unresolved situation. With a three node cluster, when one node fails, the
total vote from the remaining nodes is two out of possible three votes. Thus,
the cluster operation continues. By any means, a two node cluster is not
recommended for a production cluster. However, it is still possible to create
using instructions by visiting https://pve.proxmox.com/wiki/TwoNode_High_Availability_Cluster.
Getting ready
We are going to use the Proxmox VE installation disk to install Proxmox. First, we need to
prepare a disk with the Proxmox installation ISO image.
How to do it
Here are the steps to install Proxmox:
1. Download the Proxmox ISO image by visiting http://proxmox.com/downloads/
category/iso-images-pve.
2. Use a burning software to copy the ISO image on to a DVD disk.
3. Boot the physical node from the disk prepared from ISO to start the
installation process.
Installing Proxmox
There's more
Some nodes may not have a ROM drive available to install from a disk. In such cases, it is
possible to install Proxmox by transferring an ISO image onto a USB flash drive. Note that in
order to boot from USB media, your motherboard must support the USB boot option. Check
from the motherboard BIOS before proceeding to the following steps. If the motherboard
does not support USB boot option, it may not also support an external USB ROM Drive. In
this case, the best way to proceed is to install an ROM drive in the computer or use a newer
motherboard if possible. Here are the instructions to transfer an ISO image to a USB and use
it as bootable drive:
Use the following steps to do this on Windows:
1. Download the Proxmox ISO installation image from http://proxmox.com/
downloads/category/iso-images-pve.
2. Rename the file extension of the downloaded ISO from .iso to .raw.
3. Download and install the USB image writing application from https://github.
com/downloads/openSUSE/kiwi/ImageWriter.exe.
In some Windows 7 versions, the preceding writer may not work. In such
scenarios, download and install the ImageUSB from http://www.
osforensics.com/tools/write-usb-images.html.
4. Using the preceding applications, copy the ISO image onto a USB drive.
5. Insert the USB media into the USB port of the physical node and boot from the
USB media.
Use the following steps to do this on Linux:
1. Download the Proxmox ISO installation image from http://proxmox.com/
downloads/category/iso-images-pve.
2. Insert the USB media into the USB port of the node and find out the device name of
the drive using #fdisk. The name should be in the /dev/XXX format.
3. Use the following command to copy the ISO onto USB media. Use extra caution when
using a device name in the following command. The wrong device name will destroy
all the data on the device:
#dd if=<Proxmox ISO file> of=/dev/XXX bs=1M
4. Reboot the node from the USB media to start the installation.
Chapter 1
Getting ready
Power up and boot the physical node using the installation disk or the USB media we created
in the preceding recipe. The following screenshot is how the screen looks after the boot:
How to do it
1. At the main installation window after the booting process press Enter to start
the installation.
2. On the End User License Agreement (EULA) screen click on Agree.
Installing Proxmox
3. In this step, we have chosen the drive to install the hypervisor on. From Proxmox VE
3.4, a new feature to change the filesystem has been added. After selecting Target
Harddisk from the drop-down menu, select Options to open the Filesystem selection
dialog box. The following screenshot shows the drive selection screen with the
Filesystem dialog box open:
Chapter 1
4. From the Filesystem drop-down menu, select the desired filesystem. Select the desired
filesystem size in hdsize. In version 3.3, support for the ext3, ext4, and ZFS filesystems
have been added. Add additional information, such as the swapsize, maxroot, minfree,
and maxvz values as required or leave them blank to continue with default, then click
on Next. The following table shows the functions of these four options. These values
are usually alternatives to each other, meaning if values are entered for one of these
options, values for other options are automatically calculated:
Option
Function
swapsize
maxroot
This refers to the maximum size the root partition should be.
minfree
maxvz
The following screenshot shows the filesystem that is supported after clicking on the
drop-down menu:
Installing Proxmox
5. After selecting the drive for installation, we now have to select localization
information, such as Country, Time Zone, and Keyboard Layout based on the
desired language. Then, click on Next. The following screenshot displays the
localization screen:
6. Type in and confirm the password for the root login. Then, enter an e-mail address
where all the Proxmox cluster notifications will go to. Click on Next.
10
Chapter 1
7.
In this step, we need to enter the hostname and network information, such as IP
Address, Gateway, DNS Server, and so on. Enter the necessary information for
your environment, then click on Next. The following screenshot shows the network
information screen:
8. At this point, all the necessary information has been collected and the main
installation has been started. After the installation is completed, eject the
installation disk or the USB media, then click on Reboot.
There's more
Follow steps 1 to 7 to set up the second node. A minimum of two nodes are required to
form a Proxmox cluster. More information on cluster configurations is available in Chapter 3,
Cluster and VM Management.
11
Installing Proxmox
Getting ready
Install Debian from instructions from the official Debian site at http://www.debian.org.
Prior to installing Proxmox on the Debian node, ensure that the hostname can be resolved.
Check the hostname using the following command:
#nano /etc/hosts
If the entries are missing, type in the proper IP address associated with the hostname of the
node. The pvelocalhost entry must be present at the end of the line.
How to do it...
Use the following steps to install Proxmox on a Debian system:
1. Add the Proxmox VE repository in the source list as follows:
#nano /etc/apt/sources.list
deb http://ftp.ca.debian.org/debian wheezy main contrib
12
Chapter 1
Due to a bug in the Debian OS, apt-get may display an error of not
finding /binary-i386 with a Unable to find expected entry
'pve/binary-i386/packages' error message. The error may occur
even though it is a 64-bit Debian installed operating system. In such cases,
change the PVE repository entry to the following:
deb [arch=amd64] http://download.proxmox.com/debian
wheezy pve
7.
12. During installation, accept suggestions to remove Exim and set up Postfix. Exim can
be installed later if required.
13. Reboot the node after the Proxmox VE installation is done.
13
Installing Proxmox
There's more
Follow steps 1 to 13 to set up a second node. A minimum of two nodes are required to form a
Proxmox cluster. We will take a good look at the Proxmox GUI in Chapter 2, Getting to know the
Proxmox GUI.
A Proxmox subscription
The Proxmox VE itself is free. There are absolutely no costs involved in simply downloading
the ISO image and installing a fully-functional Proxmox cluster without paying for a license or
subscription. However, there is a Proxmox subscription option available to support the project,
which enables enterprise repository. There are no feature differences between the Free and
Subscription versions of Proxmox. Both are exactly the same. The difference is between the
type of releases, updates, and patches they receive.
Packages from the enterprise repository go through an extra layer
of scrutiny and testing. Thus, a subscription is recommended for a
production-level Proxmox VE.
This not to be confused with the fact that a Proxmox cluster is built with no subscription and
is not stable enough to use. New packages are usually released through a no-subscription
repository first. Same packages are pushed through the Enterprise repository at a later time.
This delay allows the Proxmox team to pin point and fix any lingering bugs or defects in the
package. In a cluster running mission critical virtual machines may face unacceptable downtime
due to the bug, which will not affect a smaller environment that is able to sustain downtime.
There are four levels of subscription at various price points, such as COMMUNITY, BASIC,
STANDARD, and PREMIUM. For more information on the Proxmox subscription, visit
https://www.proxmox.com/proxmox-ve/pricing.
14
Chapter 1
This is because an enterprise repository is enabled by default. If you decide not to get any
Proxmox subscriptions and continue using the fully Free version, you will have to disable
the enterprise repository.
Getting ready
Login to the Proxmox node through a console or SSH. An enterprise repository can only be
disabled through CLI.
How to do it
The enterprise repository is listed in /etc/apt/sources.list.d/pve-enterprise.
list. We have to comment out the line to disable the repository:
# nano /etc/apt/sources.list.d/pve-enterprise.list
#deb https://enterprise.proxmox.com/debian wheezy pve-enterprise
How it works
No restart of services or reboot is required to apply the changes. Log out from the Proxmox
GUI and log back in to see if the changes were applied correctly. The "no subscription"
message box should not pop-up after login. Subscriptions can be managed from the Proxmox
GUI under the Subscription tab. Here is a screenshot of a nonsubscribed Proxmox node:
15
Installing Proxmox
Getting ready
Login to the Proxmox GUI by accessing the link through a browser and enter the admin login
credentials. The default username is root and the password is the same as was entered
during installation: https://<pmx_node_IP>:8006.
How to do it
1. After logging into the Proxmox GUI, click on the node that the subscription is going to
be applied to.
2. Click on the Subscription tab.
3. Click on the Upload Subscription Key button to open the key dialog box, as shown in
the following screenshot:
4. Copy/paste the subscription key from the e-mail received from Proxmox in the key
box, then click on Ok.
16
Chapter 1
5. Click on Check. At this moment, the key will be verified with Proxmox to check the
validity. After the activation is completed, it should look like the following screenshot:
There's more
If a wrong subscription key has been entered, then the display should resemble the
following screenshot:
In such cases, simply upload the correct key to activate again. You may also see the key
invalid notice when the key has already been activated for another node, which is no longer in
service. In such cases, contact Proxmox or other third-party license providers that the license
was purchased from to request reissuing of the same license. Then, simply click on the Check
button to reactivate the key. Each key is hard coded to each server ID. The key needs to be
reissued by Proxmox in order to use it.
Please keep in mind that once a key is reissued, it will no longer work
on the previous node it was activated for. If you have asked for reissue
a license by mistake, request to reissue again and click on the Check
button on the previous node.
17
Installing Proxmox
Subscription
Usage
Enterprise
Required
No-Subscription
Not required
Test
Not required
The location and content of the Enterprise Repository source file is as follows:
#cat /etc/apt/sources.list.d/pve-enterprise.list
deb https://enterprise.proxmox.com/debian wheezy pve-enterprise
The location and content of the No-Subscription Repository source file is as follows:
#cat /etc/apt/sources.list
deb http://ftp.ca.debian.org/debian wheezy main contrib
deb http://download.proxmox.com/debian wheezy pve-no-subscription
deb http://security.debian.org / wheezy/updates main contrib
Proxmox offers a Test Repository to allow users to try out new features or packages. As the
name implies, the Test Repository should only be used for testing. All the new features of
Proxmox are released in the Test Repository before they are available for the No-Subscription
and Enterprise repositories. Packages in the Test Repository are not well-tested and may
contain bugs. For this reason, the repository should never be used in a production-level
cluster. The Test Repository is not enabled by default.
18
Chapter 1
Getting ready
Log in to the Proxmox node through a console or SSH. The repository source file needs to be
edited through CLI to enable the Test Repository.
How to do it
Use the following steps to set up the Proxmox package repository:
1. Open the repository source file using any favorite text editor:
#nano /etc/apt/sources.list
2. Make the necessary changes to make the entries look similar to the following:
deb http://ftp.debian.org/debian wheezy main contrib
deb http://download.proxmox.com/debian wheezy pvetest
deb http://security .debian.org/ wheezy/updates main contrib
How it works
Usually, the announcement of the availability of a new package is made on the official
Proxmox forum (http://forum.proxmox.com). The name of the package or the version
information is included in the announcement. If you want to find information on a package,
simply ask for it on the forum. Once you have the information, simply run the apt-get
command to install it through CLI:
#apt-get install <package_name>
There's more
Besides Enterprise, No-Subscription, and Test repositories there are two repositories that are
outdated and are no longer supported or updated:
Outdated stable repository (pve): This repository has stopped receiving updates
after the initial release of Proxmox VE 3.1:
/etc/apt/sources.list
deb http://ftp.debian.org/debian wheezy main contrib
deb http://download.proxmox.com/debian wheezy pve
deb http://security .debian.org/ wheezy/updates main contrib
19
Installing Proxmox
If you're upgrading from Proxmox VE 2.x to 3.x, the second entry in /etc/apt/
sources.list needs to be changed from wheezy pve to wheezy pve-nosubscription.
Outdated Proxmox VE 2.x stable repository (squeeze pve): In order to have a stable
Proxmox node, it is highly recommended to upgrade and update to the latest stable
release of the Proxmox VE.
/etc/apt/sources.list
deb http://ftp.debian.org/debian squeeze main contrib
deb http://download.proxmox.com/debian squeeze pve
deb http://security.debian.org/ squeeze/updates main contrib
Seeking support
As mentioned in the beginning of this chapter, Proxmox has a vibrant community of users
ready to provide help to anybody in need. There are several ways that a new Proxmox user
can seek help and support to learn and extend knowledge of the Proxmox VE:
Help and support
Free/subscription
Forum
Free
Wiki/Documentation
Free
Requires subscription
Free
Free
The forum
The official forum of Proxmox is a gathering place for newbies or experts alike to receive or
provide help from the Proxmox community. It is also a vast information resource of past issues
and solutions to many problems. A few of the Proxmox staff also spend a significant amount of
time in this forum to offer help outside their job responsibilities. There is an array of Proxmox
experts willing to help out without expecting anything in return. This is the only place for Free
and Community-level subscriptions for Proxmox users to seek support. Visit http://forum.
proxmox.com to access the official Proxmox forum.
20
Chapter 1
Wiki/Documentation
The Proxmox Wiki site contains a wealth of information on installation, configuration, and the
management of Proxmox clusters. All documentation is written in a very easy to understand
form with as many illustrations as possible. The use of the Proxmox Wiki page is completely
free and requires no registration. Visit https://pve.proxmox.com/wiki/Main_Page for
the official Proxmox documentation.
User mailing list: This mailing list is targeted at general Proxmox users to ask
technical questions (http://pve.proxmox.com/cgi-bin/mailman/
listinfo/pve-user).
Developer mailing list: This mailing list is for developers who are interested
in participating in code-related commits and developmental related questions
(http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel).
21
www.PacktPub.com
Stay Connected: