Tigase8集群配置是很简单的,本文从实验的角度来了解tigase集群配置及启动。

首先你先能保证在机器上能跑单机版本的代码,如果还没有,先移步看前面的博客吧<IDEA 上 Tigase8.0 源代码编译运行>

 

1、准备工作:内网中至少两台主机:

我就以我本地实验来做参考:

主机A:[192.168.3.2] 主机名[llooper]

主机B:[192.168.3.5] 主机名[shirley-pc]

 

2、修改 C:\Windows\System32\drivers\etc\hosts 文件,配置名字映射使得A.B主机之间互通

192.168.3.5 Shirley-PC
192.168.3.2 llooper

3、修改Tigase的配置文件

A主机:

'admin = [ 'admin@llooper' ]
'cluster-mode' = true
'cluster-nodes' = [ 'llooper' , 'Shirley-PC' ]
'config-type' = 'default'
'default-virtual-host' = 'llooper'
'debug' = [ 'server', 'cluster','eventbus' ]
'cl-comp' {
    'connect-all' = true
}
dataSource {
  'pool-size' = 1
    default () {
        uri = 'jdbc:mysql://A数据源'
    }
}

B主机:

'admin = [ 'admin@Shirley-PC' ]
'cluster-mode' = true
'cluster-nodes' = [ 'llooper' , 'Shirley-PC' ]
'config-type' = 'default'
'default-virtual-host' = 'Shirley-PC'
'debug' = [ 'server', 'cluster','eventbus' ]
'cl-comp' {
    'connect-all' = true
}
dataSource {
  'pool-size' = 1
    default () {
        uri = 'jdbc:mysql://B数据源'
    }
}

 集群相关的配置也就以下三个属性需要注意下:

'cluster-mode' = true  //开启集群模式
'cluster-nodes' = [ 'llooper' , 'Shirley-PC' ] //集群全部的主机域名
'cl-comp' {
    'connect-all' = true  //动态地将不在集群配置中的节点加入到集群中,默认为false
}

 

4、注意:目前集群user模块数据库必需使用不同的数据源,如果同用一个数据库,不同域下的注册用户都在同一个user模块表中。通过vhost-manager在users表中,查询出UID,再通过vhosts-lists作为key在tig_pairs表中查询库加载<vhost>,如果都同用一个数据源,那么vhost包含所有域。当eventbus组件发出给另一个域的数据包在MessageRouter中查询vhost发现本地包含该域,所以导致数据包又投回来本机处理,从而出现数据包死循环的问题。

<vhost anon="true" tls-required="false" enabled="true" s2s-secret="15b43189-2b23-46ae-9dc6-ab0acdceafe5" hostname="llooper" max-users="0" register="true" domain-filter="ALL"><comps></comps><other></other></vhost>
<vhost anon="true" tls-required="false" enabled="true" s2s-secret="1434ac98-8ba1-41e2-a57e-6559fb94d921" hostname="shirley-pc" max-users="0" register="true" domain-filter="ALL"><comps></comps><other></other></vhost>

 

 

 

5、分别启动 XMPPServer ,成功运行服务!

 

6、使用PSI 进行测试:连接不同的域进行注册用户,然后进行互加好友,互发消息:

 

 

 

 

 

 

 

 

 A域和B域的账号互通消息,证明集群消息能相互转发成功!

 

7、最后,为了方便用户在调试Tigase代码,附上一件我修改过的配置。配置上,组件的线程数量被我修改为1. 为了串行执行,便于从日志中分析流程。

'admins' = [ 'admin@llooper' ]
'cluster-mode' = true
'cluster-nodes' = [ 'llooper' , 'Shirley-PC' ]
'config-type' = 'default'
'default-virtual-host' = 'llooper'
'debug' = [ 'server', 'cluster','eventbus' ]
'cl-comp' {
    'connect-all' = true
}

