Nginx openfire xmpp cluster installation configuration

Source: Internet
Author: User
Tags mysql database nginx server hazelcast

Openfire is developed in Java and the open-source RTC server is based on the XMPP (Jabber) protocol. Openfire is easy to install and use, and can be managed on the Web. Openfire clusters are easy to configure, but there is no connection pool. We can use nginx to make up for this disadvantage.

First. Server description


192.168.10.235 // openfire
192.168.10.203 // openfire
192.168.10.208 // openfire
 
192.168.10.208 // nginx connection pool, unified web management address
The three openfire servers are installed on the nginx server 208 and support the tct and http protocols. Whether it is http or xmpp, the unified portal is 208. Note that the tcp reverse proxy of nginx cannot be the same as the default port of xmpp. Otherwise, nginx and openfire of 208 cannot be the same. It doesn't matter if it's not the same machine.
Second. openfire installation and configuration

1. Download openfire


Http://www.igniterealtime.org/downloads/index.jsp#openfire // download rpm Package for easy installation
2. Start openfire and access http: // IP: 9090 in the browser to set up the server. The three servers can connect to a mysql database (or multiple servers can be used as the master-slave mysql database, is not the focus of this article ).
Openfire installation is not detailed, and it is relatively simple. If not the same mysql database at the beginning, you can modify the configuration file vim/opt/openfire/conf/openfire. xml.

Third. openfire cluster configuration

1. openfire hazelcast cluster plug-in. I use openfire 3.9.3. This plug-in is available by default in the/openfire installation directory/plugins/directory. If no, download hazelcast. jar and put it in this directory. Then install the plug-in the web management background.
2. Configure the hazelcast cluster plug-in


# Vim/opt/openfire/plugins/hazelcast/classes/hazelcast-cache-config.xml
 
<Join>
<Multicast enabled = "false"> // change true to false.
<Multicast-group> 224.2.2.3 </multicast-group>
<Multicast-port> 54327 </multicast-port>
</Multicast>
<TCP/IP enabled = "true"> // change "false" to "true" and add the following content:
<Member> 192.168.10.203: 5701 </member>
<Member> 192.168.10.235: 5701 </member>
<Member> 192.168.10.208: 5701 </member>
</TCP/IP>
<Aws enabled = "false"/>
</Join>
<Interfaces enabled = "true"> // change "false" to "true" and add the following
<Interface> 192.168.10.203 </interface> // local IP address
</Interfaces>

All three openfire machines are configured according to this rule. Restart openfire after configuration.

3. Log on to the web management background, http: // IP: 9090, and then start the cluster, as shown in the figure below.
Openfire_cluster
Openfire_cluster
Note: it is very slow to save the settings. If it is stuck there, restart openfire and it will be OK. After the cluster is configured successfully, three openfire machines are displayed in the web Management backend of the three openfire instances.

Fourth. Install and configure nginx and nginx_tcp_proxy_module on 192.168.10.208.

1, nginx, nginx_tcp_proxy_module download


Nginx: http://nginx.org/download/
Tcp plug-in: https://github.com/yaoweibin/nginx_tcp_proxy_module

2. Install nginx, install patches, and install the tcp plug-in.


# Wget http://nginx.org/download/nginx-1.2.1.tar.gz
# Tar-zxvf nginx-1.2.1.tar.gz
# Cd nginx-1.2.1/
# Patch-p1 </nginx_tcp_proxy_module path/tcp. patch // patch
#./Configure -- add-module =/nginx_tcp_proxy_module path // add nginx tcp module
# Make & make install

Note: nginx1.2.1 and nginx1.4.7 are all correct. nginx1.8.1 cannot be installed. The nginx version cannot be too new.

3. Configure nginx


# Vim/etc/nginx. conf
 
Tcp {// add
Timeout 1d;
Proxy_read_timeout 10d;
Proxy_send_timeout 10d;
Proxy_connect_timeout 30;
Upstream openfire5222 {
Server 192.168.10.235: 5222;
Server 192.168.10.203: 5222;
Server 192.168.10.208: 5222;
Check interval = 3000 rise = 2 fall = 5 timeout = 1000;
    } 
Server {
Listen 6222;
Proxy_pass openfire5222;
So_keepalive on;
Tcp_nodelay on;
    } 
Upstream openfire5223 {
Server 192.168.10.235: 5223;
Server 192.168.10.203: 5223;
Server 192.168.10.208: 5223;
Check interval = 3000 rise = 2 fall = 5 timeout = 1000;
    } 
Server {
Listen 6223;
Proxy_pass openfire5223;
So_keepalive on;
Tcp_nodelay on;
    } 

 
Http {// add the following content
............ Omitted ..............
Upstream openfire7070 {
Server 192.168.10.235: 7070;
Server 192.168.10.203: 7070;
Server 192.168.10.208: 7070;
    } 
Server {
Listen 17070;
Server_name 192.168.10.208;
Location /{
Proxy_pass http: // openfire7070;
        } 
    } 
Upstream openfire9090 {
Server 192.168.10.235: 9090;
Server 192.168.10.203: 9090;
Server 192.168.10.208: 9090;
Ip_hash;
    } 
Server {
Listen 19090;
Server_name 192.168.10.208;
Location /{
Proxy_pass http: // openfire9090;
        } 
    } 
............ Omitted ..............

Restart nginx

Fifth. Test the nginx openfire cluster

1. Test the openfire Management backend, http: // 192.168.10.208: 19090
2. Test xmpp and download spark. The logon address and port are 192.168.10.208 and Port: 6222.
After registering and successfully logging on, we can see the number of online users from the four web management backgrounds.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.