Friday, October 16, 2015

Proxmox version 4 remove support for OpenVZ, but added LXC (Linux Containers)

I have just read Proxmox's press release and watch video about Proxmox Version 4.

One major shock was the Team's decision to move away from OpenVZ and replacing it with LXC.

Both OpenVZ and LXC are good linux VPS (virtual private server) technologies. I believe OpenVZ was more mature to start with but, LXC is more efficient and faster.

In my opinion Proxmox team's decision is the correct one because OpenVZ is tied in too much with their sponsoring company Odin (used to be SWSoft). Versus LXC which started as true open source collaboration and eventually got some support from Canonical (Ubuntu people).

As far as I know their features are very similar but OpenVZ require kernel modification and LXC does NOT. Which is a huge difference for DevOps admin.

Anyhow, I am now thinking about moving to LXC from OpenVZ also, and realizing I will need to re-learn everything that I know about OpenVZ and look them up how do to all the basic things like Backup, Stop, Suspend, Start, etc... Haha... Here we go again.

Sunday, June 28, 2015

Enable automatic time synchronization for OpenVZ container in Proxmox (for Ubuntu / Debian)

apt-get update
apt-get -y install ntpdate

locale-gen en_US en_US.UTF-8
dpkg-reconfigure locales

dpkg-reconfigure tzdata

/usr/sbin/vzctl stop  <ctid>
/usr/sbin/vzctl set <ctid>  --capability sys_time:on  --save
/usr/sbin/vzctl start  <ctid>

Rejoin hardware node to Proxmox cluster

service pvestatd stop
service pvedaemon stop

service cman stop
killall -9 corosync cman dlm_controld fenced

service pve-cluster stop

rm /etc/cluster/cluster.conf
rm -rf /var/lib/pve-cluster/* /var/lib/pve-cluster/.*
rm /var/lib/cluster/*

// check versions - make sure it is running same version (kernel) as other nodes
uname -a
pveversion -v   (look for Running kernel: ... )

reboot (you have to reboot!)



After rebooting, you can add the node as usual:
pvecm add <IP address of one of the nodes already in the cluster>


Backup OpenVZ container CT to another hardware node for automatic scheduled remote backup

Proxmox does have a nice user interface which allows you to backup any OpenVZ container (even when it is live - using snapshot).  Did you know you can also do the same from command line?

You can use vzdump!

For example:

vzdump 104 --mode snapshot --compress lzo --stdout | ssh 10.0.1.1 "cat > /mnt/backup/vz/104/vzdump-openvz-104-2013_05_18-11_00_00.tar.lzo"


The above command will backup

CT 104

using 'snapshot' mode (live - without needing to shut it down)

with compression LZO mode

stores it to another server (in this example 10.0.1.1) using SSH

to a remote directory and filename:

    /mnt/backup/vz/104/vzdump-openvz-104-2013_05_18-11_00_00.tar.lzo


Why is this useful? well... for daily / routine backup of course!  Imagine never having to worry about backing up your VM ever again once you set this command nicely in your crontab. :-)

Removing openvz container CT manually from Proxmox

/etc/vz/conf/<ctid>.*
     there may be .mount files here, just back them up to /root/ but don't worry, vzdump back up these configuration files too.
     vzrestore will restore .mount files also.

/var/lib/vz/root/<ctid>   may contain fastboot file. just move this also to /root/ just in case
     this could be the directory used if local storage is used for container

where the actual CT was:

/mnt/md0/private/


notes:
vzdump also backs up <ctid> configuration find and <ctid>.mount files  and   vzrestore restores conf and .mount files just fine.

Increase open file limit number of open file limit on HN host node and vm / ct

DO THIS IN HN (hardware nodes):

nano /etc/security/limits.conf

# wildcard does not work for root, but for all other users
*               soft     nofile           65536
*               hard     nofile           65536
# settings should also apply to root
root            soft     nofile           65536
root            hard     nofile           65536

ulimit -n 65536

do not need to modify pam limits

-----------------------------------------------

for each CTs we also need to do this:

Fix repair replace broken failed RAID mirrored hard drive from proxmox hardware node HN MD0

** REBOOT NOT REQUIRED FOR HOT-SWAP DRIVE BAY **

cat /proc/mdstat

FROM SDB TO SDC:
dd if=/dev/zero of=/dev/sdc bs=512 count=1
sfdisk -d /dev/sdb | sfdisk --force /dev/sdc
mdadm --manage /dev/md0 --add /dev/sdc1

FROM SDC TO SDB:
dd if=/dev/zero of=/dev/sdb bs=512 count=1
sfdisk -d /dev/sdc | sfdisk --force /dev/sdb
mdadm --manage /dev/md0 --add /dev/sdb1

cat /proc/mdstat