Tigase8.0 源代码分析:四、集群配置篇
原文链接: https://www.cnblogs.com/eyecool/p/12633939.html
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-PC192.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= tls-required= enabled= s2s-secret= hostname= max-users= register= domain-filter=><comps></comps><other></other></vhost> <vhost anon= tls-required= enabled= s2s-secret= hostname= max-users= register= domain-filter=><comps></comps><other></other></vhost>
5、分别启动 XMPPServer ,成功运行服务!
6、使用PSI 进行测试:连接不同的域进行注册用户,然后进行互加好友,互发消息:
A域和B域的账号互通消息,证明集群消息能相互转发成功!
7、最后,为了方便用户在调试Tigase代码,附上一件我修改过的配置。配置上,组件的线程数量被我修改为1. 为了串行执行,便于从日志中分析流程。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | '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 {} } |
标签:
上一篇: tigase源码分析1:启动
下一篇: Tigase8.0 源代码分析:二、MUC源码分析