Blog

  • 客户端time_wait过多,调整服务端tcp_timestamps

    客户端发送大量 http 请求到服务端

    在客户端已经设置了

    net.ipv4.tcp_tw_recycle = 1
    net.ipv4.tcp_tw_reuse = 1

    发现客户端 time_wait 还是过多,后来在服务端设置

    sysctl -w net.ipv4.tcp_timestamps=1
  • ansible lineinfile 改文件某一行

    添加

    ansible all -i jpuyy-com-lan -m lineinfile -a "dest=/etc/hosts line='115.239.28.20 api.jpuyy.com'" -s

    删除

    ansible all -i jpuyy-com-lan -m lineinfile -a "dest=/etc/hosts line='115.239.28.20 api.jpuyy.com' state=absent" -s 

    更改某一行

    ansible all -i jpuyy-com-lan -m lineinfile -a "dest=/etc/env.yaml line='idc: sh' regexp='idc: qcloud'" -s
  • curl 测试时设置超时时间

    使用curl时,有两个超时时间:一个是连接超时时间,另一个是数据传输的最大允许时间。

    连接阶段超时时间用 –connect-timeout 参数
    整个过程的最大允许时间用 -m 参数

    例如:

    curl --connect-timeout 10 -m 20 http://jpuyy.com/

    连接超时的话,出错提示形如:

    curl: (28) connect() timed out!

    数据传输的最大允许时间超时的话,出错提示形如:

    curl: (28) Operation timed out after 2000 milliseconds with 0 bytes received

  • 打乱文件的行顺序

    命令

    shuf

    参考:http://x-wei.github.io/%E6%89%93%E4%B9%B1%E6%96%87%E6%9C%AC%E7%9A%84%E8%A1%8C.html

  • python smtplib 发邮件

    http://www.mkyong.com/python/how-do-send-email-in-python-via-smtplib/

  • centos7 python 升级

    脚本

    #!/bin/bash
    
    yum install -y gcc make
    cd /usr/src
    curl -O https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz
    tar xzf Python-2.7.12.tgz
    cd Python-2.7.12
    ./configure
    make altinstall
    

    CentOS 7 安装 python 3.6.5

    sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm
    sudo yum install -y python36u python36u-libs python36u-devel python36u-pip
    

    CentOS 7.7, Python 3 is available in the base package repository

    # cat /etc/redhat-release 
    CentOS Linux release 7.7.1908 (Core)
    # yum install -y python3 python3-devel