kubectl exec stress-pod -- ps -o "rss,vsz,comm"|grep -v VSZ
2576 6256 stress-ng
3628 6900 stress-ng-cpu
  64 6256 stress-ng-vm
135m 262m stress-ng-vm
   4 1504 ps

rss: 物理
vsz: 虚拟
VSS - Virtual Set Size 虚拟耗用内存(包含共享库占用的内存)
RSS - Resident Set Size 实际使用物理内存(包含共享库占用的内存)

背景:在多进程时,用那个叫物理内存、虚拟内存的,怎么看?https://blog.csdn.net/i_am_jojo/article/details/7862362

ps -eo pid,ppid,gid,sid,tty,cmd --forest|less


  -e     Select all processes.  Identical to -A.
  -o format
              User-defined format.  format is a single argument in the form of a blank-separated or comma-separated
              list, which offers a way to specify individual output columns.  The recognized keywords are described
              in the STANDARD FORMAT SPECIFIERS section below.  Headers may be renamed (ps -o pid,ruser=RealUser -o
              comm=Command) as desired.  If all column headers are empty (ps -o pid= -o comm=) then the header line
              will not be output.  Column width will increase as needed for wide headers; this may be used to widen
              up columns such as WCHAN (ps -o pid,wchan=WIDE-WCHAN-COLUMN -o comm).  Explicit width control (ps opid,
              wchan:42,cmd) is offered too.  The behavior of ps -o pid=X,comm=Y varies with personality; output may
              be one column named "X,comm=Y" or two columns named "X" and "Y".  Use multiple -o options when in
              doubt.  Use the PS_FORMAT environment variable to specify a default as desired; DefSysV and DefBSD are
              macros that may be used to choose the default UNIX or BSD columns.

       -C cmdlist
              Select by command name.  This selects the processes whose executable name is given in cmdlist.
       --forest
              ASCII art process tree.

#ps -eo 'pid,ppid,gid,sid,tty,cmd' |grep Easy
26721 62388     0 62388 pts/4    EasySwoole
26722 26721     0 62388 pts/4    EasySwoole
26744 26722     0 62388 pts/4    EasySwoole.Crontab
31311 26722     0 62388 pts/4    EasySwoole.Worker.0
31312 26722     0 62388 pts/4    EasySwoole.Worker.1
31313 26722     0 62388 pts/4    EasySwoole.Worker.2
31314 26722     0 62388 pts/4    EasySwoole.Worker.3
31315 26722     0 62388 pts/4    EasySwoole.Worker.4
31316 26722     0 62388 pts/4    EasySwoole.Worker.5
31317 26722     0 62388 pts/4    EasySwoole.Worker.6
31318 26722     0 62388 pts/4    EasySwoole.Worker.7
31319 26722     0 62388 pts/4    EasySwoole.TaskWorker.8
31320 26722     0 62388 pts/4    EasySwoole.TaskWorker.9
31321 26722     0 62388 pts/4    EasySwoole.TaskWorker.10
31322 26722     0 62388 pts/4    EasySwoole.TaskWorker.11
31323 26722     0 62388 pts/4    EasySwoole.TaskWorker.12
31324 26722     0 62388 pts/4    EasySwoole.TaskWorker.13
31325 26722     0 62388 pts/4    EasySwoole.TaskWorker.14
31326 26722     0 62388 pts/4    EasySwoole.TaskWorker.15

对Crontab进行查看:
lsof -nPp 26744|grep swoole.log
php     26744 root   11u      REG              253,0  39874179 100744037 /data/logs/php/swoole.lo

#lsof -nPp 26721 |grep LISTEN
php     26721 root    3u     IPv4             763966       0t0       TCP *:8080 (LISTEN)
php     26721 root   10u     IPv4             762762       0t0       TCP 127.0.0.1:9000 (LISTEN)


