简体   繁体   中英

Erlang: How can I remove a node from other nodes' nodes()?

I want to simulate the behavior of erl -sname example -hidden but dynamically. How can I drop a node out of visibility in a cluster?

See the comments by @mwt at @Yasir Arsanukaev for additional clarification of what I'm trying to do.

Try erlang:disconnect_node/1 :

(bar@dt)1> nodes().
[]
(bar@dt)2> net_adm:ping('foo@dt').          
pong
(bar@dt)3> nodes().               
[foo@dt]
(bar@dt)4> erlang:disconnect_node('foo@dt').
true
(bar@dt)5> nodes().                         
[]

Or if you want a node to remove itself from other nodes' nodes() :

(bar@dt)1> nodes().
[foo@dt]
(bar@dt)2> rpc:eval_everywhere(erlang, disconnect_node, [node()]).
abcast
(bar@dt)3> nodes().
[]

If the node was started with key -hidden :

(bar@dt)1> nodes(hidden).
[foo@dt]
(bar@dt)2> rpc:eval_everywhere(nodes(hidden), erlang, disconnect_node, [node()]).
abcast
(bar@dt)3> nodes(hidden).
[]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM