Checkpoint/Restore in Userspace(CRIU)的安装与使用(CentOS 7.2)

参考网址:Installation - CRIU

CRIU安装:

获取CRIU的源代码

git clone https://github.com/xemul/criu

或者

wget http://download.openvz.org/criu/criu-x.x.tar.bz2
tar -xvf criu-x.x.tar.bz2

安装编译依赖软件

yum install gcc make -y
yum install glibc-devel.i686 protobuf protobuf-c protobuf-c-devel protobuf-compiler protobuf-devel protobuf-python libaio-devel libcap-devel libnl3-devel -y

在CRIU代码根目录下,执行编译命令 make

安装依赖软件

yum install asciidoc xmlto -y

在CRIU代码根目录下,运行安装命令 make install

CRIU使用:

命令格式:
   criu dump -D chkpoint -t pid
 
CRIU环境检查
 
创建一个无限循环脚本文件
 
[root@de69 ~]# chmod 755 test.sh
[root@de69 ~]# ./test.sh
 
创建一个新的终端,获得test.sh的pid,“pgrep -f test.sh”
 
[root@de69 ~]# criu dump -t $PID --images-dir chkpoint --shell-job
 
[root@de69 ~]# criu restore -t 23267 --images-dir chkpoint/ --shell-job
运行命令之后test.sh恢复正常运行。
 
在使用CRIU对docker容器进行操作时出现以下提示错误
Error (criu/namespaces.c:403): Can't dump nested pid namespace for 23025
Error (criu/namespaces.c:607): Can't make pidns id
Error (criu/cr-dump.c:1625): Dumping FAILED.
 
pid=23025
 
[root@de69 ~]# criu dump -t 23025 --images-dir /tmp/doc01/
 
原因是当前CRIU并不完善(如不支持seccomp、不支持外部终端、挂载的文件系统可读等),Docker容器对宿主机的应用(例如“/bin/bash”等)有依赖,而CRIU不能对非Docker容器进程树中的进程设置检查点,从而导致Checkpoint/Restore失败。
原文地址:https://www.cnblogs.com/yujinyu/p/6095156.html