26721 62388     0 62388 pts/4         \_ EasySwoole
26722 26721     0 62388 pts/4             \_ EasySwoole
26742 26722     0 62388 pts/4                 \_ HotReload
26743 26722     0 62388 pts/4                 \_ KafkaAddFormId
26744 26722     0 62388 pts/4                 \_ EasySwoole.Crontab
31311 26722     0 62388 pts/4                 \_ EasySwoole.Worker.0
31312 26722     0 62388 pts/4                 \_ EasySwoole.Worker.1
31313 26722     0 62388 pts/4                 \_ EasySwoole.Worker.2
31314 26722     0 62388 pts/4                 \_ EasySwoole.Worker.3
31315 26722     0 62388 pts/4                 \_ EasySwoole.Worker.4
31316 26722     0 62388 pts/4                 \_ EasySwoole.Worker.5
31317 26722     0 62388 pts/4                 \_ EasySwoole.Worker.6
31318 26722     0 62388 pts/4                 \_ EasySwoole.Worker.7
31319 26722     0 62388 pts/4                 \_ EasySwoole.TaskWorker.8
31320 26722     0 62388 pts/4                 \_ EasySwoole.TaskWorker.9
31321 26722     0 62388 pts/4                 \_ EasySwoole.TaskWorker.10
31322 26722     0 62388 pts/4                 \_ EasySwoole.TaskWorker.11
31323 26722     0 62388 pts/4                 \_ EasySwoole.TaskWorker.12
31324 26722     0 62388 pts/4                 \_ EasySwoole.TaskWorker.13
31325 26722     0 62388 pts/4                 \_ EasySwoole.TaskWorker.14
31326 26722     0 62388 pts/4                 \_ EasySwoole.TaskWorker.15

ps --headers -eo pid,ppid,GID,tty,sid,vsz,rss,cmd -C EasySwoole


To see every process with a user-defined format:
          ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm

Print only the process IDs of syslogd:
          ps -C syslogd -o pid=

相查看树,能看到进程的继承关系:
ps -eo 'pid,ppid,vsz,rss,cmd' --forest
3078  1214  48620  3032  \_ sshd: xiangdong [priv]
3084  3078  48752  1680      \_ sshd: xiangdong@pts/0,pts/1,pts/2
3085  3084 108352  1788          \_ -bash
3644  3085 189592  2940          |   \_ sudo su -
3645  3644 163756  1964          |       \_ su -
3646  3645 108476  1908          |           \_ -bash
5416  3646 108412  1200          |               \_ ps -eo pid,ppid,vsz,rss,cmd --forest
5417  3646 105460   816          |               \_ less

1481     1  55604  1460 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
1484  1481  76816 22864  \_ nginx: worker process                                          
1485  1481  76816 22936  \_ nginx: worker process                                          
1486  1481  76816 22936  \_ nginx: worker process                                          
1487  1481  76816 22936  \_ nginx: worker process  


cat pod-test.yml    

执行一下命令安装以后就可以locate XXX了

yum install mlocate

sudo updatedb

locate  *.doc

实践如下:
在linux下搞软件开发的朋友, 几乎没有不知道strings命令的。我们先用man strings来看看:

strings - print the strings of printable characters in files.  

意思是, 打印文件中可打印的字符。  我来补充一下吧, 这个文件可以是文本文件(test.c), 可执行文件(test),  动态链接库(test.o), 静态链接库(test.a)


脱离代码地长篇大论而不去实际验证, 不是我的风格。 还是搞点代码下菜吧(代码存在test.c中):

cat test.c



我们来看看strings test.c的结果:
strings test.c


可以看到, 确实打印出了test.c中的很多字符。
下面, 我们对可执行文件用strings试试, 如下:
gcc test.c
strings a.out
/lib64/ld-linux-x86-64.so.2
__gmon_start__
libc.so.6
printf
__libc_start_main
GLIBC_2.2.5
fff.
fffff.
l$ L
t$(L
|$0H
oh, my dear, c isd

可以看到, 打印出了a.out中很多字符。
实际上, 如果有目标文件、静态库或动态库,, 也是可以用strings命令进行打印操作的。 我们来看看:
xxx.h文件:

xxx.c文件:
cat  xxx.c


然后, 我们来看看怎么制作静态、动态库吧(在后续博文中会继续详细介绍):
gcc -shared -fPIC -c xxx.c  #-fPI得加上,否则会报relocation R_X86_64_32 against `.rodata'
gcc -shared -fPIC -o libxxx.so xxx.o

问题:
gcc -shared -fPIC -o libxxx.so xxx.o
/usr/bin/ld: xxx.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
解决办法:
gcc默认没加-fPIC参数,得手工加上即可。
strings xxx.o
rainy days

strings libxxx.a


strings libxxx.so

trings命令很简单, 看起来好像没什么, 但实际有很多用途。 下面, 我来举一个例子。  在大型的软件开发中, 假设有100个.c/.cpp文件, 这个.cpp文件最终生成10个.so库, 那么怎样才能快速知道某个.c/.cpp文件编译到那个.so库中去了呢? 当然, 你可能要说, 看makefile不就知道了。 对, 看makefile肯定可以, 但如下方法更好, 直接用命令:
      strings -f "*.so" | grep "xxxxxx"

      如果还不明白, 那就就以上面的小程序为例为说明, 不过, 此处我们考虑所有的文件, 如下:

strings -f * | grep "my dear"
a.out: oh, my dear, c isd
test.c:         printf("oh, my dear, c isd\n", c);

可以看到, 源文件test.c和可执行文件中皆有"my dear"串, 一下子就找到了对应的文件,清楚了吧。如果某.c/.cpp文件编译进了.so库, 那么,strings -f * | grep "my dear"必定可以找到对应的.so文件, 其中"my dear"为该.c/.cpp文件中的某个日志串(比如以printf为打印)。

来自:https://blog.csdn.net/stpeace/article/details/46641069
背景: 系统启动的grub.cfg 不一样,有的在/boot/efi/EFI/centos/grub.cfg ,有的在 /etc/grub2.cfg

某天挂载了一个新硬盘后,我的centos7系统第二天就出现了崩溃现象,报错如题“failed to start crash recovery kernel arming”.

意思大致为“内存崩溃捕获机制未能成功启动”,一搜才知道这是因为一个叫做kdump的服务无法启动导致的。

那么什么是kdump呢?

kdump 是一种先进的基于 kexec 的内核崩溃转储机制。当系统崩溃时,kdump 使用 kexec 启动到第二个内核。第二个内核通常叫做捕获内核,以很小内存启动以捕获转储镜像。第一个内核保留了内存的一部分给第二内核启动用。由于 kdump 利用 kexec 启动捕获内核,绕过了 BIOS,所以第一个内核的内存得以保留。这是内核崩溃转储的本质。详细的在:http://www.ibm.com/developerworks/cn/linux/l-cn-kdump1/index.html#major3

那接下来查找失败的原因:

看到一个博文中说与启动文件配置有关

查看/etc/grub.conf 文件,发现crashkernel=auto,

系统对crashkernel=auto的定义为:

如果系统的内存 <= 8 GB 对kdump kernel不会保留任何内容;也就是说,crashkernel=auto 等

于关掉了机器上的kdump功能;

如果系统的内存> 8 GB但是<= 16 GB,crashkernel=auto会保留256M,等同于crashkernel=256M;

如果系统内存> 16GB, crashkernel=auto会保留512M, 等同于crashkernel=512M

安装虚拟机时,给虚拟机设置的内存为1G,所以说系统关掉了kdump。

接下来就是改写配置,但是没能在系统中找到博文中所说的/etc/grub.conf这个文件,后来想到从Centos 7之后启动就采用grub2 了,所以vi /etc/grub2.cfg把其中的crashkernel=auto改成crashkernel=256M重启就成功了。

来自:https://www.jianshu.com/p/c9e741c24d2b
在mac下开发的时候,经常会发现有些文件的属性后面,有个@符号



如上图所示。为什么呢?


在mac os 下 HFS+的文件系统里,有时候有些文件会附加上mac的专有属性,@属性就表示文件或文件夹是来自互联网下载
去掉方法:
xattr -l 文件名:查看attr
xattr -d 属性名:删除attr


来自:https://blog.csdn.net/mysteryhaohao/article/details/51900188
mac下发现不能用记事本打开文本文件,ls -la 发现格式后面有个@:
https://blog.csdn.net/wk3368/article/details/29597535
如何用tar压缩文件夹到指定目录:
tar -zxvf /usr/local/jmeter.tar.gz -C /usr/local/  && rm -rf /usr/local/jmeter.tar.gz && chmod -R 755 /usr/local/jmeter

压缩:
tar -cvzf /test/tmp/abc.tar.gz /test/tcp/abc

实例,将魔方MYSIM数据库给压缩到根目录下:
tar -cvzf /mofang.08.21.tar.gz mofang/

解压
tar -cvxf abc.tar.gz  -C /test/tmp
导语
    Redhat企业级系统的6.7版自带SSH版本为OpenSSH_5.3p1, 基于审计和安全性需求,建议将其升级到最新的OpenSSH版本,当前官网最新版本为7.4p1. 本文档将详细介绍OpenSSH升级的完整步骤。需要说明的是,升级过程中虽然涉及zlib、openssl和openssh的卸载,但是并不会导致当前的ssh远程连接会话断开,因此是可以将整个升级过程写成自动化脚本以进行自动批量部署的。后面咱准备逐步过度到CentOS7了,新版在SSH底层上优化了TCP连接传输功能。在譬如拷贝时会用同一个TCP的FD,而旧版本的是没有这个功能的。再就是刚连接过了在超时设置范围内,再次发起连接时也会复用之前的一个Socket的FD句柄,提高连接效率。
编译安装OpenSSH7.4p1一共分二步,
第一步:安装编译需要的RPM包:


第二步:编译并安装到和原来一样的目录,如下步骤:
tar zxvf openssh-7.4p1.tar.gz
cd openssh-7.4p1
ll
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords --with-kerberos5=/usr/lib64/libkrb5.so
make && make install
cp -rf /usr/local/src/openssh-7.4p1/contrib/redhat/sshd.init /etc/init.d/sshd  
cp -rf contrib/redhat/sshd.init /etc/init.d/sshd  
chmod +x /etc/init.d/sshd
chkconfig --add sshd
vim /etc/init.d/sshd
sed -i '/sbin/restorecon /etc/ssh/ssh_host_key.pub/s/^/#/'  /etc/init.d/sshd  
sed -i 's/#PermitRootLogin/PermitRootLogin/' /etc/ssh/sshd_config
vim /etc/ssh/sshd_config
ssh -V
service sshd restart
vim /etc/ssh/sshd_config
ll
vim /etc/ssh/sshd_config
ps -ef|grep ssh
service sshd start
history

附录:
反查一些OpenSSH需要的动态库,RPM包的安装路径辅助上面参数配置:
rpm -ql openssh-server-5.3p1-122.el6.x86_64
/etc/pam.d/ssh-keycat
/etc/pam.d/sshd
/etc/rc.d/init.d/sshd
/etc/ssh/sshd_config
/etc/sysconfig/sshd
/usr/libexec/openssh/sftp-server
/usr/libexec/openssh/ssh-keycat
/usr/sbin/.sshd.hmac
/usr/sbin/sshd
/usr/share/doc/openssh-server-5.3p1
/usr/share/doc/openssh-server-5.3p1/HOWTO.ssh-keycat
/usr/share/man/man5/moduli.5.gz
/usr/share/man/man5/sshd_config.5.gz
/usr/share/man/man8/sftp-server.8.gz
/usr/share/man/man8/sshd.8.gz
/var/empty/sshd



ldd /usr/sbin/sshd
        linux-vdso.so.1 =>  (0x00007fffbc5ff000)
        libpam.so.0 => /lib64/libpam.so.0 (0x00007f2d19bf3000)
        libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007f2d1980e000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f2d19605000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f2d19401000)
        libutil.so.1 => /lib64/libutil.so.1 (0x00007f2d191fe000)
        libz.so.1 => /lib64/libz.so.1 (0x00007f2d18fe7000)
        libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f2d18db0000)
        libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f2d18b96000)
        libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f2d18951000)
        libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f2d1866a000)
        libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f2d1843e000)
        libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f2d18239000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f2d17ea5000)
        libaudit.so.1 => /lib64/libaudit.so.1 (0x00007f2d17c89000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2d17a6b000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003c0e400000)
        libfreebl3.so => /lib64/libfreebl3.so (0x00007f2d177f4000)
        libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f2d175e9000)
        libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f2d173e5000)
        libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f2d171c6000)

