移动硬盘测速

https://item.jd.com/1179011.html

 

读速度: 60MB/s

写速度: 88MB/s

 

测试方法:

 

linux 下载工具之 aria

有一种文件下载方式为: 把知道的下载源都组织到一个文件中(metalink,扩展名 meta4),这些下载源可以是不同的协议(http、ftp、bt等),然后就有一种工具(linux上为aria,mac上为speed download,windows上有getright 等)会参考该文件,同时从多个下载源下载该文件,这样的话,只要下载源够多,基本不会受下载源带宽限制,就看自己有多大带宽了;下载opensuse(4.1GB)使用metalink文件 紧花费了不到10分钟时间

一般来讲,多线程并行下载是不错的办法,但是同时从不同的下载源(而且是不同的下载协议)来下载,就更加疯狂了

 

参考资料 :

http://blog.csdn.net/wuyanhuiyishi/article/details/1460728

多台机器上批量执行ssh命令的小脚本

脚本:

 

用法:

 

截屏: (这里仅仅输出了要执行的命令,使用时把echo ssh中的echo去掉就好)

关于nsenter

从 help 来看,只要使用了 -p 选项,就可以进入目标进程的pid名字空间,换言之,就可以只看到目标进程所在的名字空间的进程,用法如下:

事实上,

看到的却是nsenter当前所在名字空间(严格来讲,这样描述也不太准确)的所有进程,为什么呢?

因为top参考的是 /proc 文件系统,所以,进入相应的mount空间也很重要,所以,正确的写法为:

syslog协议之PRI解析

syslog协议的第一部分是尖括号引用的一个数字,如: <182>

该数字大小范围为: 0 ~ 255, 为1个字节表达的数字,包含两部分内容:

低三位: (0 ~ 7)称作: Severity

 

高5位(右移3位后): (0 ~ 31)称作:Facility

 

根据尖括号中的数字还原上面两个部分的方法,以 182 为例:

即: local6的information

 

参考:https://tools.ietf.org/html/rfc3164#section-4.1.1

不需要临时文件的diff

diff 可以比较两个文件,那么能否比较两个字符串呢(主要是懒得创建文件),其实是可以的,如:

不仅仅diff可以这么玩, vimdiff也能这么玩,如:

那么,比较的两部分算是什么呢?

其实也是两个文件,如下:

这是两个什么文件呢?其实是两个pipe,如下:

这里vimdiff还为这两个pipe创建了两个交换文件.

知识点

bash中 “<(list)” 是一种语法结构,叫做Process Substitution :

3.5.6 Process Substitution

Process substitution allows a process’s input or output to be referred to using a filename. It takes the form of

or

The process list is run asynchronously, and its input or output appears as a filename. This filename is passed as an argument to the current command as the result of the expansion. If the >(list) form is used, writing to the file will provide input for list. If the <(list) form is used, the file passed as an argument should be read to obtain the output of list. Note that no space may appear between the < or > and the left parenthesis, otherwise the construct would be interpreted as a redirection. Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files.

When available, process substitution is performed simultaneously with parameter and variable expansion, command substitution, and arithmetic expansion.

该语法结构在zsh中记作: =(list)

 

注意1:

这里产生的文件管道,是管道,是管道只能读一次,不能到做普通文件使用,如:

这里cat了两次,只输出一次hello

为什么写个简单的测试还要放在function里面?拿出来不好使

脚本:

 

注意2:

进程替换只对于bash生效,对于sh不生效; sh 不理解进程替换,至少对于4.2.46版本的bash来讲,如果把bash mv成为 sh,就不再理解进程替换了; 更有甚者,如果 sh 软连接到bash,然后使用sh执行上面脚本就得出现错误

参考:

https://unix.stackexchange.com/questions/62140/filesize-difference-of-same-name-folders

http://tiswww.case.edu/php/chet/bash/bashref.html#Process-Substitution

 

ceph osd 操作

ceph  osd down $id: 将osd $id 标记为down(mark down),达到不再访问的效果,并不真正停止进程,(仍然参与hash?),ceph osd tree 查看的时候,依然可能是up的状态

ceph osd out $id: 将weight 设置为0(零), 达到不再访问的效果,(不参与hash?)

ceph osd lost $id: 删除该osd上的所有数据,该操作比较危险,需要明确指定 –yes-i-really-mean-it, 如:

ceph osd rm $id: 从集群中彻底删除该osd;如果要删除某osd,必须先停止进程,仅仅标记为down(ceph osd down $id) 是不够的,如:

停止指定osd进程:

仅仅rm掉osd还是可以在ceph osd tree中看到,如下:

需要从crush中移除:

然而,依然删除的不够干净,如 auth中还有相关信息:

删除:

查看所有osd: