[kvm] Failed to get shared “write” lock Is another process using the image?
虚拟云与Docker jackxiang 2023-5-12 15:54
原因
此磁盘已经被其他进程占用。
解决方法
方法1
ps -aux |grep " image(创建的磁盘名称)"
//通过上述命令找到相关进程杀死(该磁盘可能被别人占用,建议询问后在杀)
kill -9 “上述命令查出的进程号”
重新拉虚拟机
方法2
sb.img文件镜像大小制作: qemu-img create -f qcow2 sb.img 50G
启动虚拟机 fdisk -l 查看查看磁盘信息 一般会输出/dev/vda或/dev/vdb信息
mkfs.ext4 /dev/vda 格式化磁盘(分区磁盘,查看本地/document/Newer_enviroment_construct/分区磁盘命令)
新建一个文件夹mkdir /tmp , 并挂载磁盘 mount /dev/vda /tmp
替换原来的disk
实践如下:
ps -aux|grep "win10"
root 1519052 2.3 0.1 883548 92928 ? Sl 14:51 1:25 /usr/bin/qemu-img convert -f qcow2 -O qcow2 -o compat=1.1,lazy_refcounts /backup/virtImages/win10_bak_10_10_0_119.img /backup/virtImages/win10_bak_10_10_0_168.img
kill -9 1519052
错误如下:
启动域时出错: 内部错误:process exited while connecting to monitor: 2023-05-12T07:49:37.817008Z qemu-kvm: -blockdev {"node-name":"libvirt-2-format","read-only":false,"driver":"qcow2","file":"libvirt-2-storage","backing":null}: Failed to get "write" lock
Is another process using the image [/backup/virtImages/win10_bak_10_10_0_119.img]?
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 111, in tmpcb
callback(*args, **kwargs)
File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 66, in newfn
ret = fn(self, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/object/domain.py", line 1280, in startup
self._backend.create()
File "/usr/lib64/python3.6/site-packages/libvirt.py", line 1234, in create
if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirt.libvirtError: 内部错误:process exited while connecting to monitor: 2023-05-12T07:49:37.817008Z qemu-kvm: -blockdev {"node-name":"libvirt-2-format","read-only":false,"driver":"qcow2","file":"libvirt-2-storage","backing":null}: Failed to get "write" lock
Is another process using the image [/backup/virtImages/win10_bak_10_10_0_119.img]?
来自:https://blog.csdn.net/qq_36657175/article/details/124748507
此磁盘已经被其他进程占用。
解决方法
方法1
ps -aux |grep " image(创建的磁盘名称)"
//通过上述命令找到相关进程杀死(该磁盘可能被别人占用,建议询问后在杀)
kill -9 “上述命令查出的进程号”
重新拉虚拟机
方法2
sb.img文件镜像大小制作: qemu-img create -f qcow2 sb.img 50G
启动虚拟机 fdisk -l 查看查看磁盘信息 一般会输出/dev/vda或/dev/vdb信息
mkfs.ext4 /dev/vda 格式化磁盘(分区磁盘,查看本地/document/Newer_enviroment_construct/分区磁盘命令)
新建一个文件夹mkdir /tmp , 并挂载磁盘 mount /dev/vda /tmp
替换原来的disk
实践如下:
ps -aux|grep "win10"
root 1519052 2.3 0.1 883548 92928 ? Sl 14:51 1:25 /usr/bin/qemu-img convert -f qcow2 -O qcow2 -o compat=1.1,lazy_refcounts /backup/virtImages/win10_bak_10_10_0_119.img /backup/virtImages/win10_bak_10_10_0_168.img
kill -9 1519052
错误如下:
启动域时出错: 内部错误:process exited while connecting to monitor: 2023-05-12T07:49:37.817008Z qemu-kvm: -blockdev {"node-name":"libvirt-2-format","read-only":false,"driver":"qcow2","file":"libvirt-2-storage","backing":null}: Failed to get "write" lock
Is another process using the image [/backup/virtImages/win10_bak_10_10_0_119.img]?
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 111, in tmpcb
callback(*args, **kwargs)
File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 66, in newfn
ret = fn(self, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/object/domain.py", line 1280, in startup
self._backend.create()
File "/usr/lib64/python3.6/site-packages/libvirt.py", line 1234, in create
if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirt.libvirtError: 内部错误:process exited while connecting to monitor: 2023-05-12T07:49:37.817008Z qemu-kvm: -blockdev {"node-name":"libvirt-2-format","read-only":false,"driver":"qcow2","file":"libvirt-2-storage","backing":null}: Failed to get "write" lock
Is another process using the image [/backup/virtImages/win10_bak_10_10_0_119.img]?
来自:https://blog.csdn.net/qq_36657175/article/details/124748507
[实践OK]手把手教你打造高效的 Kubernetes 命令行终端
虚拟云与Docker jackxiang 2020-8-17 17:56
在mac上
$ brew install bash-completion
$ source $(brew --prefix)/etc/bash_completion
$ source <(kubectl completion bash)
来自:https://juejin.im/entry/6844903678898356237
Mac: https://i4t.com/3245.html
k8s下容器的内存大小触发OOM
虚拟云与Docker jackxiang 2019-9-2 16:29
背景:出现没有OOM,但是stress子进程反复重启,于是系统负载到118,死机,让机房重启,需要验证为何没有OOM?
container_memory_cache,我们会发现使用的缓存量继续增加,直到container_memory_usage_bytes达到限制,然后开始减少。container_memory_usage_bytes确实考虑了一些正在缓存的文件系统页面。我们还可以看到OOMKiller正在跟踪container_memory_working_set_bytes。这是有道理的,因为共享文件系统缓存页面可以随时从内存中逐出。
也就是说:container_memory_cache ((思考文件系统缓存))平时是不动它的一个值,但是当container_memory_usage_bytes伴随container_memory_usage_bytes的增长而增长,container_memory_usage_bytes增长到设定的limit 200M后,发现container_memory_usage_bytes还继续增长,那么它会把container_memory_cache的内存给用掉。
来自:https://medium.com/faun/how-much-is-too-much-the-linux-oomkiller-and-used-memory-d32186f29c9d
kubectl get pod memory-demo-2 --namespace=mem-example
这时候,容器可能会运行,也可能会被杀掉。如果容器还没被杀掉,重复之前的命令直至 你看到这个容器被杀掉:
NAME READY STATUS RESTARTS AGE
memory-demo-2 0/1 OOMKilled 1 24s
来自:https://www.cnblogs.com/weifeng1463/p/10174432.html
相关测试的yaml:https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/
container_memory_cache,我们会发现使用的缓存量继续增加,直到container_memory_usage_bytes达到限制,然后开始减少。container_memory_usage_bytes确实考虑了一些正在缓存的文件系统页面。我们还可以看到OOMKiller正在跟踪container_memory_working_set_bytes。这是有道理的,因为共享文件系统缓存页面可以随时从内存中逐出。
也就是说:container_memory_cache ((思考文件系统缓存))平时是不动它的一个值,但是当container_memory_usage_bytes伴随container_memory_usage_bytes的增长而增长,container_memory_usage_bytes增长到设定的limit 200M后,发现container_memory_usage_bytes还继续增长,那么它会把container_memory_cache的内存给用掉。
来自:https://medium.com/faun/how-much-is-too-much-the-linux-oomkiller-and-used-memory-d32186f29c9d
kubectl get pod memory-demo-2 --namespace=mem-example
这时候,容器可能会运行,也可能会被杀掉。如果容器还没被杀掉,重复之前的命令直至 你看到这个容器被杀掉:
NAME READY STATUS RESTARTS AGE
memory-demo-2 0/1 OOMKilled 1 24s
来自:https://www.cnblogs.com/weifeng1463/p/10174432.html
相关测试的yaml:https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/
[实践OK]Docker里的php-fpm 错误日志级别由notice修改为warning
虚拟云与Docker jackxiang 2019-5-24 16:05
Docker里的php-fpm 错误日志级别由notice修改为warning 不指定,原因是默认的notice日志太多关于PHP-FPM接受设置的请求数后通出的notice:
[24-May-2019 16:22:58] NOTICE: [pool www] child 281 exited with code 0 after 5.861800 seconds from start
[24-May-2019 16:22:58] NOTICE: [pool www] child 282 started
[24-May-2019 16:23:01] NOTICE: [pool www] child 282 exited with code 0 after 2.919651 seconds from start
[24-May-2019 16:23:01] NOTICE: [pool www] child 283 started
1、php-fpm 错误日志
#默认位置 安装目录下的 log/php-fpm.log
error_log = log/php-fpm.log
#错误级别 alert(必须立即处理), error(错误情况), warning(警告情况), notice(一般重要信息), debug(调试信息). 默认: notice.
log_level = notice
来自:https://www.cnblogs.com/siqi/p/3656823.html
[24-May-2019 16:22:58] NOTICE: [pool www] child 281 exited with code 0 after 5.861800 seconds from start
[24-May-2019 16:22:58] NOTICE: [pool www] child 282 started
[24-May-2019 16:23:01] NOTICE: [pool www] child 282 exited with code 0 after 2.919651 seconds from start
[24-May-2019 16:23:01] NOTICE: [pool www] child 283 started
1、php-fpm 错误日志
#默认位置 安装目录下的 log/php-fpm.log
error_log = log/php-fpm.log
#错误级别 alert(必须立即处理), error(错误情况), warning(警告情况), notice(一般重要信息), debug(调试信息). 默认: notice.
log_level = notice
来自:https://www.cnblogs.com/siqi/p/3656823.html
[实践OK]dive - 用于探索docker image中每个图层的工具
虚拟云与Docker jackxiang 2018-12-10 09:51
Docker 容器镜像是一个轻量、独立、含有运行某个应用所需全部软件的可执行包,那么一个 Docker 镜像里面会包含什么东西?这个名为 Dive 的工具正是用来分析和浏览 Docker 镜像每层的内容。
通过分析 Docker 镜像,我们可以发现在各个层之间可能重复的文件,并通过移除它们来减小 Docker 镜像的大小。
Dive 是一个用 Go 语言编写的自由开源工具。Dive 工具不仅仅是一个 Docker 镜像分析工具,它还可以帮助使用者用于构建镜像。
RHEL/Centos
curl -OL https://github.com/wagoodman/dive/releases/download/v0.3.0/dive_0.3.0_linux_amd64.rpm
rpm -i dive_0.3.0_linux_amd64.rpm
来自:https://javascript.ctolib.com/wagoodman-dive.html
通过分析 Docker 镜像,我们可以发现在各个层之间可能重复的文件,并通过移除它们来减小 Docker 镜像的大小。
Dive 是一个用 Go 语言编写的自由开源工具。Dive 工具不仅仅是一个 Docker 镜像分析工具,它还可以帮助使用者用于构建镜像。
RHEL/Centos
curl -OL https://github.com/wagoodman/dive/releases/download/v0.3.0/dive_0.3.0_linux_amd64.rpm
rpm -i dive_0.3.0_linux_amd64.rpm
来自:https://javascript.ctolib.com/wagoodman-dive.html