rpm -qf /lib64/libpam.so.0 >> /tmp/jackRpmResult.txt
rpm -qf /usr/lib64/libcrypto.so.10 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/librt.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libdl.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libutil.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libz.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libcrypt.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libresolv.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libgssapi_krb5.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libkrb5.so.3 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libk5crypto.so.3 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libcom_err.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libc.so.6 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libaudit.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libpthread.so.0 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/ld-linux-x86-64.so.2 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libfreebl3.so >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libkrb5support.so.0 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libkeyutils.so.1 >> /tmp/jackRpmResult.txt
rpm -qf /lib64/libselinux.so.1 >> /tmp/jackRpmResult.txt

需要这些包:
rpm -qa|grep audit-libs-2.2-2
rpm -qa|grep glibc-2.12-1.192
rpm -qa|grep keyutils-libs-1.4-5
rpm -qa|grep krb5-libs-1.10.3-65
rpm -qa|grep libcom_err-1.41.12-23
rpm -qa|grep libselinux-2.0.94-7
rpm -qa|grep nss-softokn-freebl-3.14.3-9
rpm -qa|grep openssl-1.0.1e-57
rpm -qa|grep pam-1.1.1-24
rpm -qa|grep zlib-1.2.3-29


yum 安装软件包:
audit-libs-2.2-2 glibc-2.12-1.192 keyutils-libs-1.4-5 krb5-libs-1.10.3-65 libcom_err-1.41.12-23 libselinux-2.0.94-7 nss-softokn-freebl-3.14.3-9 openssl-1.0.1e-57 pam-1.1.1-24 zlib-1.2.3-29

