OpenVZ 服务器上的容器是使用模板 Ubuntu 12.04 32 位设置的,并且设置成功。执行重启操作时,容器加载失败。重新安装容器只会使服务器重新上线。关闭后启动容器时会出现以下错误日志。
[root@openvz ~]# vzctl start 4879
Starting container...
Unmounting file system at /vz/root/4879
--- lsof /vz/root/4879 output ---
Error in print_output (ploop.c:945): Command lsof exited with status 1
Error in do_umount (ploop.c:983): Failed to umount /vz/root/4879: Device or resource busy
Failed to umount image: Error in do_umount (ploop.c:983): Failed to umount /vz/root/4879: Device or resource busy [22]
Adding IP address(es): 12.34.56.78
/bin/bash: line 535: /etc/network/interfaces: Read-only file system
/bin/bash: line 567: /etc/network/interfaces: Read-only file system
/bin/bash: line 574: /etc/network/interfaces: Read-only file system
cp: cannot create regular file `/etc/network/interfaces.bak': Read-only file system
/bin/bash: line 598: /etc/network/interfaces.bak: Read-only file system
mv: cannot stat `/etc/network/interfaces.bak': No such file or directory
Setting CPU limit: 100
Setting CPU units: 1000
Setting CPUs: 1
/bin/bash: line 122: /etc/init/console.conf: Read-only file system
/bin/bash: line 122: /etc/init/tty2.conf: Read-only file system
/bin/cp: cannot create regular file `/etc/hosts.21': Read-only file system
ERROR: Can't copy file /etc/hosts
Container start in progress...
答案1
这是我解决问题的方法
该容器有一个先前用于另一个容器的 IP 地址。当终止前一个容器时,该容器的私有区域并未被删除。因此,在安装新容器后,它会加载新的私有区域。但重启后,容器无法加载正确的配置,它必须加载旧容器的私有区域。
因此,删除旧的私人区域是解决方案,以下是解决此问题所采取的措施。
[root@openvz /]#vzlist -a| grep 12.34.56.78
4870 mounted 12.34.56.78 host20305.server.com
4879 28 running 12.34.56.78 host20305.server.com
这里可以清楚的看到虚拟机4870
属于旧容器,需要销毁。现在执行以下命令。
[root@openvz /]# vzctl destroy 4870
Container is currently mounted (umount first)
[root@openvz /]# vzctl umount 4870
Unmounting file system at /vz/root/4870
--- lsof /vz/root/4870 output ---
Error in print_output (ploop.c:945): Command lsof exited with status 1
Error in do_umount (ploop.c:983): Failed to umount /vz/root/4870: Device or resource busy
Failed to umount image: Error in do_umount (ploop.c:983): Failed to umount /vz/root/4870: Device or resource busy [22]
[root@openvz /]# umount -l /vz/root/4870
[root@openvz /]# vzctl destroy 4870
Destroying container private area: /vz/private/4870
Container private area was destroyed
现在检查容器的状态。
[root@openvz /]#vzlist -a| grep 12.34.56.78
4879 28 running 12.34.56.78 host20305.server.com