how to perform precopy memory migration in LXC /LXD so that I can perform live migration from one host to another?How do I set to precopy migration in CRIU?
1 Answers
The Pre-copy memory migration for Live migration with CRUI
Live Migration of Linux Containers between hosts (there is migration script), LXC and CRUI:
You should have built and installed a recent (>= 1.3.1) version of CRIU.
LXC upstream has begun to integrate checkpoint/restore support through the lxc-checkpoint tool. This functionality has been in the recent released version of LXC---LXC 1.1.0 , you can install the LXC 1.1.0 or you can check out the development version on Ubuntu by doing:
sudo add-apt-repository ppa:ubuntu-lxc/daily
sudo apt-get update
sudo apt-get install lxc
And add the following lines (as above) to LXC container config:
cat | sudo tee -a /var/lib/lxc/u1/config << EOF
# hax for criu
lxc.console = none
lxc.tty = 0
lxc.cgroup.devices.deny = c 5:1 rwm
EOF
checkpoint the container:
lxc-checkpoint -s -D /tmp/checkpoint -n u1
At this point, the container's state is stored in /tmp/checkpoint, and the filesystem is in /var/lib/lxc/u1/rootfs. You can restore the container by doing:
lxc-checkpoint -r -D /tmp/checkpoint -n u1
PS: You can do live migration for processes:
Dump
Take tasks you're about to migrate and dump them into some place, asking criu
to leave them in stopped state after dump:
criu dump --tree <pid> --images-dir <path-to-existing-directory> --leave-stopped
The directory you put images to can reside on the shared file-system if you're using one. In this case you can skip the Copy step and proceed to Restore.
Copy Copy images to destination node:
scp -r <path-to-images-dir> <dst>:/<path-to-images>
Restore Go to the destination node and restore the apps from images on it:
criu restore --tree <pid> --images-dir <path-to-images>

- 5,384
- 3
- 27
- 45