去掉版本号直接安装:
yum install audit-libs glibc keyutils-libs krb5-libs libcom_err libselinux nss-softokn-freebl openssl pam zlib




参考编译来源:
(1)http://blog.chinaunix.net/uid-28266791-id-5759478.html
(2)https://www.cnblogs.com/xshrim/p/6472679.html
cat php.ini |grep -v "^;"|grep -v ^$

grep -v ^# /etc/vsftpd/vsftpd.conf |grep -v ^$ >> /etc/vsftpd/vsftpd

来自:http://blog.51cto.com/mange888/806342
$cat pingfang.awk


$cat xy.txt
1 2
3 3
4 3
2 3

$./pingfang.awk xy.txt
sum = 5
sum = 18
sum = 25
sum = 13

这些文章{print 'sum =',SquareSum($1,$2)} 都是单引号,估计都没实践过吧?
参考:https://tieba.baidu.com/f?kz=4897365011&mo_device=1&ssid=0&from=844b&uid=0&pu=usm@0,sz@1320_2001,ta@iphone_1_11.4_3_605&bd_page_type=1&baiduid=F7F621D935F5435074FCC25A0863FC2F&tj=www_normal_5_0_10_title&referer=m.baidu.com?pn=0&
http://blog.sina.cn/dpool/blog/s/blog_4cab1a3701007ya9.html
实践成功如下:
vim中 输入 :set
:set
--- Options ---
  comments=:#         filetype=yaml       pastetoggle=<F9>    ttymouse=xterm2
  cscopetag           helplang=en         ruler               viminfo='20,"50
  cscopeverbose       history=50          syntax=yaml         t_Sb=^[[4%dm
  expandtab           hlsearch            ttyfast             t_Sf=^[[3%dm
  backspace=indent,eol,start
  commentstring=# %s
  cscopeprg=/usr/bin/cscope
  fileencodings=ucs-bom,utf-8,latin1
  formatoptions=croql
  guicursor=n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block,a:blinkon0
ormatoptions=croql

这个选项,希望在~/.vimrc中禁止,比如设置为

set formatoptions=tcpmM

但是vim不识别此行,报错.无法禁止这个选项....

经过百度搜索,发现解决方案.[比较恶心 开源软件的就是配置文件 不人性化]

在粘贴前先设置进入粘贴插入模式,即不会自动缩进和连续注释

set paste

然后再进入插入模式粘贴,啥注释的#号或双斜杠都不影响。AddTime:2018-07-30
在粘贴插入模式下代码是不会自动按格式缩进的,需要使用nopaste设置回来

set nopaste

也可以在.vimrc中设置切换的快捷键,比如设置F9,则可以在.vimrc中加入:

set pastetoggle=<F9>

这样直接在插入模式按F9就会在“-- 插入 --”模式和“-- 插入(粘贴) --”模式中切换
说的就是这个设置:


================================================================================

ecureCRT会将你原来的文本原封不动的按照字符串的样式发送给服务器。所以当你的服务器上的vim设置为autoindent的话,在i模式下,那么它会将secureCRT传输而来的这些字符串再进行一下缩进。若你拷贝的文本中已经有表示缩进的空格或者制表符的话,它们也会被当成字符串,而被缩进。
解决办法:
1. 在拷贝前输入:set paste (这样的话,vim就不会启动自动缩进,而只是纯拷贝粘贴)
2. 拷贝完成之后,输入:set nopaste (关闭paste)


来自:
https://blog.csdn.net/kwame211/article/details/77964106
https://blog.csdn.net/chenghai37/article/details/80698322

vim复制代码包含注释时格式会乱掉的解决办法:
每次复制代码时,如果代码里有 // 这样的注释就容易让格式乱掉,通过下面的设置就可以避免这种情况。

粘贴代码时取消自动缩进
VIM在粘贴代码时会自动缩进,把代码搞得一团糟糕,甚至可能因为某行的一个注释造成后面的代码全部被注释掉,我知道有同学这个时候会用vi去打开文件再粘贴上去(鄙人以前就是这样),其实需要先设置一下

set paste

然后再进入插入模式粘贴,代码就不会被自动缩进。可是敲代码的时候需要自动缩进,又得改回来:

set nopaste

最方便的方法就是在.vimrc中加一句:

set pastetoggle=<F9>
以后在插入模式下,只要按F9键就可以切换自动缩进。

来自:https://blog.csdn.net/tao_627/article/details/18764539
来自:https://eallion.com/aliyun-ntp

公共NTP服务器
Unix类系统:time1-7.aliyun.com 8台:
我也不知道是怎么想的,
随手就去搜索了“阿里云 NTP”,
结果还真有!

ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com

Windows: time.pool.aliyun.com


*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>/dev/null

#/usr/sbin/ntpdate ntp1.aliyun.com
30 Jul 13:27:42 ntpdate[32557]: step time server 120.25.115.20 offset 486.889850 sec

#sed -n 's#ntp.ksyun.cn#ntp1.aliyun.com#p'   /var/spool/cron/root
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>/dev/null
正式替换:
sed -i 's#ntp.ksyun.cn#ntp1.aliyun.com#'   /var/spool/cron/root
成功替换:
cat /var/spool/cron/root
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>/dev/null

Ansbile批量替换:
ansible applet -a"sed -i 's#ntp.ksyun.cn#ntp1.aliyun.com#' /var/spool/cron/root"
ansible applet -m ping      
[DEPRECATION WARNING]: DEFAULT_SUDO_EXE option, In favor of Ansible Become, which is a generic framework. See become_exe. ,
use become instead. This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: DEFAULT_MODULE_LANG option, Modules are coded to set their own locale if needed for screenscraping .
This feature will be removed in version 2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.
#deprecation_warnings = True     允许在ansible-playbook输出结果中禁用“不建议使用”警告
vi /etc/ansible/ansible.cfg
解决办法:
#deprecation_warnings = True
deprecation_warnings = false
CentOS7.X下如何查看并将一个应用设置为开机启动?systemctl start slapd 只是启动,并不是开机启动。


背景:有时候我们使用systemctl命令,如简单点的systemctl start memcached来讲,出现错时,会有一些提示,但是提示的内容是变量,其并没有将参数给编译后的值放入,于是出现如下所示,但是要失败了怎么排查这些参数呢?此文就讲这个问题,如果不是为了linux开机启动提速而并行启动外,这个systemctl其本质是想接管很多东西,但也带来了很多麻烦,难怪linus对此有一定的意见,系统要保持简单,好用。像开机慢可以少开机或不关机嘛,学学人家苹果升级在半夜,你慢就慢,谁管你,从策略上就规避了,把技术搞复杂还是简单是一门哲学,而创始人的价值就在于坚守设计艺术,而不光是技术。
● memcached.service - Memcached
   Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Fri 2018-07-20 18:48:50 CST; 19h ago
  Process: 15266 ExecStart=/usr/local/memcached/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 15266 (code=exited, status=0/SUCCESS)

失败:
systemctl start memcached
Job for memcached.service failed because the control process exited with error code. See "systemctl status memcached.service" and "journalctl -xe" for details.






/etc/sysconfig/memcached


systemctl daemon-reload
systemctl start memcached
systemctl status memcached.service
  Active: failed (Result: exit-code) since Sat 2018-07-21 14:35:22 CST; 5s ago
  Process: 11417 ExecStart=/usr/local/memcached/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS (code=exited, status=71)
  Process: 11399 ExecStartPre=/bin/bash -l -c echo "/usr/local/memcached/bin/memcached" -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS > /tmp/systemctl.debug (code=exited, status=0/SUCCESS)
Main PID: 11417 (code=exited, status=71)

如果有错,需要挑食的参数查看 /tmp/systemctl.debug:
cat /tmp/systemctl.debug
/usr/local/memcached/bin/memcached -u root -p 11211 -m 64 -c 1024 -vv >> /data/logs/memcached/11211/memcached.log 2>&1
一)netstat常用查看端口参数之查看所有tcp/udp端口:
netstat -atlunp|grep 80


二)netstat常用查看端口参数之单独查看tcp/udp端口命令:
netstat -uln

Proto Recv-Q Send-Q Local Address               Foreign Address             State
udp        0      0 0.0.0.0:111                 0.0.0.0:*
udp        0      0 0.0.0.0:808                 0.0.0.0:*
udp        0      0 127.0.0.1:837               0.0.0.0:*
udp        0      0 0.0.0.0:17617               0.0.0.0:*
udp        0      0 0.0.0.0:2392                0.0.0.0:*



假如没有n,直接用netstat -tl,显示的是一些端口的程序名,如下:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 *:5646                      *:*                         LISTEN
tcp        0      0 *:sunrpc                    *:*                         LISTEN
tcp        0      0 *:7824                      *:*                         LISTEN
tcp        0      0 *:webcache                  *:*                         LISTEN
tcp        0      0 *:ssh                       *:*                         LISTEN
tcp        0      0 *:5881                      *:*                         LISTEN

三)netstat常用查看端口参数之单独查看tcp端口命令:
netstat -tln

Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:34945               0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:32740               0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:15770             0.0.0.0:*                   LISTEN

四)netstat本身也是通过读取系统中的/proc/net/tcp(6)文件来实现对当前网络状态的监控输出的
netstat本身也是通过读取系统中的/proc/net/tcp(6)文件来实现对当前网络状态的监控输出的。我们只要依样画葫芦对此文件进行 解析(主要是合并ipv4和ipv6的内容,然后从16进制转换成字符串形式的ip,端口),然后再比对一下,只要发现此socket的远程ip和端口和 php中的$_SERVER['REMOTE_ADDR'],$_SERVER['REMOTE_PORT']相匹配即可。具体实现如下:

