Author: jpuyy

  • redis bitmaps

    setbit 最大 offset
    python 中 2**32 -1 = 4294967295

    setbit mykey 4294967295 1
  • ansible sed替换

    使用 shell 模块时,有时为了偷懒 lineinfile,用 sed 替换,涉及到使用 sed 自己变量时,会报错

    例:将最后一行注释掉

    ansible all -i 172.28.128.3, -m shell -a "sed -e '$s/^/#/g' /etc/hosts" -u vagrant -s
    172.28.128.3 | FAILED | rc=1 >>
    sed: -e expression #1, char 4: comments don't accept any addresses

    由于 $s 代表最后一行,需要转义一下

    ansible all -i 172.28.128.3, -m shell -a "sed -i '\$s/#//g' /etc/hosts" -u vagrant -s
  • 开车时听的歌list

    1. linda(张学友 粤语)

  • 对日志每分钟数量进行统计

    日志格式

    2016-12-16 07:15:29.055
    

    统计每分钟的量

    uniq -w16 -c access.log
    
  • 客户端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