Compile CRIU on CentOS 6
2018-03-24T23:57:00+08:00
再见理想
Config CentOS 6 Source
sed -i 's|mirror.centos.org|mirrors.aliyun.com|g' /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum makecache
yum -y install centos-release-scl-rh
sed -i 's|mirror.centos.org|mirrors.aliyun.com|g' /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
curl -o cert-forensics-tools-release-el6.rpm https://forensics.cert.org/cert-forensics-tools-release-el6.rpm
rpm -Uvh cert-forensics-tools-release*rpm
curl -o elrepo-release-6-8.el6.elrepo.noarch.rpm http://elrepo.org/linux/elrepo/el6/x86_64/RPMS/elrepo-release-6-8.el6.elrepo.noarch.rpm
rpm -Uvh elrepo-release*rpm
curl -o epel-release-6-8.noarch.rpm http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release*rpm
yum makecache
Upgrade Linux Kernel
Take a snapshot before please(务必打一个快照)
curl -o kernel-lt-aufs-headers-4.9.60-1.el6.x86_64.rpm https://go.dist.pub/yum.spaceduck.org/kernel-lt-aufs/6/x86_64/kernel-lt-aufs-headers-4.9.60-1.el6.x86_64.rpm
curl -o kernel-lt-aufs-4.9.60-1.el6.x86_64.rpm https://go.dist.pub/yum.spaceduck.org/kernel-lt-aufs/6/x86_64/kernel-lt-aufs-4.9.60-1.el6.x86_64.rpm
rpm -Uvh kernel-lt-aufs*rpm
vi /etc/sysconfig/kernel
modify DEFAULTKERNEL=kernel-lt-aufs
vi /etc/grub.conf
modify default value to new kernel order(normally it is 0)
reboot
Install Build Tools
yum -y install devtoolset-4-gcc devtoolset-4-make xz unzip wget
Upgrade Glibc
Take a snapshot before please(务必打一个快照)
curl -o binutils-2.26.1.tar.gz https://go.dist.pub/ftp.gnu.org/gnu/binutils/binutils-2.26.1.tar.gz
tar xf binutils-2.26.1.tar.gz && cd binutils-2.26.1
scl enable devtoolset-4 './configure --prefix=/usr'
scl enable devtoolset-4 'make -j2 && make install'
cd ../
curl -o glibc-2.23.tar.xz http://go.dist.pub/ftp.gnu.org/gnu/glibc/glibc-2.23.tar.xz
tar xf glibc-2.23.tar.xz && cd glibc-2.23
mkdir build && cd build
scl enable devtoolset-4 '../configure --prefix=/usr'
scl enable devtoolset-4 'make -j2'
scl enable devtoolset-4 'make install'
will raise error: gawk: error while loading shared libraries: /lib64/libm.so.6: invalid ELF header
ignore it do: ln -s -f /lib64/libm-2.23.so /lib64/libm.so.6
retry: scl enable devtoolset-4 'make install'
cd ../../
Install CRIU dependencies
yum -y install protobuf protobuf-c protobuf-devel protobuf-c-devel protobuf-python python-ipaddr libbsd libcap-devel libnet-devel libnl3-devel
Compile and Install CRIU 2.x Stable Branch
curl -o criu-2.12.1.tar.gz https://go.dist.pub/codeload.github.com/checkpoint-restore/criu/tar.gz/v2.12.1
tar xf criu-2.12.1.tar.gz && cd criu-2.12.1
scl enable devtoolset-4 'make'
vi Makefile.install
delete install-man from install section
scl enable devtoolset-4 'make install'
Test
criu check
if print Looks good.
then ok, otherwise you should fix issue.
Compatible Python 3
default criu py-lib compiled by protoc 2 and python2 which compatible python 2 if you need python 3 compatibility, follow below command.
mkdir protoc-3.5.1 && cd protoc-3.5.1
wget https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip
unzip *.zip
export PATH=`pwd`/bin:$PATH
cd ../
vi lib/Makefile
modify PYTHON_BIN ?= python3
scl enable devtoolset-4 'make install'
now you can move py-lib to your site-packages directory.
mv usr/local/lib/python3.x/site-packages/pycriu/* /PATH/TO/YOUR/PYTHOH/LIB
* don’t forget install python protobuf lib from pip*
run loop.py
n = 0
while True:
print(n)
import time
time.sleep(1)
n += 1
python loop.py
checkpoint and restore
criu dump -j -t `ps -elf|grep loop.py|grep -v grep|awk '{print $4}'`
criu restore -j