Distributed nodes
Known nodes
A remote node Y has to be known to node X if there exist any pids, ports, references, or funs (Erlang data types) from Y on X, or if X and Y are connected. The maximum number of remote nodes simultaneously/ever known to a node is limited by the maximum number of atoms available for node names. All data concerning remote nodes, except for the node name atom, are garbage-collected.
Connected nodes
The maximum number of simultaneously connected nodes is limited by either the maximum number of simultaneously known remote nodes, the maximum number of (Erlang) ports available, or the maximum number of sockets available.
semantic error: process return probes not available with inode-based uprobes
Pass 2: analysis failed. Try again with another ‘–vp 01’ option.
You have new mail in /var/spool/mail/root
何解????
configure 的时候如下报错
crypto : No usable OpenSSL found
jinterface : No Java compiler found
odbc : ODBC library – header check failed
ssh : No usable OpenSSL found
ssl : No usable OpenSSL found
Program terminated with signal 11, Segmentation fault.
#0 0x000000000050dcb4 in ?? ()
“/data/core_files/core-beam.smp-37368-1463090605” is a core file.
Please specify an executable to debug.
(gdb) file /data/app/erlang/lib/erlang/erts-5.10.4/bin/beam.smp
Reading symbols from /data/app/erlang/lib/erlang/erts-5.10.4/bin/beam.smp…(no debugging symbols found)…done.
Missing separate debuginfos, use: debuginfo-install dw_erlang-R16B03-1.x86_64
(gdb) bt
#0 0x000000000050dcb4 in port_get_data_1 ()
#1 0x000000000053d2ad in process_main ()
#2 0x000000000049dc9b in ?? ()
#3 0x00000000005bda76 in ?? ()
#4 0x0000003d2b0079d1 in ?? ()
#5 0x00007fdd42a7e700 in ?? ()
#6 0x0000000000000000 in ?? ()
你好,我看了您的帖子http://blog.yufeng.info/archives/1096,我用了相同的命令smartctl -a -d megaraid,0 /dev/sda获取到的信息差很多,特此请教一下。
smartctl版本是5.40
|># smartctl -a -d megaraid,0 /dev/sda
smartctl 5.40 2010-07-12 r3124 [x86_64-unknown-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net
Device: SEAGATE ST3600057SS Version: ES66
Serial number: 6SL5PWEC
Device type: disk
Transport protocol: SAS
Local Time is: Mon Apr 10 11:15:23 2017 SGT
Device supports SMART and is Enabled
Temperature Warning Disabled or Not Supported
SMART Health Status: OK
Current Drive Temperature: 44 C
Drive Trip Temperature: 68 C
Elements in grown defect list: 0
Vendor (Seagate) cache information
Blocks sent to initiator = 1075511673
Blocks received from initiator = 1015742411
Blocks read from cache and sent to initiator = 20911148
Number of read and write commands whose size segment size = 0
Vendor (Seagate/Hitachi) factory information
number of hours powered up = 27904.30
number of minutes until next internal SMART test = 60
你的理解是对的
[Reply]
sunface Reply:
March 30th, 2014 at 1:48 pm
谢谢霸爷,我非常喜欢erlang,您也是我的偶像,希望以后可以像您一样轻松驾驭这门语言;)
[Reply]
霸爷,您好!请教一个最近在用rebar重构项目遇到的问题:
在开发过程中,我们总会遇到修改一点代码然后要运行调试的情况,对于这种情况我们每次都要rebar generate一下然后运行调试?
[Reply]
Yu Feng Reply:
March 27th, 2014 at 8:34 pm
写个脚本自动做就好了,运行调试最好是想清楚了一把做好。不要把debug当成常态。
[Reply]
老大,看来你这篇帖子http://blog.yufeng.info/archives/2169,你提到每个节点有个动态端口,这个动态端口的规则是什么呢?
[Reply]
Yu Feng Reply:
April 18th, 2014 at 6:33 pm
http://www.erlang.org/doc/man/kernel_app.html
{inet_dist_listen_min, First}
See below.
{inet_dist_listen_max, Last}
Define the First..Last port range for the listener socket of a distributed Erlang node.
[Reply]
Yu Feng Reply:
April 18th, 2014 at 6:34 pm
{kernel,
[
{check_ip, false},
{error_logger, silent},
{inet_dist_listen_min, 4096},
{inet_dist_listen_max, 8192},
{inet_default_listen_options, [{nodelay,true}]},
{inet_default_connect_options, [{nodelay,true}]}
]},
[Reply]
看源代码是发现点问题搞不懂,麻烦老大给我看看,求教
问题帖子
http://bbs.erlang-cn.com/forum.php?mod=viewthread&tid=55&extra=
[Reply]
就是 Erlang 进程在处理消息的时候, 如果有一个消息不匹配这个进程里面的任何规则, 那么这个消息会一直保留在这个进程的message queue里面. 为什么既然这条消息不匹配任何规则, erlang 不直接把这个消息丢掉呢? 是为了热加载么?
[Reply]
Yu Feng Reply:
April 24th, 2014 at 11:05 am
erlang的消息匹配是可以再附带其他guard(条件)的,也就是说这次消息匹配不成功,不等于下一次不成功。
[Reply]
baotiao Reply:
April 30th, 2014 at 12:37 pm
比如我们一个模块继承Gen_server, 那么这个Gen_server的匹配条件就是已经定下来了,
我能想到的就是热加载的时候这个匹配条件才有可能改变.
难道是这个匹配条件是一个变量?
会随着运行状态的改变么?
[Reply]
Yu Feng Reply:
April 30th, 2014 at 1:25 pm
是可以变量的。
老大 qq是多少
[Reply]
Yu Feng Reply:
May 8th, 2014 at 3:48 pm
526275,很少用。
[Reply]
博主您好,请教一个Erlang的问题。
假设这样一个应用环境,在一个P2P的分布式系统中,每个节点会在本地mnesia数据库中记录某个Key对应的对象所在的节点(即Key -> ‘node@host’)。由于节点是用原子来表示的,而Erlang系统对于原子的数目是有限制的,是否意味着,数据库中存储的记录也是有上限的?原子的数量有上限,是否意味着,Erlang节点,可以通信的Eralng节点的数目也是有上限的?
[Reply]
Yu Feng Reply:
May 11th, 2014 at 12:18 am
思路是错的.
[Reply]
阿涵 Reply:
May 11th, 2014 at 2:14 pm
我看了一下CouchDB的源代码,里面好像没有直接用到Node,貌似都用的是Pid来通信,官方文档中说Pid中包含有Node的信息,并且 Pid的会消耗node table,请问如果只使用Pid在不同节点上通信的话,会消耗atom table吗?
如果能多说点细节就好了,万分感激。
[Reply]
Yu Feng Reply:
May 13th, 2014 at 10:57 am
当然消耗呀。
Distributed nodes
Known nodes
A remote node Y has to be known to node X if there exist any pids, ports, references, or funs (Erlang data types) from Y on X, or if X and Y are connected. The maximum number of remote nodes simultaneously/ever known to a node is limited by the maximum number of atoms available for node names. All data concerning remote nodes, except for the node name atom, are garbage-collected.
Connected nodes
The maximum number of simultaneously connected nodes is limited by either the maximum number of simultaneously known remote nodes, the maximum number of (Erlang) ports available, or the maximum number of sockets available.
我想我找到答案了。
请问博主有解决方案吗????atom table可以人为删除吗??或者每次新建atom(和别的结点通信)的时候,如果判断当前的atom数量快超过限制了,就重启一下erl进程?
[Reply]
再问博主,Erlang epmd 是一个Erlang进程吗?它是否也有一个atom table呢?
[Reply]
博主是大牛啊!赞个 多看看你的文章学习学习!
[Reply]
hejavac Reply:
September 18th, 2014 at 11:28 am
+1
[Reply]
请问有没有关于db kernel dev的qq群?自己找了几个都不是很靠谱。
[Reply]
霸爷,来向您求助了。我把erlang从R16升级到R17后,出现了各种编码的问题。。之前项目的中文字符编码貌似都有问题了,请问这个应该怎么处理?编码集转为utf8-nobom模式吗?
[Reply]
sunface Reply:
June 18th, 2014 at 4:01 pm
我仔细测试了下, file:write_file(FileName,Content, [write, binary, {encoding, utf8}])这个函数在r16底下把中文字符写入文件中的时候是每个中文字符3个字节,可是在R17,就变成了每个中文字符转变为一个很大的数,20000+,所以后面的调用和读取就全部是错的了,请问霸爷,这是啥问题?
[Reply]
hi,霸爷,不知道您对编译方向是否了解呢? 有没有好的资料或人 可以推荐呢 期待您的回复 非常感谢
[Reply]
hi,yufeng ,
能否和你做一个友链?www.chinahadoop.cn
[Reply]
hello,能不能组织一个erlang文档的翻译小组?
我愿意加入,虽然资历浅,邮箱:liuweiccy@qq.com
[Reply]
霸爷,最近要使用rabbitmq,然后再使用erlang client的时候,自己要写很多处理重连,根据配置文件自动建立连接的代码,想咨询下霸爷,是否有已经写好的,比较好的开源代码可以使用呀,不想自己重新造轮子了。
我自己找到的有gen_bunny这个项目(https://github.com/noblesamurai/gen_bunny),不过他的目标是:Especially for simple publisher and consumer applications.
之后我想把这个application加到ejabberd里面,让他去读取消息,发送给ejabberd的客户端,不知道霸爷有没有好的建议,之前我没有做过类似的东西,第一次使用rabbitmq和ejabberd
[Reply]
Yu Feng Reply:
September 27th, 2014 at 3:54 am
用erlang的客户端挺好的,何必再写一个。要抑制自己的冲动,代价非常大。
[Reply]
liufan Reply:
September 28th, 2014 at 8:11 am
gen_bunny也是在erlang client的基础上去做了一个封装,然后去处理断线重连等操作,它启动了一个connections_mon的gen_server进程来保存每个连接的状态和信息,处理每个连接的重连等,但是有些地方是写死了,比如说一个connection只有一个channel等,觉得不是很好,然后自己以前没有用过这个erlang client,所以想看看有没有已经写好的例子参考一下。
[Reply]
erlang的一个主要特性就是热更新,我是erlang初学者,在学习过程中发现这么一个问题:
如果有a,b两个模块需要热更新,但是a,b模块相互依赖,要求a,b的老版本可以相互调用,新版本可以相互调用,但是不能进行新老版本之间的相互调用.
怎样才能实现这个要求.
[Reply]
霸爷,你好,我最近在看热更新想咨询一个问题:在热更新的时候会有old和current两个版本,怎么才能禁止模块间old和current版本之间的相互调用.
[Reply]
如果ets中,先读,判断符合条件后赋值后写,但是本次读和写之前又插入了另外一个写,这个怎么办?能把“读和写”这段时间都锁住么。
[Reply]
霸爷,请问你最近在翻译 learn you some Erlang for great good 嘛,表示很期待。
[Reply]
当我做测试的时候发现在gen_server的handle_info中发消息比在其他地方慢 这是为什么?
这是我的测试代码:
-module (tgen_server2).
-behaviour (gen_server).
% APIs
-export([start_link/0, t/0, worker/0]).
% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
-record (state, {cursor :: integer(),
pool_size :: integer()}).
%% ===================================================================
%% APIs
%% ===================================================================
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
t() ->
io:format(“start:~p~n”, [os:timestamp()]),
t(100000).
t(N) when N > 0 ->
?MODULE ! t,
t(N – 1);
t(0) ->
?MODULE ! t1,
io:format(“finish send:~p~n”, [os:timestamp()]),
ok.
worker() ->
receive
_ ->
worker()
end.
%% ===================================================================
%% gen_server callbacks
%% ===================================================================
init([]) ->
ets:new(session, [named_table]),
loop(10),
{ok, #state{cursor = 1, pool_size = 10}}.
handle_call(_Request, _From, State) ->
{reply, nomatch, State}.
handle_cast(_Msg, State) ->
{noreply, State}.
% {update, insert, {UserId, Pid}} | {update, delete, UserId}
handle_info(t, State) ->
worker_1 ! t,
{noreply, State};
handle_info(_Info, State) ->
io:format(“finish:~p~n”, [os:timestamp()]),
{noreply, State}.
terminate(_Reason, _State) -> ok.
code_change(_OldVer, State, _Extra) -> {ok, State}.
%% ===================================================================
%% Internal functions
%% ===================================================================
loop(N) when N > 0 ->
Pid = spawn(fun ?MODULE:worker/0),
erlang:register(worker_name(N), Pid),
loop(N – 1);
loop(0) ->
ok.
worker_name(Index) ->
IndexStr = erlang:integer_to_list(Index),
erlang:list_to_atom(“worker_” ++ IndexStr).
=============================================================================
当我运行tgen_server2:start_link().
tgen_server2:t().后
得到的结果如下:
start:{1439,521183,104974}
finish send:{1439,521183,255421}
ok
finish:{1439,521188,940656}
===================================================
在handle_info()中发10万个消息结果需要5秒多,反而在t()中发消息不到1秒 这是为什么呢?
[Reply]
问一下,
[root@localhost linux-3.5]# uname -a
Linux localhost.localdomain 3.5.0 #2 SMP Tue Sep 15 09:51:37 PDT 2015 x86_64 x86_64 x86_64 GNU/Linux
我的内核从redhat 5.3 2.6.18 手动源码装了一个3.5内核 ,源码安装方试,遇到一个问题,就是systemtap 用起来都正常,唯一不正常就是return 探针没有作用
[root@localhost linux-3.5]# stap -e ‘probe process(“a.out”).function(“*”).return { printf(“%s”,”123″)}’
semantic error: while resolving probe point: identifier ‘process’ at :1:7
source: probe process(“a.out”).function(“*”).return { printf(“%s”,”123″)}
^
semantic error: process return probes not available with inode-based uprobes
Pass 2: analysis failed. Try again with another ‘–vp 01’ option.
You have new mail in /var/spool/mail/root
何解????
[Reply]
没怎么用过 mac,在 macpro 上装 erlang 的时候遇到问题:
configure 的时候如下报错
crypto : No usable OpenSSL found
jinterface : No Java compiler found
odbc : ODBC library – header check failed
ssh : No usable OpenSSL found
ssl : No usable OpenSSL found
[Reply]
hgx Reply:
October 21st, 2015 at 1:03 pm
问题解决了,重新安装 openssl 就可以了
[Reply]
我是用mnesia的fragment的时候,遇到了这个错误:
(test1@localhost)19> mnesia:create_table(test, [{record_name, test}, {attributes, [sid, usr, us, priority, info, online_flag]}, {disc_copies, [test1@localhost, test2@localhost, test3@localhost]}, {frag_properties, [{n_fragments, 3},{n_ram_copies, 3}, {n_disc_copies, 2}, {node_pool, [test2@localhost, test1@localhost, test3@localhost]}]}]).
{aborted,{combine_error,test_frag3,
“Too few nodes in node_pool”}}
我想请教下,这三个值需要满足什么样的关系吗?
{n_ram_copies, 3},
{n_disc_copies, 2},
{node_pool, [test2@localhost, test1@localhost, test3@localhost]}
是上面两个的值都要小于node_pool的个数吗?
[Reply]
monkboy Reply:
November 11th, 2015 at 6:42 pm
我在mnesia_frag找到原因了:
651 set_frag_nodes(NR, ND, NDO, Cs, [Head | Tail], Acc) when NR > 0 ->
652 Pos = #cstruct.ram_copies,
653 {Cs2, Head2} = set_frag_node(Cs, Pos, Head),
654 set_frag_nodes(NR – 1, ND, NDO, Cs2, Tail, [Head2 | Acc]);
655 set_frag_nodes(NR, ND, NDO, Cs, [Head | Tail], Acc) when ND > 0 ->
656 Pos = #cstruct.disc_copies,
657 {Cs2, Head2} = set_frag_node(Cs, Pos, Head),
658 set_frag_nodes(NR, ND – 1, NDO, Cs2, Tail, [Head2 | Acc]);
659 set_frag_nodes(NR, ND, NDO, Cs, [Head | Tail], Acc) when NDO > 0 ->
660 Pos = #cstruct.disc_only_copies,
661 {Cs2, Head2} = set_frag_node(Cs, Pos, Head),
662 set_frag_nodes(NR, ND, NDO – 1, Cs2, Tail, [Head2 | Acc]);
663 set_frag_nodes(0, 0, 0, Cs, RestDist, ModDist) ->
664 {Cs, ModDist, RestDist};
665 set_frag_nodes(_, _, _, Cs, [], _) ->
666 mnesia:abort({combine_error, Cs#cstruct.name, “Too few nodes in node_pool”}).
就是NR, ND, NDO的和要小于等于node_pool的长度,一直关注霸爷的博客中。
[Reply]
monkboy Reply:
November 11th, 2015 at 6:44 pm
通过霸爷介绍的dbg跟踪来理解源码还是感觉很好用
(mnesia_nodes1@localhost)3> dbg:tracer().
{ok,}
(mnesia_nodes1@localhost)4> dbg:p(all, [call]).
{ok,[{matched,mnesia_nodes1@localhost,105}]}
(mnesia_nodes1@localhost)6> dbg:tpl(mnesia_frag, set_frag_nodes, [{‘_’,[],[{return_trace}]}]).
{ok,[{matched,mnesia_nodes1@localhost,1},{saved,1}]}
[Reply]
霸爷,请教个问题,我们服务器有个 gen_server 行为模式的模块假设叫做 team。当在远程节点使用rpc:call(Node, code, load_binary, ….)方式热更新team代码后,我们原本期望会自动执行team:code_change ,但实际上并没有,怎样才能在热更新后执行code_change?code_change是什么时候执行
[Reply]
霸爷,向您反映一个淘宝平台的漏洞问题,即,卖家可以一次延长收货时间30天,也可以延长收货时间-30,请看清楚,是负30天,从而导致在默认快到收货期限前,延长收货时间,而后,再以延长负数来使系统自动确认收货。咨询客服,给的答案是不能延长那么长时间,也不能取消,我的单号是:1445584263367899,请查看相关日志信息,尽快解决此漏洞,谢谢!
[Reply]
有幸在网上拜读了你对erlang的一些博客, 感觉你对erlang认识比较深。
http://blog.yufeng.info/
我现在遇到个内存池使用的问题,能不能给我建议呢。
其实问题和这里的描述一样,
http://erlang.org/pipermail/erlang-questions/2014-April/078896.html
我的ejabberd系统里面分配了大量的binary的内存池
,但是使用率很低,只有5%左右。 我现在想通过+MBacul 0 把内存池这个功能禁掉。
我想请问下这种做法对性能的影响有多大呢? 速度下架多少个百分点。
我现在的系统4个ejabberd服务器集群, 每个上面有30000多个聊天室, 5w左右进程, 连接数一直保持在5000左右。
禁掉内存池,会不会对系统性能造成很大影响呢。
谢谢!
[Reply]
霸爷,请教个问题,再给进程发送消息时,erlang语法的 ! 与 erlang:send/2的区别是什么。
[Reply]
请教一下,sockets 的options里的 nodelay 和 delay_send,我看的文档觉得是前者是想实时,后者想省io么。这两个option起作用的层面分别在哪里呢?谢谢。
[Reply]
Program terminated with signal 11, Segmentation fault.
#0 0x000000000050dcb4 in ?? ()
“/data/core_files/core-beam.smp-37368-1463090605” is a core file.
Please specify an executable to debug.
(gdb) file /data/app/erlang/lib/erlang/erts-5.10.4/bin/beam.smp
Reading symbols from /data/app/erlang/lib/erlang/erts-5.10.4/bin/beam.smp…(no debugging symbols found)…done.
Missing separate debuginfos, use: debuginfo-install dw_erlang-R16B03-1.x86_64
(gdb) bt
#0 0x000000000050dcb4 in port_get_data_1 ()
#1 0x000000000053d2ad in process_main ()
#2 0x000000000049dc9b in ?? ()
#3 0x00000000005bda76 in ?? ()
#4 0x0000003d2b0079d1 in ?? ()
#5 0x00007fdd42a7e700 in ?? ()
#6 0x0000000000000000 in ?? ()
霸爷 请教一下 现在经常有些节点莫名奇妙的挂掉 没有额外的C代码 能提示下可能的地方么 信息实在太少
[Reply]
最近碰到一些问题
使用 prim_inet:async_receive 经常会收到 {inet_async, Socket, _, error,closed}这样的消息, 但是这时候客户端并没有执行关闭操作,并且与服务器还是正常连接状态,还能发送接收请求。。
请问这个 error,closed消息是怎么被发送上来的。。
[Reply]
你好,我看了您的帖子http://blog.yufeng.info/archives/1096,我用了相同的命令smartctl -a -d megaraid,0 /dev/sda获取到的信息差很多,特此请教一下。
smartctl版本是5.40
|># smartctl -a -d megaraid,0 /dev/sda
smartctl 5.40 2010-07-12 r3124 [x86_64-unknown-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net
Device: SEAGATE ST3600057SS Version: ES66
Serial number: 6SL5PWEC
Device type: disk
Transport protocol: SAS
Local Time is: Mon Apr 10 11:15:23 2017 SGT
Device supports SMART and is Enabled
Temperature Warning Disabled or Not Supported
SMART Health Status: OK
Current Drive Temperature: 44 C
Drive Trip Temperature: 68 C
Elements in grown defect list: 0
Vendor (Seagate) cache information
Blocks sent to initiator = 1075511673
Blocks received from initiator = 1015742411
Blocks read from cache and sent to initiator = 20911148
Number of read and write commands whose size segment size = 0
Vendor (Seagate/Hitachi) factory information
number of hours powered up = 27904.30
number of minutes until next internal SMART test = 60
Error counter log:
Errors Corrected by Total Correction Gigabytes Total
ECC rereads/ errors algorithm processed uncorrected
fast | delayed rewrites corrected invocations [10^9 bytes] errors
read: 48051332 0 0 48051332 48051332 1944.053 0
write: 0 0 0 0 0 11591.561 0
verify: 372058007 0 0 372058007 372058007 34095.924 0
Non-medium error count: 12
SMART Self-test log
Num Test Status segment LifeTime LBA_first_err [SK ASC ASQ]
Description number (hours)
# 1 Background short Completed 32 11901 – [- – -]
Long (extended) Self Test duration: 6400 seconds [106.7 minutes]
[Reply]