摘录:http://www.4shell.org/archives/2064.html
参考:http://www.80sec.com/security-issue-on-linux-fd-inheritance.html
SecureCrt某个设置不合朕的心意,在打开一个新的连接时不是在同一个窗口下,它又新开了一个工作窗口,像下面这样,操作起来让人很不爽:
一个SSH打一一个SecureCRT,
解决方案:点击 File -> Connect In Tab/Tile 连接新的会话

来自:https://blog.csdn.net/u012135425/article/details/79487575
背景:在Linux下习惯使用ll、la、l等ls别名的童鞋到mac os可就郁闷了,
whichi ll
-bash: whichi: command not found
[xiangdong@jenkins_server_bj_sjs_10_71_182_25 .ssh]$ which ll
alias ll='ls -l --color=auto'
        /bin/ls
其实只要在用户目录下建立一个脚本“.bash_profile”,并输入以下内容即可:


ls -l --color=auto

1 2014-461deMacBook-Pro:~ root# cd ~
2 2014-461deMacBook-Pro:~ root#vim .bash_profile
加入:


  保存后,执行

3 2014-461deMacBook-Pro:~ root#source .bash_profile
=============================================

.bash_profile

alias l='ls -alhF'
alias la='ls -AFh'
alias ll='ls -lhAF'
alias l='ls -alhF'
alias la='ls -AFh'
alias ll='ls -lhAF'

