erlang学习记录

文件句柄限制调整

echo "* soft nofile 204800" >> /etc/security/limits.conf

echo "* hard nofile 204800" >> /etc/security/limits.conf


echo "* soft nproc 204800" >> /etc/security/limits.conf

echo "* hard nproc 204800" >> /etc/security/limits.conf

echo fs.file-max = 6553560 >> /etc/sysctl.conf

查看文件句柄限制
sysctl -p

1. 日志level调整 
lager:set_loglevel(lager_console_backend, debug).

logger:get_primary_config().
logger:set_primary_config(level,debug).

2. 进程数量查看 
erlang:system_info(process_count).

3. 进程限制查看
erlang:system_info(process_limit).

4. 端口限制
erlang:system_info(port_limit).

5. 端口数量
erlang:system_info(port_count).

6. 内存占用
erlang:memory(). 

7. 查看哪些进程占用内存最高
spawn(fun() -> etop:start([{output, text}, {interval, 1},{lines, 20}, {sort, memory}]) end).

8. 查看占用内存最高的进程状态
erlang:process_info(pid(0,12571,0)).

erlang:process_info(self(), memory). 

9. 手动gc回收,希望问题可以解决
erlang:garbage_collect(pid(0,12571,0)).

10. 批量查看系统状态
SchedId      = erlang:system_info(scheduler_id),  
SchedNum     = erlang:system_info(schedulers),  
ProcCount    = erlang:system_info(process_count), 
ProcLimit    = erlang:system_info(process_limit), 
ProcMemUsed  = erlang:memory(processes_used),  
ProcMemAlloc = erlang:memory(processes),  
MemTot       = erlang:memory(total),  
io:format("abormal termination: " 
          "~n   Scheduler id:                         ~p" 
          "~n   Num scheduler:                        ~p" 
          "~n   Process count:                        ~p" 
          "~n   Process limit:                        ~p" 
          "~n   Memory used by erlang processes:      ~p" 
          "~n   Memory allocated by erlang processes: ~p" 
          "~n   The total amount of memory allocated: ~p" 
          "~n ",  
          [SchedId, SchedNum, ProcCount, ProcLimit,  
           ProcMemUsed, ProcMemAlloc, MemTot ]),   

ok.   


11. 开启observer
% werl -name bob@127.0.0.1 -setcookie emqttdsecretcookie

werl -name bob@127.0.0.1 -setcookie emqxsecretcookie
observer:start().


12.查看集群内的其他节点
nodes().

13.ping其他节点,pong代表连接成果, pang表失败
net_adm:ping('node@192.168.205.116').

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值