How to deploy Plesk 11 on KVM or Xen systems

Created:

2016-11-16 12:48:55 UTC

Modified:

2017-04-24 11:33:41 UTC

1

Was this article helpful?


Have more questions?

Submit a request

How to deploy Plesk 11 on KVM or Xen systems

Applicable to:

  • Plesk 11.0 for Linux

Release Notes

To simplify Plesk 11 provisioning for Cloud infrastructure providers (including service providers offering dedicated servers, VPS, or IaaS), Odin introduces Plesk virtual machine images for KVM and Xen systems.

Download

The images based on CentOS 6.2 and Ubuntu 12.04, both 64-bit, are shipped as an archive including deployment scripts, which is available here .

Software Requirements

Hypervisor services KVM or Xen.

Command line tools:

  • virt-install
  • virt-clone
  • qemu-img
  • virsh (Usually, they are included in the virtinst package or in the python-virtinst; libvirt; virt-manager;qemu-kvm, or kvm-qemu-img package.)

Deployment Scripts

To create servers using our images, download and unpack the archive. The archive contains the following:

  • Two shell scripts: plesk\\_clone\\_kvm.sh and plesk\\_clone\\_xen.sh

  • Disk image in qcow2 format: clone.qcow2

  • xml config for KVM: clone.cfg The scripts are designed for different hypervisors, but they have the same set of commands:

    # ./plesk_clone_kvm.sh

USAGE:

     plesk_clone_kvm.sh <COMMAND> [OPTIONS]

plesk_clone_kvm.sh install <VM name> <image path> [MAC address]
plesk_clone_kvm.sh mount <VM disk file>
plesk_clone_kvm.sh umount
plesk_clone_kvm.sh installkey <VM disk file> <SSH key file>
plesk_clone_kvm.sh installpasswd <VM disk file> <plain text password>

COMMANDS:

  • install - install the new virtual machine from Parallels image.
  • mount - mount the virtual disk of existing environment.
  • umount - unmount the virtual disk of existing environment.
  • installkey - install SSH key into existing environment.
  • installpasswd - set root password into existing envrionment.
    # ./plesk_clone_xen.sh

USAGE:

     plesk_clone_xen.sh <COMMAND> [OPTIONS]

plesk_clone_xen.sh install <VM name> <image path> [MAC address]
plesk_clone_xen.sh mount <Virtual disk file>
plesk_clone_xen.sh umount
plesk_clone_xen.sh installkey <Virtual disk file> <SSH key file>
plesk_clone_xen.sh installpasswd <Virtual disk file> <plain text password>

COMMANDS:

  • install - install the new virtual machine from Parallels image.
  • mount - mount the virtual disk of existing environment.
  • umount - unmount the virtual disk of existing environment.
  • installkey - install SSH key into existing environment.
  • installpasswd - set root password into existing envrionment.

