飞羽

Docker容器热迁移-跨节点迁移
本文主要讲解跨节点的Docker容器热迁移
扫描右侧二维码阅读全文
13
2019/06

Docker容器热迁移-跨节点迁移

本文主要讲解跨节点的Docker容器热迁移

Docker容器热迁移-跨节点迁移

Docker容器热迁移-跨节点迁移.png

说明


如果想要了解单节点的Docker容器热或者想要了解热迁移,请转到以下博客:


本文是接着上篇博客,所以看这篇博客之前,请先看以上博客

跨界点注意事项

单节点迁移我们已经会了,那么跨界点需要注意什么呢?


首先你需要两个节点docker、CRIU、Linux内核完全一样,否则迁移不成功!!!!

跨界点步骤


上一篇博客已经说明了储存docker的checkpoint节点在哪里了,因此我们直接就可以找到他,打包,上传到另一个节点,具体步骤如下:

定位到checkpoint位置

[root@localhost ~]# cd /var/lib/docker/containers/c86b61b9165e9d85c9cd366fc0312ff0e6f81f161fb720ccf9ef5d34eb96066c/checkpoints/
[root@localhost checkpoints]# ls
looper2

打包镜像

[root@localhost checkpoints]# tar -cvf /root/looper2.tar.gz ./looper2/
#打包命令
./looper2/
./looper2/cgroup.img
./looper2/core-1.img
./looper2/core-155.img
./looper2/descriptors.json
./looper2/fdinfo-2.img
./looper2/fdinfo-3.img
./looper2/files.img
./looper2/fs-1.img
./looper2/fs-155.img
./looper2/ids-1.img
./looper2/ids-155.img
./looper2/inventory.img
./looper2/ipcns-var-10.img
./looper2/mm-1.img
./looper2/mm-155.img
./looper2/mountpoints-12.img
./looper2/pagemap-1.img
./looper2/pagemap-155.img
./looper2/pages-1.img
./looper2/pages-2.img
./looper2/pstree.img
./looper2/seccomp.img
./looper2/tmpfs-dev-44.tar.gz.img
./looper2/tmpfs-dev-47.tar.gz.img
./looper2/tmpfs-dev-48.tar.gz.img
./looper2/tmpfs-dev-49.tar.gz.img
./looper2/tmpfs-dev-50.tar.gz.img
./looper2/tmpfs-dev-51.tar.gz.img
./looper2/utsns-11.img

通过scp传输到另一节点

[root@localhost ~]# scp ./looper2.tar.gz 192.168.1.240:/root/

另一台机器运行容器,并停止

docker run -d --name looper2 --security-opt seccomp:unconfined busybox          /bin/sh -c 'i=0; while true; do echo $i; i=$(expr $i + 1); sleep 1; done'
#运行容器
faac2ac7f7bf76f19f2774725f72f6df8c14738d623c91fe16ec84d49d170dfe
[root@localhost ~]# docker stop looper2
#停止
looper2

把传过来的文件解压到容器镜像文件夹

[root@localhost ~]# cd /var/lib/docker/containers/faac2ac7f7bf76f19f2774725f72f6df8c14738d623c91fe16ec84d49d170dfe/checkpoints/
[root@localhost checkpoints]# cp /root/looper2.tar.gz ./
[root@localhost checkpoints]# ls
looper2.tar.gz
[root@localhost checkpoints]# tar -xvf looper2.tar.gz 
./looper2/
./looper2/cgroup.img
./looper2/core-1.img
./looper2/core-125.img
./looper2/descriptors.json
./looper2/fdinfo-2.img
./looper2/fdinfo-3.img
./looper2/files.img
./looper2/fs-1.img
./looper2/fs-125.img
./looper2/ids-1.img
./looper2/ids-125.img
./looper2/inventory.img
./looper2/ipcns-var-10.img
./looper2/mm-1.img
./looper2/mm-125.img
./looper2/mountpoints-12.img
./looper2/pagemap-1.img
./looper2/pagemap-125.img
./looper2/pages-1.img
./looper2/pages-2.img
./looper2/pstree.img
./looper2/seccomp.img
./looper2/tmpfs-dev-44.tar.gz.img
./looper2/tmpfs-dev-47.tar.gz.img
./looper2/tmpfs-dev-48.tar.gz.img
./looper2/tmpfs-dev-49.tar.gz.img
./looper2/tmpfs-dev-50.tar.gz.img
./looper2/tmpfs-dev-51.tar.gz.img
./looper2/utsns-11.img
[root@localhost checkpoints]# ls
looper2.tar.gz  looper2
[root@localhost checkpoints]# rm looper2.tar.gz 
rm:是否删除普通文件 
"looper2.tar.gz"?y

容器恢复

docker start --checkpoint looper2 looper2

恢复完成


注:
如果想要保存状态并且容器还是运行状态,那么就这么写

docker checkpoint create --leave-running=true looper2 looper2
文章名: 《Docker容器热迁移-跨节点迁移》

文章链接:https://blog.8086k.cn/archives/41/

联系方式:1412981048@qq.com

除特别注明外,文章均为飞羽小随笔原创,转载时请注明本文出处及文章链接
Last modification:June 19th, 2019 at 05:14 pm
如果觉得我的文章对你有用,请随意赞赏

Leave a Comment