Tigase服务器和多个数据库配置,如用户验证和数据存储分离

发布时间: 5年前 (2020-04-16)浏览: 1175评论: 0

7.4。Tigase服务器和多个数据库

在Tigase XMPP Server中几乎总是可以将用户身份验证数据与其他所有XMPP信息(例如名册,vcard等)分开。可能且非常简单的配置。同样,为每个Tigase组件(MUC,PubSub,AMP)分配一个不同的数据库以记录服务器统计数据始终是可能且容易的。几乎每种数据类型或组件都可以将信息存储在不同的位置,并且可以通过配置文件轻松简单地进行设置。

但是,鲜为人知的是,每个虚拟域也可以具有不同的数据库。这适用于用户存储库和身份验证存储库。这允许进行非常有趣的配置,例如用户数据库分片,其中每个分片将用户保留在特定域中,或者如果每个域指的是不同的客户或一群人,则根据虚拟域物理拆分数据。

那我们该怎么做呢?

通过Tigase的配置文件很容易做到这一点。

通常,众所周知的行:

--auth-db=tigase-custom --auth-db-uri=jdbc:mysql://db1.tigase/dbname?user&password --user-db=mysql --user-db-uri=jdbc:mysql://db2.tigase/dbname?user&password

仅为用户存储库和身份验证存储库定义默认数据库。默认表示在没有为特定虚拟域指定存储库时使用。但是,每个虚拟域都可以有一个单独的用户和身份验证存储库。

下面是它的工作原理:

# First, let's define our default database for all VHosts 
--auth-db=tigase-custom 
--auth-db-uri=jdbc:mysql://db1.tigase/dbname?user&password 
--user-db=mysql 
--user-db-uri=jdbc:mysql://db2.tigase/dbname?user&password 
# Now, we have VHost: domain1.com 
# User authentication data for this VHost is stored in Drupal database 
--auth-db[domain1.com]=drupal 
--auth-db-uri[domain1.com]=jdbc:mysql://db7.tigase/dbname?user&password 
# All other user data is stored in Tigase's standard database in MySQL 
--user-db[domain1.com]=mysql 
--user-db-uri[domain1.com]=jdbc:mysql://db4.tigase/dbname?user&password 
# Next VHost: domain2.com # User authentication is in LDAP server 
--auth-db[domain2.com]=tigase.db.ldap.LdapAuthProvider 
# Pretty standard Tigase's definition for the database (repository) 
#  connection string 
--auth-db-uri[domain2.com]=ldap://ldap.domain2.com:389 
# Now is something new, we have a custom authentication repository 
# settings for a single domain. 
# Please note how we define the VHost for which we set custom parameters basic-conf/auth-repo-params/domain2.com/user-dn-pattern=cn=,ou=,dc=,dc= 
# All other user data is stored in the same as default repository 
--user-db[domain2.com]=mysql 
--user-db-uri[domain2.com]=jdbc:mysql://db2.tigase/dbname?user&password 
# Next VHost: domain3.com 
# Again user authentication is in LDAP server but pointing to 
# a different LDAP server with different access credentials 
--auth-db[domain3.com]=tigase.db.ldap.LdapAuthProvider 
# Pretty standard Tigase's definition for the database 
# (repository) connection string 
--auth-db-uri[domain3.com]=ldap://ldap.domain3.com:389 
# Now is something new, we have a custom authentication 
# repository settings for a single domain 
# Please note how we define the VHost for which we set custom parameters 
basic-conf/auth-repo-params/domain3.com/user-dn-pattern=cn=,ou=,dc=,dc= 
# All other user data is stored on the domain3 server in PostgreSQL database 
--user-db[domain3.com]=pgsql 
--user-db-uri[domain3.com]=jdbc:pgsql://db.domain3.com/dbname?user&password 
# For VHost: domain4.com all the data, both authentication and 
# user XMPP data are stored on a separate 
# MySQL server with custom stored procedures for both user 
# login and user logout processing. 
--auth-db[domain4.com]=tigase-custom 
--auth-db-uri[domain4.com]=jdbc:mysql://db14.domain4.com/dbname?user&password 
basic-conf/auth-repo-params/domain4.com/user-login-query={ call UserLogin(?, ?) } 
basic-conf/auth-repo-params/domain4.com/user-logout-query={ call UserLogout(?) } 
basic-conf/auth-repo-params/domain4.com/sasl-mechs=PLAIN,DIGEST-MD5 
--user-db[domain4.com]=mysql 
--user-db-uri[domain4.com]=jdbc:mysql://db14.domain4.com/dbname?user&password

如您所见,它需要进行一些编写,但是灵活性非常广泛,您可以根据需要或需要设置任意数量的独立数据库。如果一个数据库(由数据库连接字符串识别)在不同的VHost之间共享,则Tigase仍将使用单个连接池,因此不会为数据库创建过多的连接。

我希望这有助于更复杂的设置和配置案例。


标签:

上一篇: Maven 3 Felix 4 Eclipse 的搭建与部署(部分转载自别人文章)
下一篇: Tigase HTTP API官方文档--7.1.2

相关文章暂无相关
评论列表暂无评论
发表评论
验证码

«   2024年4月   »
1234567
891011121314
15161718192021
22232425262728
2930
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言
    文章归档
    网站收藏
    友情链接
    • RainbowSoft Studio Z-Blog
    • 订阅本站的 RSS 2.0 新闻聚合
    ︿
    Top