docker & cache

缘起:

dubbo-monitor容器swap使用率超过 20% ,而且在不断上升,为什么呢?

 

下面是容器dubbo-monitor在drop-caches前后的对比:

 

drop-cache后,容器的swap使用率没有变化

 

结论:

  1. docker stats 显示的内存使用是包含cache的
  2. 该容器的部分cache信息会被swap出内存
    1. cache和swap之间存在一些不默契;cache认为内存够多,还可以cache更多信息;swap机制为,经内存充裕,只要是不常被访问的内存数据,尽量swap出来; 于是乎,就形成了一个恶性循环,导致swap占用越来越大
    2. 解决办法: 定期drop一下cache
  3. 系统不会傻到把cache内容换出到swap中的,swap确实为进程使用的(虚拟)内存的一部分
  4. 一个允许最大使用2g内存的java进程,swap出来500m或1g不足为奇,如果给他的swap大小为2g的话,占用50%的swap都有可能

awk替换redis aof中db的方法

测试数据:

测试目标: 把 db 1 中的数据 导入到 db 10 里面去

awk脚本:

测试:

 

一般情况下,这样做事没问题的,特殊情况下会不好使(加入数据中包含极似协议的内容)

 

 

ngx.resp.get_headers()

 

syntax: headers = ngx.resp.get_headers(max_headers?, raw?)

context: set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua*, balancer_by_lua*

Returns a Lua table holding all the current response headers for the current request.

This function has the same signature as ngx.req.get_headers except getting response headers instead of request headers.

 

参考: https://github.com/openresty/lua-nginx-module#ngxrespget_headers

注意: 字段名都会转换成小写

saltstack pillar 维护

默认情况下,pillar信息是维护在文件中的,虽然方便,如果要自动化的话,就不太方便,如果能存到数据库会方便维护一些。

相关salt模块:https://docs.saltstack.com/en/latest/ref/pillar/all/index.html

将pillar信息存入mysql:

https://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.mysql.html

其实,还有现成的模块可以将pillar信息存储mongodb、ldap、redis等

https://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.pillar_ldap.html

 

https://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.redismod.html

 

https://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.postgres.html

https://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.git_pillar.html

持续构建之maven + Jenkins + Nexus

一般来讲,maven deploy时要部署到Nexus,需要在pom.xml 中添加如下类似的东东:

如此的话,该pom.xml 就不便于分享,还有人喜欢deploy到自己的Nexus呢;

其实,还可以在mvn deploy 时通过参数的方式来指定,如:

这样的话,不管snapshot还是release都会deploy到相同位置; 正确的姿势为分别设置snapshot和release的位置,如下:

参考:https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html

xfire 代理设置

xfire 可以通过如下方式设置代理:

需要注意的是,该代理配置并不作用于下载wsdl