logging (class: tigase.conf.LoggingBean) {
    debug = [ 'server', 'cluster', 'eventbus' ]

    rootHandlers = [ 'java.util.logging.ConsoleHandler', 'java.util.logging.FileHandler' ]
    rootLevel = CONFIG
    'shutdown-thread-dump' = true
    handlers {
        'java.util.logging.ConsoleHandler' {
            formatter = 'tigase.util.log.LogFormatter'
             level = ALL
        }
        'java.util.logging.FileHandler' {
            append = true
            count = 1
            formatter = 'tigase.util.log.LogFormatter'
            level = ALL
            limit = 10000000
            pattern = 'logs/tigase.log'
        }
    }
 }

dataSource {
  'pool-size' = 1
    default () {
        uri = 'jdbc:mysql://数据源地址'
    }
}
userRepository {
    default () {}
}
authRepository {
    default () {}
}

'cl-comp' {
    'connect-all' = true
}

amp () {
    'processing-in-threads' = 1
    'processing-out-threads' = 1
}
bosh () {
    'processing-in-threads' = 1
    'processing-out-threads' = 1
    seeOtherHost {}
}
c2s () {
    'processing-in-threads' = 1
    'processing-out-threads' = 1
    seeOtherHost {}
}
http (class: tigase.http.HttpMessageReceiver) {}
'message-router' () {
    'processing-in-threads' = 1
    'processing-out-threads' = 1
}
s2s () {
    'processing-in-threads' = 1
    'processing-out-threads' = 1
}
'sess-man' () {
    'processing-in-threads' = 1
    'processing-out-threads' = 1

       amp (class: tigase.xmpp.impl.MessageAmp) {
            threadsNo = 1
            message (class: tigase.xmpp.impl.Message) {
                threadsNo = 1
            }
            msgoffline (class: tigase.xmpp.impl.OfflineMessages) {
                threadsNo = 1
            }
        }
      'default-handler' () {
            threadsNo = 1
        }
        disco () {
            threadsNo = 1
        }
        'domain-filter' (class: tigase.xmpp.impl.DomainFilter) {
            threadsNo = 1
        }


        'http://jabber.org/protocol/commands' (class: tigase.xmpp.impl.JabberIqCommand) {
            threadsNo = 1
        }
        'http://jabber.org/protocol/jingle' (class: tigase.xmpp.impl.Jingle,
            active: false) {
            threadsNo = 1
        }
        'http://jabber.org/protocol/offline' (class: tigase.xmpp.impl.FlexibleOfflineMessageRetrieval,
            active: false) {
            threadsNo = 1
        }
        'http://jabber.org/protocol/stats' (class: tigase.xmpp.impl.JabberIqStats) {
            threadsNo = 1
        }
        'invisible-command' (class: tigase.xmpp.impl.InvisibleCommand,
            active: false) {
            threadsNo = 1
        }
        'jabber:iq:auth' (class: tigase.xmpp.impl.JabberIqAuth) {
            threadsNo = 1
        }
        'jabber:iq:iq' (class: tigase.xmpp.impl.JabberIqIq,
            active: false) {
            threadsNo = 1
        }
        'jabber:iq:last-marker' (class: tigase.xmpp.impl.LastActivityMarker,
            active: false) {

            threadsNo = 1
        }
        'jabber:iq:privacy' (class: tigase.xmpp.impl.JabberIqPrivacy) {
            threadsNo = 1
        }
        'jabber:iq:private' (class: tigase.xmpp.impl.JabberIqPrivate) {
            threadsNo = 1
        }
        'jabber:iq:register' (class: tigase.xmpp.impl.JabberIqRegister) {
            threadsNo = 1
        }
        'jabber:iq:roster' (class: tigase.xmpp.impl.JabberIqRoster) {
            threadsNo = 1
        }
        'jabber:iq:version' (class: tigase.xmpp.impl.JabberIqVersion) {
            threadsNo = 1
        }
        message (class: tigase.xmpp.impl.Message,
            active: false) {
            threadsNo = 1
        }
        'message-all' (class: tigase.xmpp.impl.MessageAll,
            active: false) {
            threadsNo = 1
        }
        'message-carbons' (class: tigase.xmpp.impl.MessageCarbons) {
            threadsNo = 1
        }
        'message-vhost-forward' (class: tigase.xmpp.impl.MessageForwarding,
            active: false) {
            threadsNo = 1
        }
        mobile_v1 (class: tigase.xmpp.impl.MobileV1,
            active: false) {
            threadsNo = 1
        }
        mobile_v2 (class: tigase.xmpp.impl.MobileV2,
            active: false) {
            threadsNo = 1
        }
        mobile_v3 (class: tigase.xmpp.impl.MobileV3,
            active: false) {
            threadsNo = 1
        }
        motd (class: tigase.xmpp.impl.MotdProcessor,
            active: false) {
            threadsNo = 1
        }

        msgoffline (class: tigase.xmpp.impl.OfflineMessages,
            active: false) {
            threadsNo = 1
        }
        'pep-simple' (class: tigase.xmpp.impl.PepPlugin,
            active: false) {
            threadsNo = 1
        }
        'presence-offline' (class: tigase.xmpp.impl.PresenceOffline,
            active: false) {
            threadsNo = 1
        }
        'presence-state' (class: tigase.xmpp.impl.PresenceState) {

            threadsNo = 1
        }
        'presence-subscription' (class: tigase.xmpp.impl.PresenceSubscription) {
            threadsNo = 1
        }
        'remote-roster-management' (class: tigase.xmpp.impl.RemoteRosterManagement,
            active: false) {
            threadsNo = 1
        }

        scriptCommandProcessor (class: tigase.component.ComponenScriptCommandProcessor) {}
        'session-close' (class: tigase.server.xmppsession.SessionManager$SessionCloseProc) {
            threadsNo = 1
        }
        'session-open' (class: tigase.server.xmppsession.SessionManager$SessionOpenProc) {
            threadsNo = 1
        }
        starttls (class: tigase.xmpp.impl.StartTLS) {
            threadsNo = 1
        }
        'urn:ietf:params:xml:ns:xmpp-bind' (class: tigase.xmpp.impl.BindResource) {
            threadsNo = 1
        }
        'urn:ietf:params:xml:ns:xmpp-sasl' (class: tigase.xmpp.impl.SaslAuth) {
            threadsNo = 1
        }
        'urn:ietf:params:xml:ns:xmpp-session' (class: tigase.xmpp.impl.SessionBind) {
            threadsNo = 1
        }
        'urn:xmpp:blocking' (class: tigase.xmpp.impl.BlockingCommand) {
            threadsNo = 1
        }
        'urn:xmpp:csi:0' (class: tigase.xmpp.impl.ClientStateIndication) {
            threadsNo = 1
            logic (class: tigase.xmpp.impl.MobileV2) {
                threadsNo = 1
            }
        }
        'urn:xmpp:extdisco:2' (class: tigase.server.extdisco.ExternalServiceDiscoveryProcessor,
            active: false) {
            threadsNo = 1
        }
        'urn:xmpp:ping' (class: tigase.xmpp.impl.UrnXmppPing) {
            threadsNo = 1
        }
        'urn:xmpp:time' (class: tigase.xmpp.impl.EntityTime) {
            queueSize = null
            threadsNo = 1
        }
        'vcard-temp' (class: tigase.xmpp.impl.VCardTemp) {
            threadsNo = 1
        }
        'vcard-xep-0292' (class: tigase.xmpp.impl.VCard4) {
            threadsNo = 1
        }
        writer (class: tigase.server.xmppsession.SessionManager$SMPacketWriter) {}
        zlib (class: tigase.xmpp.impl.StartZLib) {
            threadsNo = 1
        }

}
ws2s () {
    'processing-in-threads' = 1
    'processing-out-threads' = 1
    seeOtherHost {}
}

  

 

posted on 2020-04-04 21:22  llooperliang  阅读(1160)  评论(0编辑  收藏  举报