Steps to Deploy

  1. Create a KVM virtual server with Plesk:
    # ./plesk_clone_kvm.sh install plesk.centos.vm3 /var/lib/libvirt/images/
    Trying to install new VM with disk image /var/lib/libvirt/images//plesk.centos.vm3.qcow2 ...
    Cloning clone.qcow2 | 30 GB 00:00

    Clone 'plesk.centos.vm3' created successfully.`

1.1 Create a virtual server with the specified MAC address:

    # ./plesk_clone_kvm.sh install plesk.centos.vm1 /var/lib/libvirt/images 00:11:22:33:44:55

Note: Make sure the first octet in the MAC address is EVEN (e.g., 00:) as MAC addresses with ODD first-bytes (e.g., 01:) are reserved for multicast communication and can cause problems. (See https://help.ubuntu.com/community/KVM/Networking .)

The rest of the operations are applied to the disk of the virtual machine. To avoid possible problems with the file system, do not use it for disks of a started virtual server.

  1. Generate and install the public key:

     # ssh-keygen -t rsa -b 4096 -f id_example
    # ./plesk_clone_kvm.sh installkey /var/lib/libvirt/images/plesk.centos.vm3.qcow2 id_example.pub
    Trying to install SSH key for root user... done
  2. Create the root password:

    # ./plesk_clone_kvm.sh installpasswd /var/lib/libvirt/images/plesk.centos.vm3.qcow2 PASSWORD
    Trying to set root password... done
  3. (Optional) Mount the disk of the virtual server to the _mnt/ _directory:

    # ./plesk_clone_kvm.sh mount /var/lib/libvirt/images/plesk.centos.vm3.qcow2
    Trying to mount virtual disk into /root/plesk_kvm/mnt... done
  4. (Optional) Unmount the disk of the virtual server:

     # ./plesk_clone_kvm.sh umount
    Trying to unmount virtual disk from /mnt... done
    Trying to disconnect device ... done
  5. Start the virtual server:

    # virsh start plesk.centos.vm3
    Domain plesk.centos.vm3 started
  6. Get the Plesk admin's password (IP address is required\*):

    # ssh -x root@192.0.2.2 "/usr/local/psa/bin/admin --show-password"
    root@192.0.2.2's password:
    **************
    # ssh -i id_example -x root@192.0.2.2 "/usr/local/psa/bin/admin --show-password"
    *************

Plesk post-installation steps should be performed according to the Plesk Installation/Upgrade/Migration Guide . (Note: change the server hostname because the default hostname in the images is "localhost.localdomain.")

\* IP address assigned to a virtual machine by means of KVM/XENcannot be used; therefore, DHCP server should be used to lease the files. For example, for a local DHCP server that serves the virtual network interfaces operating in the Usermode Networking (NAT):

    # grep 00:11:22:33:44:55 /var/lib/libvirt/dnsmasq/default.leases | awk '{print $3}'
192.0.2.2

\ \ For configuration of a virtual server with a static IP address, mount the disk of the virtual server and insert the needed network configuration file:

    # ./plesk_clone_kvm.sh mount /var/lib/libvirt/images/plesk.centos.vm1.qcow2
Trying to mount virtual disk into /root/plesk_kvm/mnt... done
# cat centos-ifcfg-eth0 > mnt/etc/sysconfig/network-scripts/ifcfg-eth0
# ./plesk_clone_kvm.sh umount
Trying to unmount virtual disk from /mnt... done
Trying to disconnect device ... done`
Where centos-ifcfg-eth0:
`DEVICE="eth0"
BOOTPROTO="static"
BROADCAST="10.50.255.255"
DNS1="192.0.2.3"
GATEWAY="192.0.2.1"
IPADDR="192.0.2.2"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
NETMASK="255.255.0.0"
NM_CONTROLLED="yes"
ONBOOT="yes"
NAME="System eth0"

Additional Information

The disk size of our images is 30 GB. It can be changed using the following steps:

Create a backup of the disk:

# cp /var/lib/libvirt/images/centos.mu.bridged /var/lib/libvirt/images/centos.mu.bridged.back

Change the disk size:

# qemu-img resize /var/lib/libvirt/images/centos.mu.bridged +10GB
Image resized.

Convert the image to "raw" format:

# qemu-img convert -O raw /var/lib/libvirt/images/centos.mu.bridged /var/lib/libvirt/images/centos.mu.bridged.raw

Recreate the third partition of the virtual disk via the fdisk utility; it will remove the partition and create a new partition that starts from the same sector as the removed partition:

# fdisk /var/lib/libvirt/images/centos.mu.bridged.raw

Command (m for help): p

Disk /var/lib/libvirt/images/centos.mu.bridged.raw: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006d850

Device Boot Start End Blocks Id System
/var/lib/libvirt/images/centos.mu.bridged.raw1 * 2048 411647 204800 83 Linux
/var/lib/libvirt/images/centos.mu.bridged.raw2 411648 4605951 2097152 82 Linux swap / Solaris
/var/lib/libvirt/images/centos.mu.bridged.raw3 4605952 62914559 29154304 83 Linux

Command (m for help): d
Partition number (1-4): 3

Command (m for help): p

Disk /var/lib/libvirt/images/centos.mu.bridged.raw: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006d850

Device Boot Start End Blocks Id System
/var/lib/libvirt/images/centos.mu.bridged.raw1 * 2048 411647 204800 83 Linux
/var/lib/libvirt/images/centos.mu.bridged.raw2 411648 4605951 2097152 82 Linux swap / Solaris

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4, default 3): 3
First sector (4605952-83886079, default 4605952):
Using default value 4605952
Last sector, +sectors or +size{K,M,G} (4605952-83886079, default 83886079):
Using default value 83886079

Command (m for help): p

Disk /var/lib/libvirt/images/centos.mu.bridged.raw: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006d850

Device Boot Start End Blocks Id System
/var/lib/libvirt/images/centos.mu.bridged.raw1 * 2048 411647 204800 83 Linux
/var/lib/libvirt/images/centos.mu.bridged.raw2 411648 4605951 2097152 82 Linux swap / Solaris
/var/lib/libvirt/images/centos.mu.bridged.raw3 4605952 83886079 39640064 83 Linux

Command (m for help): w
The partition table has been altered!

Syncing disks.

After recreating the partition, convert the raw file to qcow2 format again:

# qemu-img convert -O qcow2 /var/lib/libvirt/images/centos.mu.bridged.raw /var/lib/libvirt/images/centos.mu.bridged

After changing the size of the disk and starting the guest OS, run this command:

 # resize2fs /dev/vda3

Remove the backup of the disk if all steps have been completed successfully.   To change the disk size for the image, use the same commands for the file of the virtual server cloned from our image. Additionally, after the last command, resize2fs /dev/vda3 , in the guest OS, run the following commands:

 # /usr/local/psa/bin/ipmanage --auto-remap-ip-addresses true
# /usr/local/psa/bin/cloning --update -prepare-public-image true -reset-license true
# > /etc/udev/rules.d/70-persistent-net.rules
# poweroff

After that, replace the clone.qcow2 file with the file of the created virtual server.

Have more questions? Submit a request
Please sign in to leave a comment.