由于IP地址不会出现在kvm进程参数中,如果kvm虚拟机的名字(或其他属性)上也不标记IP地址的话,使用者只告知IP地址的时候就不太好查找虚拟机了。
查找办法:
- 首先,根据IP地址查找到MAC地址
- 查找方法:
- 同一网段的其它机器上ping一下虚拟机的IP地址,然后,arp -an查看IP对应的MAC地址
- 查找方法:
- 然后,根据MAC地址去进程中搜索就行了
注意: 这里是机器活着到底情况下的办法,如果机器死了的时候就不能这样了,所以,最好还是把IP地址标记到某个地方
DevOps
由于IP地址不会出现在kvm进程参数中,如果kvm虚拟机的名字(或其他属性)上也不标记IP地址的话,使用者只告知IP地址的时候就不太好查找虚拟机了。
查找办法:
注意: 这里是机器活着到底情况下的办法,如果机器死了的时候就不能这样了,所以,最好还是把IP地址标记到某个地方
centos官方yum源目前更新至podman-1.4.4,距离最新的1.5并不太远,所以,centos7上直接yum install -y podman就行。
podman search busybox
podman pull docker.io/library/busybox
podman run -it –rm busybox
查看相关进程:
进程分析:
通过execsnoop了解podman的基本逻辑:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
3182 2530 podman run -it --rm busybox 3188 3187 /usr/sbin/iptables --version 3189 3187 /usr/sbin/ip6tables --version 3195 3193 /usr/libexec/cni/loopback 3200 3193 /usr/libexec/cni/bridge 3206 3200 /usr/libexec/cni/host-local 3212 3200 /usr/sbin/iptables --version 3213 3200 /usr/sbin/iptables -t nat -S --wait 3214 3200 /usr/sbin/iptables -t nat -N CNI-d286860d1f2c10088f58c4fa --wait 3215 3200 /usr/sbin/iptables -t nat -C CNI-d286860d1f2c10088f58c4fa -d 10.88.0.4/16 -j ACCEPT [...] 3216 3200 /usr/sbin/iptables -t nat -A CNI-d286860d1f2c10088f58c4fa -d 10.88.0.4/16 -j ACCEPT [...] 3217 3194 /usr/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/vethaec894ac --prefix=/net/ipv4/neigh/vethaec894ac --prefix=/net/ipv6/conf/vethaec894ac --prefix=/net/ipv6/neigh/vethaec894ac 3218 3200 /usr/sbin/iptables -t nat -C CNI-d286860d1f2c10088f58c4fa ! -d 224.0.0.0/4 -j [...] 3219 3200 /usr/sbin/iptables -t nat -A CNI-d286860d1f2c10088f58c4fa ! -d 224.0.0.0/4 -j [...] 3220 3200 /usr/sbin/iptables -t nat -C POSTROUTING -s 10.88.0.4 -j CNI-d286860d1f2c10088f58c4fa [...] 3221 3200 /usr/sbin/iptables -t nat -A POSTROUTING -s 10.88.0.4 -j CNI-d286860d1f2c10088f58c4fa [...] 3222 3190 /usr/libexec/cni/portmap 3226 3190 /usr/sbin/iptables -t filter -S --wait 3227 3190 /usr/sbin/iptables -t filter -S --wait 3228 3190 /usr/sbin/iptables -t filter -C FORWARD -m comment --comment CNI firewall plugin rules [...] 3229 3190 /usr/sbin/iptables -t filter -C CNI-FORWARD -m comment --comment CNI firewall plugin rules [...] 3230 3190 /usr/sbin/iptables -t filter -C CNI-FORWARD -d 10.88.0.4/32 -m conntrack [...] 3231 3190 /usr/sbin/iptables -t filter -A CNI-FORWARD -d 10.88.0.4/32 -m conntrack [...] 3232 3190 /usr/sbin/iptables -t filter -C CNI-FORWARD -s 10.88.0.4/32 -j ACCEPT [...] 3233 3190 /usr/sbin/iptables -t filter -A CNI-FORWARD -s 10.88.0.4/32 -j ACCEPT [...] 3234 3191 /usr/libexec/podman/conmon -s -c 25320a1e64226351a66056671a5f0c8c382204b3ea183d69d1fce06293164f8d -u 25320a1e64226351a66056671a5f0c8c382204b3ea183d69d1fce06293164f8d -n sad_dijkstra -r [...] 3236 3235 /usr/bin/runc --systemd-cgroup 3242 3241 /usr/bin/runc init 3252 3190 /usr/bin/runc start 25320a1e64226351a66056671a5f0c8c382204b3ea183d69d1fce06293164f8d 3245 3244 sh |
通过podman info 了解podman:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
[root@docker ~]# podman info host: BuildahVersion: 1.9.0 Conmon: package: podman-1.4.4-4.el7.centos.x86_64 path: /usr/libexec/podman/conmon version: 'conmon version 0.3.0, commit: unknown' Distribution: distribution: '"centos"' version: "7" MemFree: 81936384 MemTotal: 1567813632 OCIRuntime: package: runc-1.0.0-65.rc8.el7.centos.x86_64 path: /usr/bin/runc version: 'runc version spec: 1.0.1-dev' SwapFree: 3111645184 SwapTotal: 3221221376 arch: amd64 cpus: 1 hostname: docker kernel: 3.10.0-957.1.3.el7.x86_64 os: linux rootless: false uptime: 216h 45m 40.51s (Approximately 9.00 days) registries: blocked: null insecure: null search: - registry.access.redhat.com - docker.io - registry.fedoraproject.org - quay.io - registry.centos.org store: ConfigFile: /etc/containers/storage.conf ContainerStore: number: 1 GraphDriverName: overlay GraphOptions: null GraphRoot: /var/lib/containers/storage GraphStatus: Backing Filesystem: xfs Native Overlay Diff: "true" Supports d_type: "true" Using metacopy: "false" ImageStore: number: 1 RunRoot: /var/run/containers/storage VolumePath: /var/lib/containers/storage/volumes |
目前所有发行版并不带有该功能,通过varlink来实现的,原本只listen本地的unix socket,远程连接需要先走ssh通道,话说这个也无可厚非
需要使用crun作为运行时,而不是runc,因为需要cgroup v2,runc不支持cgroup v2
https://github.com/containers/libpod/blob/master/docs/tutorials/rootless_tutorial.md
一个管理镜像仓库的工具
虽然可以设置一个检查点,保存到文件后,从另外一个机器上restore后,继续运行,但是,该模式从网络的角度来看,等待时间太长,或者根本就是中断的,而OpenStack中虚拟机的热迁移基本是无感知的;
测试发现,podman的checkpoint功能完成export功能都很难,尚未测试成功; 另外,如果容器中有僵尸进程,基本是export不了的
bash中的函数名中可以包含中划线(-)的,由于中划线比下划线敲起来要容易,所以我就喜欢中划线。但是一般来讲,中划线不能作为单词的一部分的,所以,关键字补全的时候就不能很好的补全。
但是,vim中可以让中划线作为关键字的字符,设置方法为:
se lisp
参考: https://superuser.com/questions/403516/exclude-dash-from-word-separators-in-vi
或vim 中查看帮助: help ‘iskeyword’
http://developer.51cto.com/art/201902/591639.htm
部署一个sourcegraph来在线阅读代码可能是一个不错的体验
关于容器中已经没有了进程,但是容器还是杀不死的情况:
用bash作为初始进程启动了一个容器:
1 |
docker run -it --rm redis:5.0.5 bash |
然后,在bash中cat了一个二进制文件:
1 |
cat /usr/local/bin/gosu |
如此,bash卡死,不能操作了,可能是因为转码没有处理好导致的。
docker top时已经看不到容器中存在任何进程了,但是docker run进程依然存在
docker stop操作也不能停掉容器。
原因在于:
就是说,docker run进程向/dev/pts/0 write的时候,阻塞住了,这就和pts有关了
解决办法,kill -9 22784
https://blog.csdn.net/xj80231314/article/details/88689898
看的想吐的redis集群
php中参考的conf.d 目录是在编译时指定的,不能在运行时修改,如果非要修改,也不是不行,可以直接用sed来修改php这个二进制文件:
1 |
sed 's/conf\.d/conf.e/' /usr/bin/php >/tmp/php |
如果是签名或者有摘要校验的二进制文件如phar文件,则不能直接使用sed修改
由于学习swoole的时候,需要使用swoole扩展,但是偶尔又想单步调试一些逻辑,不得不使用xdebug扩展,但是swoole扩展和xdebug扩展势不两立,有不能通过参数来切换是否使用xdebug,于是通过此法搞了两个php二进制文件,二者使用不同的conf.d 目录,就可以单独配置扩展了。
但是phpstorm中单个项目不能同时使用两个php解释器,只好在使用时临时切换php解释器了
A进程总是连接B进程listen的1158端口,而且连接到断开的持续时间很短,由于知道1158端口,所以,B进程很容易被找到,现在不知道A进程是哪个,只知道是本机的某进程来连接1158端口的。
如何找到A进程呢?
对于持续时间不太短的连接,我们通常可以使用ss -anp来查看,但是对于持续时间足够短的连接,ss是不太容易抓到的。毕竟,当机器上进程数多的时候,每个连接都扫一遍所有的进程下的fd,会明显感觉很慢的。
所以,一种办法是:
不使用ss的-p选项,只使用ss -an,从结果中拿到感兴趣的端口后,再去/proc/*/fd/* 中找对应的fd,但是,进程的fd中对应的socket的id并不出现在ss的结果中,无法对应起来。
另一种办法:
直接去 /proc/net/tcp 中查找感兴趣的连接,基本逻辑如下:
1 2 3 4 5 6 7 8 9 |
while : ; do cat /proc/net/tcp |grep ":0486"|awk '$10 != 23774779 {print $10}' done | while read key;do echo $key; for fd in /proc/*/fd/*; do v=$(readlink $fd) [[ $v = socket*$key* ]] && { echo $fd $v ; } done done |
其中的 :0486 是我们感兴趣的端口号的16进制表示, 23774779 是我们不感兴趣的连接
其实,这样也未必能抓到感兴趣的连接,毕竟连接消失的太快。
比较靠谱的办法是:
1 |
kill -19 $pid_of_B |
让B进程休眠,这样,A进程进入的连接不能被及时处理,就不会立即断开,然后使用ss -anp就可以了,除非A进程设置了非常短的超时,那么,可能我们就需要研究一下systemtap了
https://docs.zephir-lang.com/0.12/en/motivation
zephir是为开发PHP扩展而发明的一门语言,而且只能用来开发PHP扩展,通常,PHP的扩展都是编译运行的,但是zephir却是把自己编译成字节码给zend解释执行的,但是他也能进一步编译成机器语言
Zephir was not created to replace PHP or C. Instead, we think it is a complement to them, allowing PHP developers to venture into code compilation and static typing. Zephir is an attempt to join good things from the C and PHP worlds, looking for opportunities to make applications faster.
只能写带名字空间的class
Code in Zephir must be placed in classes. The language is intended to create object-oriented libraries/frameworks, so code outside of a class is not allowed. Additionally, a namespace is required:
他可以直接调用PHP语言定义的函数
必须写注释:
In most languages, comments are simply text ignored by the compiler/interpreter. In Zephir, multi-line comments are also used as docblocks, and they’re exported to the generated code, so they’re part of the language!
If a docblock is not located where it is expected, the compiler will throw an exception.
zephir相当于是跑在zend上的另一门语言