首页 > 其他 > 详细

Tigase8.0 源代码分析:四、集群配置篇

时间:2020-04-04 23:42:53      阅读:127      评论:0      收藏:0      [点我收藏+]

 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表中。vhost查询库加载出本地domain包含了所有域。当eventbus组件发出给另一个域的数据包在MessageRouter中查询vhost表发现本地包含该域,所以导致数据包又投回来本机处理,从而出现数据包死循环的问题。

 

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

 

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

技术分享图片

 

 

 

技术分享图片

 

 

 技术分享图片

 

 

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

技术分享图片

 

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

‘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
}

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 {}
}

  

 

Tigase8.0 源代码分析:四、集群配置篇

原文:https://www.cnblogs.com/eyecool/p/12633939.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!