TrinityCore多区realms配置-do multiple realms for TrinityCore
创始人
2024-09-25 18:52:52
0

TrinityCore是支持多区配置的,即多个realm分区。只需要起一套authserver服务,负责全部区的登录。需要在mysql的auth库中加入其它realm的配置信息,如:

+----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ |  1 | Trinity  | 114.115.136.249 | 127.0.0.1    | 255.255.255.0   | 8085 |    0 |    0 |       16 |                    0 |          0 |     12340 | |  2 | NewRealm | 114.115.136.249 | 127.0.0.1    | 255.255.255.0   | 8086 |    0 |    2 |       16 |                    0 |          0 |     12340 | +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ 

其它realms区只需要启动worldserver服务,不需要再启动authserver服务。worldserver.conf配置文件里需要mysql指向authserver的ip,如:LoginDatabaseInfo     = "192.168.1.2;3306;trinity;trinity;auth" 。这里的192.168.1.2是authserver服务器的ip地址,也就是mysql的auth库是调用的authserver的内容,而character和world数据库,还是用各个realms本地的。

TrinityCore安装文档:TrinityCore安装记录_ubuntu 魔兽世界-CSDN博客

mysql打开网络服务文档:如何在python里登录测试mysql数据库-CSDN博客

尝试TrinityCore多区配置

# 进入wow用户 su - wow  # 进入mysql控制台 sudo mysql

添加一条新区数据到realmlist

默认只有id 1,后来加了id 2 和6 两条。

mysql> insert into realmlist (name) values("test") ; Query OK, 1 row affected (0.01 sec)  mysql> select * from realmlist; +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ | id | name     | address         | localAddress | localSubnetMask | port | icon | flag | timezone | allowedSecurityLevel | population | gamebuild | +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ |  1 | Trinity  | 114.115.136.249 | 127.0.0.1    | 255.255.255.0   | 8085 |    0 |    0 |        1 |                    0 |          0 |     12340 | |  2 | NewRealm | 192.168.1.12    | 127.0.0.1    | 255.255.255.0   | 8085 |    0 |    0 |        1 |                    0 |          0 |     12340 | |  6 | test     | 127.0.0.1       | 127.0.0.1    | 255.255.255.0   | 8085 |    0 |    2 |        0 |                    0 |          0 |     12340 | +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ 3 rows in set (0.00 sec)  

修改realm把realm id由3改为2

首先看一下:

mysql> use auth;

mysql> select id,name,address,localaddress,gamebuild from realmlist;
+----+----------+-----------------+--------------+-----------+
| id | name     | address         | localaddress | gamebuild |
+----+----------+-----------------+--------------+-----------+
|  1 | Trinity  | 114.115.136.249 | 192.168.0.12 |     12340 |
|  3 | NewRealm | 192.168.1.12    | 192.168.1.12 |     12345 |
+----+----------+-----------------+--------------+-----------+
2 rows in set (0.00 sec)

把realm名字改成:NewRealm 。当然可以改成自己喜欢的名字。

刚开始拿到的id是3,把RealmID 从3改成2:

mysql> update realmlist set id="2" where id="3"; Query OK, 1 row affected (0.01 sec) Rows matched: 1  Changed: 1  Warnings: 0 

worldserver.conf文件中修改

修改realm2区服务器的server/etc/worldserver.conf文件,把原文件中RealmID = 1 改为RealmID = 2

同样在authserver.conf文件中需要写
当时是这样的:

mysql> use auth; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A  Database changed mysql> select * from realmlist; +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ | id | name     | address         | localAddress | localSubnetMask | port | icon | flag | timezone | allowedSecurityLevel | population | gamebuild | +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ |  1 | Trinity  | 114.115.136.249 | 192.168.0.12 | 255.255.255.0   | 8085 |    0 |    0 |        1 |                    0 |          0 |     12340 | |  3 | NewRealm | 192.168.1.12    | 192.168.1.12 | 255.255.255.0   | 8085 |    0 |    0 |        0 |                    0 |          0 |     12345 | +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ 2 rows in set (0.00 sec)  

修改时区到16

timezone	displayed name		timezone	displayed name 1	Development		20	CN4 2	United States		21	CN5 3	Oceanic		22	CN6 4	Latin America		23	CN7 5	Tournament		24	CN8 6	Korea		25	Tournament 7	Tournament		26	Test Server 8	English		27	Tournament 9	German		28	QA Server 10	French		29	CN9 11	Spanish		30	Test Server 2 12	Russian		31	CN10 13	Tournament		32	CTC 14	Taiwan		33	CNC 15	Tournament		34	CN1/4 16	China		35	CN2/6/9 17	CN1		36	CN3/7 18	CN2		37	CN5/8 19	CN3			 

