- 通过pipework给容器添加、配置、期望网络(这个就不说了)
- 如果在不重启容器的情况下,禁用容器的网络,然后在需要的时候在启动呢?
- 禁用容器网络: ifdown eth0
- 启用容器网络: ifup eth0
- 如果容器中没有ifup、ifdown、甚至没有ip命令呢?
- 通过nsenter -t pid-of-container -n (进入容器网络名字空间,但是文件系统还是宿主机的)
- 执行ip相关命令:
123ip link set eth0 upip addr add 172.16.0.3/24 dev eth0ip route add default via 172.16.0.1
注意: 这里使用的是ip命令,而不是ifconfig、ifup之类的,因为ip命令不参考本地文件系统中的相关配置,而后者会参考本地文件系统相关网络配置;因为我们需要ip命令,所以使用的是宿主机的文件系统,而不是容器的文件系统,所以在这里设置容器网卡的时候,不能使用ifconfig、ifup之类
- 在宿主机上使用ip netns exec 也能达到和使用nsenter相同的效果,但是似乎没有发现一个比较好的办法根据pid找到网络名字空间,所以还是nsenter更方便些
paramiko模块学习
第一步:安装
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 |
# pip install paramiko Collecting paramiko Downloading paramiko-2.2.1-py2.py3-none-any.whl (176kB) 100% |████████████████████████████████| 184kB 10kB/s Collecting cryptography>=1.1 (from paramiko) Downloading cryptography-2.0.3-cp27-cp27mu-manylinux1_x86_64.whl (2.2MB) 100% |████████████████████████████████| 2.2MB 5.1kB/s Collecting bcrypt>=3.1.3 (from paramiko) Downloading bcrypt-3.1.3-cp27-cp27mu-manylinux1_x86_64.whl (57kB) 100% |████████████████████████████████| 61kB 3.1kB/s Collecting pyasn1>=0.1.7 (from paramiko) ^@ Downloading pyasn1-0.3.2-py2.py3-none-any.whl (63kB) 100% |████████████████████████████████| 71kB 1.3kB/s Collecting pynacl>=1.0.1 (from paramiko) Downloading PyNaCl-1.1.2-cp27-cp27mu-manylinux1_x86_64.whl (539kB) 100% |████████████████████████████████| 542kB 4.4kB/s Collecting idna>=2.1 (from cryptography>=1.1->paramiko) Downloading idna-2.6-py2.py3-none-any.whl (56kB) 100% |████████████████████████████████| 61kB 4.5kB/s Collecting six>=1.4.1 (from cryptography>=1.1->paramiko) Downloading six-1.10.0-py2.py3-none-any.whl Collecting ipaddress (from cryptography>=1.1->paramiko) Downloading ipaddress-1.0.18-py2-none-any.whl Collecting asn1crypto>=0.21.0 (from cryptography>=1.1->paramiko) Downloading asn1crypto-0.22.0-py2.py3-none-any.whl (97kB) 100% |████████████████████████████████| 102kB 4.2kB/s Collecting enum34 (from cryptography>=1.1->paramiko) Downloading enum34-1.1.6-py2-none-any.whl Collecting cffi>=1.7 (from cryptography>=1.1->paramiko) Downloading cffi-1.10.0-cp27-cp27mu-manylinux1_x86_64.whl (392kB) 100% |████████████████████████████████| 399kB 4.2kB/s Collecting pycparser (from cffi>=1.7->cryptography>=1.1->paramiko) Downloading pycparser-2.18.tar.gz (245kB) 100% |████████████████████████████████| 256kB 6.0kB/s Installing collected packages: idna, six, ipaddress, asn1crypto, enum34, pycparser, cffi, cryptography, bcrypt, pyasn1, pynacl, paramiko Running setup.py install for pycparser ... done Successfully installed asn1crypto-0.22.0 bcrypt-3.1.3 cffi-1.10.0 cryptography-2.0.3 enum34-1.1.6 idna-2.6 ipaddress-1.0.18 paramiko-2.2.1 pyasn1-0.3.2 pycparser-2.18 pynacl-1.1.2 six-1.10.0 You are using pip version 8.1.2, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. |
rpmbuild 之 devel
我们见过比较专业一些的软件会包含多个rpm包,如:
phpor.1.0.0.el7.x86_64
phpor-docs.1.0.0.el7.x86_64
phpor-devel.1.0.0.el7.x86_64
phpor-debuginfo.1.0.0.el7.x86_64
那么,一个spec文件如何build出来多个rpm包呢?
首先,我们以devel为例,参考: https://stackoverflow.com/questions/2913130/building-both-devel-and-normal-version-of-a-rpm-package
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 |
Name: kmymoney Summary: The Personal Finances Manager for KDE. Version: 0.8 Release: 1.%{disttag}%{distver} License: GPL Packager: %packer Group: Productivity/Office/Finance Source0: %{name}2-%version.tar.bz2 BuildRoot: %{_tmppath}/%{name}2-%{version}-%{release}-build BuildRequires: kdebase3-devel Prereq: /sbin/ldconfig %description Description goes here... %package devel #Requires: Summary: KMyMoney development files Group: Productivity/Office/Finance Provides: kmymoney-devel %description devel This package contains necessary header files for KMyMoney development. ... more to go here ... %files ... some files ... %files devel ... the devel files ... |
可见,devel是以子包的形式出现的
示例:
http://kmymoney2.sourceforge.net/phb/rpm-example.html
rpmbuild 安装到BUILDROOT 下面的文件和目录都要打包的rpm包中,否则会报错(rpmbuild会认为你遗忘了),如果不想打包,就提前删掉
rpmbuild 之 /usr/lib/rpm/check-buildroot
rpm打包之前会执行: /usr/lib/rpm/check-buildroot, 其逻辑为,检查将要打包的文件中是否包含buildroot,因为这只是build时候的临时目录,如果出现在打包文件中,就可能会出现问题,起检查方法简单粗暴:
1 |
grep -F "$RPM_BUILD_ROOT" |
如果包含,就会报类似如下的错误信息,然后退出
1 |
Found '/data3/rpmbuild/BUILDROOT/gdb-8.0-1.el7.centos.x86_64' in installed files; aborting |
关于check-buildroot脚本:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
test -z "$QA_SKIP_BUILD_ROOT" || exit 0 if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then exit 0 fi tmp=$(mktemp ${TMPDIR:-/tmp}/cbr.XXXXXX) trap "rm -f $tmp" EXIT find "$RPM_BUILD_ROOT" \! \( \ -name '*.pyo' -o -name '*.pyc' -o -name '*.elc' -o -name '.packlist' \ \) -type f -print0 | \ LANG=C xargs -0r grep -F "$RPM_BUILD_ROOT" >$tmp test -s "$tmp" && { cat "$tmp" echo "Found '$RPM_BUILD_ROOT' in installed files; aborting" exit 1 } || : |
其一:
通过mktemp来创建临时文件,根本不需要自己制造随机文件名
其二:
1 |
trap "rm -f $tmp" EXIT |
保证在脚本退出后删除临时文件
其三:
1 |
test -s "$tmp" && { exit 1; } || : |
注意,这里 ” || : ” 的用法,保证test为假时脚本退出码为零
xfs bug
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 |
[二 8月 15 11:24:30 2017] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [二 8月 15 11:24:30 2017] java D ffff88000b91f7a0 0 18298 3997 0x00000180 [二 8月 15 11:24:30 2017] ffff880e4b3dfad8 0000000000000082 ffff88165bd7f300 ffff880e4b3dffd8 [二 8月 15 11:24:30 2017] ffff880e4b3dffd8 ffff880e4b3dffd8 ffff88165bd7f300 ffff88165bd7f300 [二 8月 15 11:24:30 2017] ffff88000b91f790 ffff88000b91f798 ffffffff00000000 ffff88000b91f7a0 [二 8月 15 11:24:30 2017] Call Trace: [二 8月 15 11:24:30 2017] [<ffffffff8163ae49>] schedule+0x29/0x70 [二 8月 15 11:24:30 2017] [<ffffffff8163c605>] rwsem_down_write_failed+0x115/0x220 [二 8月 15 11:24:30 2017] [<ffffffffa03197a8>] ? xlog_grant_head_check+0x58/0x110 [xfs] [二 8月 15 11:24:30 2017] [<ffffffffa030942e>] ? xfs_vn_update_time+0x6e/0x190 [xfs] [二 8月 15 11:24:30 2017] [<ffffffff81301983>] call_rwsem_down_write_failed+0x13/0x20 [二 8月 15 11:24:30 2017] [<ffffffff8163a09d>] ? down_write+0x2d/0x30 [二 8月 15 11:24:30 2017] [<ffffffffa030b9a1>] xfs_ilock+0xc1/0x120 [xfs] [二 8月 15 11:24:30 2017] [<ffffffffa030942e>] xfs_vn_update_time+0x6e/0x190 [xfs] [二 8月 15 11:24:30 2017] [<ffffffff811f9a85>] update_time+0x25/0xd0 [二 8月 15 11:24:30 2017] [<ffffffff811f9d30>] file_update_time+0xa0/0xf0 [二 8月 15 11:24:30 2017] [<ffffffffa030092d>] xfs_file_aio_write_checks+0x11d/0x180 [xfs] [二 8月 15 11:24:30 2017] [<ffffffffa0300a23>] xfs_file_buffered_aio_write+0x93/0x260 [xfs] [二 8月 15 11:24:30 2017] [<ffffffff811b85a5>] ? mpol_misplaced+0x195/0x1f0 [二 8月 15 11:24:30 2017] [<ffffffffa0300cc0>] xfs_file_aio_write+0xd0/0x150 [xfs] [二 8月 15 11:24:30 2017] [<ffffffff811dde5d>] do_sync_write+0x8d/0xd0 [二 8月 15 11:24:30 2017] [<ffffffff811de67d>] vfs_write+0xbd/0x1e0 [二 8月 15 11:24:30 2017] [<ffffffff8110b684>] ? __audit_syscall_entry+0xb4/0x110 [二 8月 15 11:24:30 2017] [<ffffffff811df11f>] SyS_write+0x7f/0xe0 [二 8月 15 11:24:30 2017] [<ffffffff816460d2>] tracesys+0xdd/0xe2 |
windows 路由之metric
如下图来看, 虽然172.16.22.29存在一条更精确的路由,但是该精确路由的metric比默认路由的metric更大一些,最终还是选择了默认路由,看来metric的影响力还是很大的
添加路由是指定metric参数吧,如下:
明明指定的metric为9,结果却是19(默认网关的metric+9)
可以通过网络设置来修改接口的跃点数(metric),最小值为10(设置为更小的值也没有用)
what is loginuid
4294967295 is just (unsigned long) -1. -1 means that loginuid was not set. This is normal behavior for processes that were not spawned by any login process (e.g. for daemons). loginuid is -1 by default; pam_loginuid module changes it to your user id whenever you login (in a tty/in DM/via ssh), and this value is preserved by child processes.
可惜的是proc.txt并未对此文件有过说明
用途:
Spring Boot Reference Guide
http://docs.spring.io/spring-session/docs/current/reference/html5/
http://docs.spring.io/spring/docs/4.2.9.RELEASE/spring-framework-reference/htmlsingle/
https://spring.io/docs/reference
http://www.jianshu.com/p/3942cce05f71
http://www.mkyong.com/tutorials/spring-boot-tutorials/
redis 之 appendonly.aof
- redis.conf 中默认配置的dir为 “./” ,即为当前目录,一些人会想当然认为是redis.conf 所在目录,而appendonly.aof 默认写在该dir下; 其实,”./” 为进程的cwd
- redis的config set dir命令可以修改redis进程的cwd
- redis的appendonly.aof 的位置会参考在config appendonly yes 被执行时的dir的值,在config appendonly yes后修改dir的值不会立即生效
遇到过的问题:
- 程序一直在tail -f 的方式同步appendonly.aof ,在下午18:16的时候,appendonly.aof 变到了/tmp/appendonly.aof (原本下意识地认为/tmp/appendonly.aof 只是18:16之后的数据,行文至此,才意识到,/tmp/appendonly.aof中不是18:16后的数据,而是全部数据);目前确认进程没有被重启过,目前能够想到的能够完成这个切换的操作为:
12345CONFIG SET appendonly noconfig set dir /tmpCONFIG SET appendonly yes
但是似乎没有谁会去执行这么复杂的命令
ssh on proxy
缘起:
- vpn逐渐不好使了
- 虽然曾经可以通过ssh来翻墙,现在ssh已经自身难保了,也需要借助其它代理才能出门
借助nc也能搞定