然后在终端窗口中输入下列命令后,别名即可立即生效:
source ~/.bash_profile
source ~/.bash_profile

如果不知道如何创建,可以直接在“终端”窗口中依次执行如下命令:

.bash_profile完整创建命令Shell

cd ~
touch .bash_profile
echo "alias l='ls -alhF'" >>.bash_profile
echo "alias la='ls -AFh'" >>.bash_profile
echo "alias ll='ls -lhAF'" >>.bash_profile
source ~/.bash_profile

cd ~
touch .bash_profile
echo "alias l='ls -alhF'" >>.bash_profile
echo "alias la='ls -AFh'" >>.bash_profile
echo "alias ll='ls -lhAF'" >>.bash_profile
source ~/.bash_profile

来自:https://clang.cn/blog/749.html
https://www.cnblogs.com/daly2008/p/4160066.html
背景:Python很火,且连一些如ESP8266的硬件都支持Python了。
目前Python存在两个版本Python2和Python3系列,且这两个版本同时在更新与维护。到底是选择Python2还是选择Python3,取决于当前要使用的库、框架支持哪个版本。因此一台电脑上可能需要同时安装Python2和Python3两个版本。本文主要讲述的是如何在centos7系统中存在python2系列的同时安装python3.6.2(目前python3系列的最新版本)

1.安装升级相应的软件包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

2.下载python 3.6 的源码包
wget http://mirrors.sohu.com/python/3.6.2/Python-3.6.2.tgz

3.安装python3.6
tar zxvf Python-3.6.2.tgz -C /opt/
cd /opt/Python-3.6.2/  
./configure --prefix=/usr/local/python3
make && make install  

若遇到编译问题:
zipimport.ZipImportError: can't decompress data; zlib not available  #make && make install
yum install zlib zlib-devel -y