把时区修改成16 中国

mysql> UPDATE realmlist SET timezone='16' WHERE id =3 ; Query OK, 1 row affected (0.03 sec) Rows matched: 1  Changed: 1  Warnings: 0  mysql> UPDATE realmlist SET timezone='16' WHERE id =1 ; Query OK, 1 row affected (0.02 sec) Rows matched: 1  Changed: 1  Warnings: 0  mysql> select * from realmlist; +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ | id | name     | address         | localAddress | localSubnetMask | port | icon | flag | timezone | allowedSecurityLevel | population | gamebuild | +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ |  1 | Trinity  | 114.115.136.249 | 192.168.0.12 | 255.255.255.0   | 8085 |    0 |    0 |       16 |                    0 |          0 |     12340 | |  3 | NewRealm | 192.168.1.12    | 192.168.1.12 | 255.255.255.0   | 8085 |    0 |    0 |       16 |                    0 |          0 |     12345 | +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ 2 rows in set (0.01 sec) 

但是现在登录到192.168.0.12,还是看不到多区。

现在总结一下,需要id 修改一下,比如把id改成2 ,同时worldserver.conf 文件里的 realmID 也设置为2 

同时localAddress 不能用本地ip地址,如192.168.0.12 ,因为这样远端(通过公网)就无法连上服务器了。

解决看不到TrinityCore多区的问题

原来是版本的问题,以前用的版本是12340,后来编译的时候可能拿到的是12345,就是版本不一致导致客户端一直没有看见新区

mysql> update realmlist set gamebuild="12340" where id="2"; 
+----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ |  1 | Trinity  | 114.115.136.249 | 127.0.0.1 | 255.255.255.0   | 8085 |    0 |    0 |       16 |                    0 |          0 |     12340 | |  2 | NewRealm | 192.168.1.12    | 127.0.0.1 | 255.255.255.0   | 8085 |    0 |    0 |       16 |                    0 |          0 |     12340 | +----+----------+-----------------+--------------+-----------------+------+------


将RealmID改成1和2,将版本号都改成12340,现在终于能看到两个区了。

现在的问题是,如果账户登录的是1号realm(192.168.0.12),能看见两个区,但是只能登录1号区,登录2号区提示auth认证失败,进不去看见账户那里。

如果帐号登录的就是2号realm(192.168.1.12),那么登录1号区会失败,2号可以登录。

也就是无法1号和2号两个区同时登录成功。

核心:解决全网可通mysql auth数据库的问题

现在的核心就是要设置一个公用的mysql的auth库,并保证可以通过网络能连上这个库。

决定使用192.168.0.12为公用auth库,realm1 和realm2都指向这台服务器的mysql数据库。为了能够外网访问mysql,增加了一个host为%的语句:

mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A  Database changed mysql> update auth set host = '%' where user = 'trinity'; ERROR 1146 (42S02): Table 'mysql.auth' doesn't exist mysql> update user set host = '%' where user = 'trinity'; Query OK, 1 row affected (0.01 sec) Rows matched: 1  Changed: 1  Warnings: 0  mysql> select host, user from user; +-----------+------------------+ | host      | user             | +-----------+------------------+ | %         | trinity          | | localhost | debian-sys-maint | | localhost | mysql.infoschema | | localhost | mysql.session    | | localhost | mysql.sys        | | localhost | root             | +-----------+------------------+ 6 rows in set (0.00 sec)

现在调试,从192.168.1.12登过来,显示

Error: (1130, "Host '192.168.1.12' is not allowed to connect to this MySQL server")

发现是给错服务器了.....因为两台服务器,老是弄混.....

给192.168.0.12增加源ip192.168.1.12的登入权限:

​ CREATE USER 'trinity'@'192.168.1.12' IDENTIFIED BY 'trinity';   GRANT ALL PRIVILEGES ON auth.* TO 'trinity'@'192.168.1.12' WITH GRANT OPTION;

可以看到加进去了: 

select host, user from user; +--------------+------------------+ | host         | user             | +--------------+------------------+ | 192.168.1.12 | trinity          | | localhost    | debian-sys-maint | | localhost    | mysql.infoschema | | localhost    | mysql.session    | | localhost    | mysql.sys        | | localhost    | phpmyadmin       | | localhost    | root             | | localhost    | trinity          | +--------------+------------------+ 9 rows in set (0.00 sec) 

 再配好worldserver的配置

worldserver从网上过来,如果是本地登录,设为本地192.168.1.12地址即可。

这里用了公网的ip的映射,最终auth realmlist的配置:

mysql> update realmlist set address="114.115.136.249"  where id="2"; Query OK, 1 row affected (0.03 sec) Rows matched: 1  Changed: 1  Warnings: 0  mysql> update realmlist set port="8086"  where id="2"; Query OK, 1 row affected (0.02 sec) Rows matched: 1  Changed: 1  Warnings: 0  mysql> update realmlist set timezone="16"  where id="2"; Query OK, 1 row affected (0.04 sec) Rows matched: 1  Changed: 1  Warnings: 0  mysql> select * ; ERROR 1096 (HY000): No tables used mysql> select * from auth; ERROR 1146 (42S02): Table 'auth.auth' doesn't exist mysql> select * from realmlist; +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ | id | name     | address         | localAddress | localSubnetMask | port | icon | flag | timezone | allowedSecurityLevel | population | gamebuild | +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ |  1 | Trinity  | 114.115.136.249 | 127.0.0.1    | 255.255.255.0   | 8085 |    0 |    0 |       16 |                    0 |          0 |     12340 | |  2 | NewRealm | 114.115.136.249 | 127.0.0.1    | 255.255.255.0   | 8086 |    0 |    2 |       16 |                    0 |          0 |     12340 | +----+----------+-----------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+ 2 rows in set (0.00 sec)  

 这样终于多区配置成功了!两个区 Trinity和NewRealm都可以登录了!

总结

TrinityCore多区拓扑:

 可以看到两个分区是不同网段,192.168.0.12和192.168.1.12且中间有一层NAT。内网的192.168.0.12被NAT为192.168.1.2 。

其实这不是必须的,在同一网段,或者不在同一网段,都可以实现TrinityCore的多区设置。当然有一个条件,就是其它的ream需要能够跟auth服务器的mysql通信,因为其它realm都是登入auth所在的mysql数据库并调用的其中的auth库内容。

对于所有的realms,都要设定auth指向192.168.0.12即worldserver.conf文件中设置,即多个realm认证服务用同一个数据库:

# LoginDatabaseInfo     = "127.0.0.1;3306;trinity;trinity;auth" LoginDatabaseInfo     = "192.168.1.2;3306;trinity;trinity;auth" 

 这里192.168.0.12数据库被NAT为192.168.1.2:3306 。所以最终指向了192.168.1.2 ,注意需要设置mysql支持网络登录,具体见:https://skywalk.blog.csdn.net/article/details/140786611

当然realm1 还是使用127.0.0.1地址登录myql,即:

LoginDatabaseInfo     = "127.0.0.1;3306;trinity;trinity;auth"

对于realmid,每个realm对需要跟auth数据库中的id值对应,比如这里

192.168.0.12 是realm 1, worldserver.conf中设为RealmID = 1:

192.168.1.12是realm2 ,设为RealmID = 2

如果再增加ream,则id依次增加即可。

worldserver.conf中RealmZone 是realm的分区,设为16即为cn ,默认是RealmZone = 1

最后注意gamebuild需要与客户端版本一致,否则客户端是看不到服务器的。

这样设置好后,TrinityCore多区realms就设定好了。当前还不支持跨服副本(Cross realms are not supported.)

相关内容

热门资讯

成了朋友的成怎么写 成了朋友的“成”在这里是动词,表示达到某种状态或结果。在简体中文中,写作“成”。我们经过长时间的相处...
显宏这个名字怎么样 显宏这个名字寓意深远,"显"意味着显赫、显著,"宏"则代表宏大、宏伟。整体给人一种气度不凡、志向远大...
print 输出语句 目录基本用法输出多个值结束符分隔符格式化输出1. 使用 f-string(格式化字符串...
非遗小知识在幕后操纵木偶进行表... 古代在幕后操纵木偶进行表演的木偶戏又称为“悬丝傀儡”或“线偶”。探秘传统艺术——木偶戏的古代称谓单元...
菜鸡云游戏怎么发动态-菜机ap... 在菜鸡云游戏APP中,通常可以在个人中心或者动态/社区页面找到发布动态的选项。点击相应的按钮,编辑内...
cad无法进一步缩小怎么解决(... 在CAD中,如果无法进一步缩小,可能是因为已经达到了最小比例。您可以尝试使用“缩放”命令(ZOOM)...
麒麟710相当于骁龙多少? 麒麟710是华为的中端芯片,而骁龙660是高通的中端芯片。在性能上,麒麟710与骁龙660相当。但具...
可以打电话的平板有哪些(目前值... 目前值得入手的可以打电话的平板电脑有:华为MatePad Pro、三星Galaxy Tab S7/S...
从零开始实现大语言模型(七):... 1. 前言前文所述神经网络模块CausalAttention也被称为单头注意力模块(single-h...
python学习笔记——字符串 一、创建字符串        1.我们可以使用引号( ' 或 " )来创建字符串。创建字符串很简单&...