ejabberd - Comments for "single domain served by a cluster " https://www.ejabberd.im/node/3379 en ok ths zit https://www.ejabberd.im/node/3379#comment-55620 <p>thanks for your help</p> Wed, 21 Apr 2010 16:15:01 +0000 Alagarvaithiyanathan comment 55620 at https://www.ejabberd.im I don't know. You should be https://www.ejabberd.im/node/3379#comment-55618 <p>I don't know. You should be able to run the "erl dbinfo" command to get the status of the running/stopped nodes, but you'll have to experiment to find out exactly how to do that on windows.</p> <p>The perl code is just used to parse the output of the "erl dbinfo" command, and then probe to see if the other ejabberd node is running, and then stop/restart the node. I just used perl because it is my language of choice. You could install perl on windows. Or you could use another language, or even erlang.</p> <p>Ultimately, this capability should be built into ejabberd directly. However, I am not a savvy erlang/ejabberd developer.</p> Wed, 21 Apr 2010 14:18:08 +0000 zjt comment 55618 at https://www.ejabberd.im sorry how to run this script in windows https://www.ejabberd.im/node/3379#comment-55616 <p>hi zjt,</p> <p> how can i run this script in my windows XP system.I am running my two clustered ejabberd node in XP system.pls tell me the steps to run the command in my system.</p> <p>i don't know about perl script.</p> <p>pls help me.</p> <p>regards,</p> <p>alagar</p> Wed, 21 Apr 2010 06:04:28 +0000 Alagarvaithiyanathan comment 55616 at https://www.ejabberd.im Basically, here is a command https://www.ejabberd.im/node/3379#comment-55607 <p>Basically, here is a command you can use to determine if the current node believes the other node is stopped.</p> <div class="codeblock"><code>echo &quot;rpc:call($ERLANG_NODE, mnesia, info, []).&quot; | exec erl -name dbinfo_$THIS_HOSTNAME</code></div> <p>and you can parse that output with this perl code</p> <div class="codeblock"><code>&nbsp; for ( @mnesia_info ) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( m/stopped db nodes\s+=\s+\[(.*?)\]/ ) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my @stopped_nodes = ();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $_ = $1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while ( /&#039;(.*?)&#039;/g ) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push @stopped_nodes, $1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return @stopped_nodes;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp; }<br />&nbsp; return $this_node;&nbsp; # this node must be down</code></div> <p>Here is some perl code that verifies that the other node is listening on port 5222, which is a good indication that it is still serving client traffic.</p> <div class="codeblock"><code>&nbsp; my $available = 0;<br />&nbsp; eval {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alarm $commandtimeout;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $sock = new IO::Socket::INET (<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PeerAddr =&gt; $master_server,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PeerPort =&gt; 5222,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Proto&nbsp;&nbsp;&nbsp; =&gt; &#039;tcp&#039;,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) or die &quot;could not connect: $!&quot;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $available = 1 if $sock;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; close $sock;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alarm 0;<br />&nbsp; };<br />&nbsp; if ( $@ ) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; syslog LOG_ERR, &quot;unable to connect to master node: $@&quot;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alarm 0;<br />&nbsp; }<br />&nbsp; return $available;</code></div> <p>At that point, you can stop or restart the node as you see fit.</p> Tue, 20 Apr 2010 16:08:51 +0000 zjt comment 55607 at https://www.ejabberd.im pls show the script https://www.ejabberd.im/node/3379#comment-55606 <p>zjt wrote:</p> <p>Submitted by zjt on Tue, 2009-02-24 00:53.</p> <p>I wrote a script that monitors mnesia:info() and restarts one of the nodes if they disconnect from each other.</p> <p>pls show the script we are also have the same problem.I am not able to reconnect the node when the node disconnect from the network.</p> <p>pls help me</p> <p>regards </p> <p>alagar</p> Tue, 20 Apr 2010 15:41:10 +0000 Alagarvaithiyanathan comment 55606 at https://www.ejabberd.im network issues can cause ejabberd nodes to disconnect https://www.ejabberd.im/node/3379#comment-54034 <p>I've seen cases where network issues can cause ejabberd nodes to disconnect from each other. So, if this is happening a lot to you, then perhaps you have a poor network connection between the nodes.</p> <p>I wrote a script that monitors mnesia:info() and restarts one of the nodes if they disconnect from each other.</p> Mon, 23 Feb 2009 19:23:27 +0000 zjt comment 54034 at https://www.ejabberd.im erlang nodes disconnect themselves in cluster https://www.ejabberd.im/node/3379#comment-54011 <p>I have replicated all the tables of the Mnesia DB to test.<br /> But the second erlang node still disconnects itself (seen in the web admin interface of the master node).<br /> (for the two servers : ejabberd is always starting, &amp; mnesia:info(). says that the other db node is stopped)<br /> Best case : the cluster worked one day. </p> <p>Any idea of what could be wrong in my configuration?</p> Wed, 11 Feb 2009 08:24:47 +0000 badarg comment 54011 at https://www.ejabberd.im Replicate tables so nodes can work idependently https://www.ejabberd.im/node/3379#comment-54002 <div class="quote-msg"> <div class="quote-author"><em>badarg</em> wrote:</div> <p>I didn't replicate any Mnesia DB.</p> <p>The problem now is that the cluster falls down. The second node disconnects itself.</p></div> <p>The Mnesia database in the second node gets all the information continuosly from the first node: every user login, every roster, offline messages, vcards... When the first node is down, the second cannot access that information.</p> <div class="quote-msg"> <div class="quote-author"><em>badarg</em> wrote:</div> <p>Should I replicate some Mnesia DB?</p></div> <p>Yes, you should tell the Mnesia database that runs in the second node to replicate the tables that you consider important from first node. Probably the interesting ones are: passwd, roster, offline_msg, last_activity, private_storage, vcard, privacy.</p> <div class="quote-msg"> <div class="quote-author"><em>badarg</em> wrote:</div> <p>Must I change some lines in my configuration of ejabberd.cfg?</p></div> <p>No, check the ejabberd Guide, it explains the method to tell Mnesia database of second node to replicate those tables.</p> Sun, 08 Feb 2009 22:18:48 +0000 mfoss comment 54002 at https://www.ejabberd.im cluster fall over https://www.ejabberd.im/node/3379#comment-53997 <p>Thanks for your explanations. It's clearly now for me.</p> <p>I have used a load-balancer to test an ejabberd cluster.<br /> I started with a basic configuration with internal authentification of ejabberd on my two servers : server1 &amp; server2.<br /> My erlang nodes are : ejabberd1@server1 &amp; ejabberd2@server2.<br /> My domain ejabberd hostname : mydomain.com</p> <p>To do that, in the both servers: I've changed the last line of ejabberdctl.cfg and written the erlang node.<br /> I've written the erlang node and host in the ejabberdctl sbin file.<br /> I've changed these lines in the ejabberd.cfg file :<br /> <code><br /> {hosts, ["mydomain.com"]}.<br /> {host_config, "mydomain.com", [{auth_method, [internal, anonymous]}]}.<br /> {acl, admin, {user, "test", "mydomain.com"}}.<br /> {host, "muc.mydomain.com"},</code></p> <p><code></code></p> <p>Then I followed the process to cluster the second node, and I didn't replicate any Mnesia DB.<br /> The cluster worked. I could speak between two jabber clients. And when a node broke, the jabber clients have changed to the other node. I could see in the web admin, the two erlang nodes and the virtual ejabberd server mydomain.com. </p> <p>The problem now is that the cluster falls down. The second node disconnects itself.<br /> Should I replicate some Mnesia DB?<br /> Must I change some lines in my configuration of ejabberd.cfg?</p> Fri, 06 Feb 2009 15:21:32 +0000 badarg comment 53997 at https://www.ejabberd.im machine hostname != erlang node name != ejabberd hosted names https://www.ejabberd.im/node/3379#comment-53991 <p>Let's see if I understood correctly your plan and how to solve it.</p> <p>The 'machine hostname' and the 'Jabber host name' can be completely different if you want.</p> <p>You have two ejabberd nodes, one installed in a machine called "first", and other in a machine called "second".<br /> The name of the Erlang node of ejabberd in first machine is called "ejabbed1@first", and in the second machine it's called "ejabberd2@second".</p> <p>You configured Mnesia in those nodes to work as a cluster.</p> <p>You want that both nodes in this cluster serve the Jabber domain "example.com".<br /> In each machine you have an ejabberd.cfg. In both files you put the same:</p> <pre> {hosts, ["example.com"]}. </pre><p> When a Jabber client tries to connect to the Jabber server "example.com", the client will try to connect to the machine that DNS points to. So, if your DNS says that "example.com" is hosted in "first", the Jabber client will connect to "first" and login in ejabberd.</p> <p>The user can configure the Jabber client to connect to "second", and login to domain "example.com". For example in Psi's Account Properties:</p> <ul> <li>Account -&gt; JabberID: <noindex><a href="mailto:bob@example.com" rel="nofollow" >bob@example.com</a></noindex> </li><li>Connection -&gt; Manually Specify Server Host/Port, Host: "second" </li></ul> <p>If you want that clients randomly connect to first or second when they try to login in example.com, you need to configure your DNS server. This is not a topic of ejabberd. The ejabberd in each of your machines will try to serve the clients that it gets. It is a problem of the clients (or your DNS server) to direct the clients to either the machine first or second.</p> Wed, 04 Feb 2009 15:14:17 +0000 mfoss comment 53991 at https://www.ejabberd.im