4.配置python,配置python3  pip3 软链接,设置软连接:目的是让我们直接在任何地方输入python3命令都可以得到python解释器的运行。
更改/usr/bin/python链接:
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
mv /usr/bin/pip{,.backup}
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip   #python2-pip没有,就没有这个pip.
查看是否安装成功
python3 -V
pip3 -V

更改/usr/bin/python默认链接,实现升级:
/usr/bin/python --version
Python 2.7.5
mv /usr/bin/python{,.backup}
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python


5.查看当python的版本,出现版本信息即为正确安装
python3 --version


6.更改yum脚本的python依赖
yum localinstall mysql-5.7.12-171123111505.el7.centos.x86_64.rpm
  File "/usr/libexec/urlgrabber-ext-down", line 28
    except OSError, e:
                  ^
# ls /usr/bin/yum*
# ls yum*
yum yum-config-manager yum-debug-restore yum-groups-manager
yum-builddep yum-debug-dump yumdownloader
更改以上文件头为
#!/usr/bin/python 改为 #!/usr/bin/python2

用Sed 一行搞定,参考自[实践OK]经常用到之linux sed 批量替换字符串,及模糊替换和模糊拼接的例子。http://jackxiang.com/post/2324/:
/usr/bin/yum-groups-manager  #!/usr/bin/python -tt
/usr/bin/yumdownloader #直接python后面有一个空格
/usr/bin/yum-debug-restore #!/usr/bin/python -tt
/usr/bin/yum-debug-dump  #!/usr/bin/python -tt
/usr/bin/yum-config-manager #!/usr/bin/python -tt
/usr/bin/yum-builddep  #!/usr/bin/python -tt
/usr/bin/yum  #python后面无空格
势必要有两种替换:
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-builddep
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-config-manager
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-debug-dump
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-debug-restore
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yumdownloader
sed -i 's/#!\/usr\/bin\/python /#!\/usr\/bin\/python2.7 /' /usr/bin/yum-groups-manager
sed -i 's/#!\/usr\/bin\/python$/#!\/usr\/bin\/python2.7/' /usr/bin/yum
sed -i 's/#!\/usr\/bin\/python$/#!\/usr\/bin\/python2.7/' /usr/libexec/urlgrabber-ext-down

这个-tt的没有啥用,只是起到警告作用,完全在替换时不要:
-t     Issue a warning when a source file mixes tabs and spaces for indentation in a  way  that  makes  it
              depend on the worth of a tab expressed in spaces.  Issue an error when the option is given twice.
-t 当源文件以制作缩进的方式混合制表符和空格时发出警告
               取决于用空格表示的选项卡的价值。 当该选项被赋予两次时发出一个错误。

7.测试用Python的Pip3安装Python扩展:
rpm -qf /bin/pip
python2-pip-8.1.2-5.el7.noarch
/bin/pip --version
pip 9.0.1 from /usr/lib/python2.7/site-packages (python 2.7)

pip3 --version
pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)

pip3 install PyEmail
Collecting PyEmail
  Downloading https://files.pythonhosted.org/packages/ca/39/caf0436670b6fa9f072e322fab1a2b04d5631bdbdc8ea9857230aae02dd5/PyEmail-0.0.1.zip
Installing collected packages: PyEmail
  Running setup.py install for PyEmail ... done
Successfully installed PyEmail-0.0.1
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

pip3 install ipdb
Collecting ipdb
  Downloading https://files.pythonhosted.org/packages/80/fe/4564de08f174f3846364b3add8426d14cebee228f741c27e702b2877e85b/ipdb-0.11.tar.gz
Requirement already satisfied: setuptools in /usr/local/python3/lib/python3.6/site-packages (from ipdb)
Collecting ipython>=5.0.0 (from ipdb)
  Downloading https://files.pythonhosted.org/packages/b1/7f/91d50f28af3e3a24342561983a7857e399ce24093876e6970b986a0b6677/ipython-6.4.0-py3-none-any.whl (750kB)
    62% |████████████████████            | 471kB 54kB/s eta 0:00:06
好一会下载安装就能装上这个,但是提示:You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
pip install --upgrade pip

pip install ipdb   #再一次安装这个Python的调试扩展
python -m pdb mail.py

最后,这些脚本总结起来放一块就这些,方便后期再安装之用:


来自:https://blog.csdn.net/hobohero/article/details/54381475
来自:https://blog.csdn.net/wjqwinn/article/details/75633714
分页: 5/37 第一页 上页 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 下页 最后页 [ 显示模式: 摘要 | 列表 ]