集群的时候,调用同一个数据库,会报错;在调用存储过程的时候,会报错
Problem initializing jdbc connection: jdbc:mysql://192.168.0.8:3306/tigase?user=xxxxxxxxxx
解决方案为;授权存储过程的权限;如下:
http://www.cnblogs.com/mstk/p/3937191.html
在两台Linux服务器ddd(IP:10.3.93.212)和tsung213(IP:10.3.93.213)上安装了Tigase,要把这两台服务器组成一个Tigase集群,只需要修改这两台服务器的init.properties文件的相关配置即可。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
config-type=--gen-config-def
--admins=admin
@myserver
--virt-hosts =myserver
--debug=server,cluster
--monitoring=jmx:
9050
,http:
9080
,snmp:
9060
--user-db=mysql
--user-db-uri=jdbc:mysql:
//localhost:3306/tigase_db?user=tigase_user&password=123456&useUnicode=true&characterEncoding=UTF-8&autoCreateUser=true
--comp-name-
1
= muc
--comp-
class
-
1
= tigase.muc.MUCComponent
--comp-name-
2
= pubsub
--comp-
class
-
2
= tigase.pubsub.PubSubComponent
--cluster-mode =
true
--cluster-nodes = tsung213,ddd
--cluster-connect-all =
true
|
主要设置的含义如下:
--virt-hosts =myserver 集群名称为myserver
--cluster-mode = true 开启集群模式
--cluster-nodes = tsung213,ddd 集群包含了tsung213和ddd两个节点
集群的时候,调用同一个数据库,会报错;在调用存储过程的时候,会报错
Problem initializing jdbc connection: jdbc:mysql://192.168.0.8:3306/tigase?user=xxxxxxxxxx
解决方案为;授权存储过程的权限;如下:
在java中通过JDBC连接MySQL执行存储过程时报错:
经过查阅资料得知,JDBC在调用存储过程时不光用户要有execute的权限,还需要对mysql.proc具有访问权限。否则它无法访问metadata。有两种解决方法:
一.给数据库连接设置一个noAccessToProcedureBodies属性,属性值为true,示例如下:
网上说设置noAccessToProcedureBodies=true会带来一些影响(未经考证):
1. 调用存储过程时,将没有类型检查,设为字符串类型,并且所有的参数设为int类型,但是在调用registerOutParameter时,不抛出异常。
2. 存储过程的查询结果无法使用getXXX(String parameterName)的形式获取,只能通过getXXX(int parameterIndex)的方式获取。
二.给数据库用户赋权,赋执行mysql.proc表的select权限,示例如下:
参考资料:
http://my.oschina.net/greki/blog/224596
直接贴配置现在2台机器,s3-1,s3-4
s3-1配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
config-
type
=--gen-config-def
--cluster-mode =
true
--cluster-nodes = s3-1.guahao.com:5333,s3-4.guahao.com:5333
--cluster-connect-all =
true
--admins=admin@guahao.com
--virt-hosts=guahao.com
--debug=server,xmpp.impl,db,cluster
--monitoring=jmx:9050,http:9080,snmp:9060
--user-db=mysql
--user-db-uri=jdbc:mysql:
//192
.168.1.15:3306
/tigasedb
?user=tigase&password=tigase&useUnicode=
true
&characterEncoding=UTF-8&autoCreateUser=
true
--comp-name-1=message-archive
--comp-class-1=tigase.archive.MessageArchiveComponent
message-archive
/archive-repo-uri
=jdbc:mysql:
//192
.168.1.15:3306
/tigasedb
?user=tigase&password=tigase&useUnicode=
true
&characterEncoding=UTF-8
--sm-plugins=+message-archive-xep-0136
sess-
man
/plugins-conf/message-archive-xep-0136/component-jid
=message-archive@s3-1
sess-
man
/plugins-conf/message-archive-xep-0136/default-store-method
=body
sess-
man
/plugins-conf/message-archive-xep-0136/required-store-method
=body
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
config-
type
=--gen-config-def
--cluster-mode =
true
--cluster-nodes = s3-1.guahao.com:5333,s3-4.guahao.com:5333
--cluster-connect-all =
true
--admins=admin@guahao.com
--virt-hosts=guahao.com
--debug=server,xmpp.impl,db,cluster
--monitoring=jmx:9050,http:9080,snmp:9060
--user-db=mysql
--user-db-uri=jdbc:mysql:
//192
.168.1.15:3306
/tigasedb
?user=tigase&password=tigase&useUnicode=
true
&characterEncoding=UTF-8&autoCreateUser=
true
--comp-name-1=message-archive
--comp-class-1=tigase.archive.MessageArchiveComponent
message-archive
/archive-repo-uri
=jdbc:mysql:
//192
.168.1.15:3306
/tigasedb
?user=tigase&password=tigase&useUnicode=
true
&characterEncoding=UTF-8
--sm-plugins=+message-archive-xep-0136
sess-
man
/plugins-conf/message-archive-xep-0136/component-jid
=message-archive@s3-1
sess-
man
/plugins-conf/message-archive-xep-0136/default-store-method
=body
sess-
man
/plugins-conf/message-archive-xep-0136/required-store-method
=body
|
注意集群要通,要确保主机名能相互访问,比如ping s3-4;
特别是用的虚拟主机,如果不通可以配下host
1
2
3
4
5
6
7
8
9
|
2.修改
/etc/hosts
里面的名字
#
vi
/etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.1.26 s3-1
192.168.1.28 s3-4
|
配置参考:http://www.tigase.org/content/cluster-nodes
另外如果配置“cluster port”,作用是在已有的集群里添加,新服务器的时候,已有的服务器,不用任何动作;
默认为集群策略说明,https://projects.tigase.org/projects/tigase-server/wiki/Default_clustering_strategy;要应用的时候多看看,这个策略不是做大量用户的;
另外还有个商业化组件,需要购买license(它妹的上当了)
http://www.tigase.com/content/tigase-acs-advanced-clustering-strategy
这快还没真正使用,还得在研究研究