-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
222 additions
and
1 deletion.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
docs/source/01-管理服务器-Manage-Server/01-服务器基础知识-Private-Server-Knowledge/create-table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
DROP USER IF EXISTS 'acore'@'%'; | ||
CREATE USER 'acore'@'%' IDENTIFIED BY 'acore' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0; | ||
|
||
GRANT ALL PRIVILEGES ON *.* TO 'acore'@'%' WITH GRANT OPTION; | ||
|
||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'acore'@'%' WITH GRANT OPTION; | ||
|
||
CREATE DATABASE `acore_world` DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_general_ci; | ||
|
||
CREATE DATABASE `acore_characters` DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_general_ci; | ||
|
||
CREATE DATABASE `acore_auth` DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_general_ci; | ||
|
||
|
||
|
||
|
||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `acore_world` . * TO 'acore'@'%' WITH GRANT OPTION; | ||
|
||
|
||
GRANT ALL PRIVILEGES ON `acore_world` . * TO 'acore'@'%' WITH GRANT OPTION; | ||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `acore_characters` . * TO 'acore'@'%' WITH GRANT OPTION; | ||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `acore_auth` . * TO 'acore'@'%' WITH GRANT OPTION; |
5 changes: 5 additions & 0 deletions
5
...器-Manage-Server/02-搭建服务器-Installation-Guide/01-安装核心-Core-Installation/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.. _core-installation: | ||
|
||
安装核心 Core Installation | ||
============================================================================== | ||
|
5 changes: 5 additions & 0 deletions
5
...管理服务器-Manage-Server/02-搭建服务器-Installation-Guide/02-准备服务器-Server-Setup/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.. _server-setup: | ||
|
||
准备服务器 Server Setup | ||
============================================================================== | ||
|
5 changes: 5 additions & 0 deletions
5
...age-Server/02-搭建服务器-Installation-Guide/03-安装数据库-Database-Installation/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.. _database-installation: | ||
|
||
安装数据库 Database Installation | ||
============================================================================== | ||
|
5 changes: 5 additions & 0 deletions
5
...01-管理服务器-Manage-Server/02-搭建服务器-Installation-Guide/04-配置网络-Networking/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.. _networking: | ||
|
||
配置网络 Networking | ||
============================================================================== | ||
|
5 changes: 5 additions & 0 deletions
5
...理服务器-Manage-Server/02-搭建服务器-Installation-Guide/05-启动服务器-Launch-Server/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.. _launch-server: | ||
|
||
启动服务器 Launch Server | ||
============================================================================== | ||
|
25 changes: 25 additions & 0 deletions
25
...r/02-搭建服务器-Installation-Guide/06-用亚马逊云部署生产服务器-AWS-Prod-Server-Deployment/create_mysql.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
本段 SQL 代码的作用是: | ||
1. 创建一个 database user 供服务端程序使用. 这个用户的名字, 密码等信息需要在 authserver.conf 和 worldserver.conf 中使用. | ||
2. 给与这个 user 较大的权限 (几乎所有) 使得服务端程序能对数据库进行各种操作. | ||
3. 创建必须的三个 database. | ||
本段代码来自于 AzerothCore 官方 GitHub 仓库: https://github.com/azerothcore/azerothcore-wotlk/blob/master/data/sql/create/create_mysql.sql | ||
*/ | ||
-- 先删除已经存在的叫做 acore 的 user, 后面的这个 localhost 表示这个 user 将要从哪里访问 | ||
-- 对于服务端程序和数据库在同一个机子上的情况, 当然要用 localhost 了 | ||
DROP USER IF EXISTS 'acore'@'localhost'; | ||
-- 创建一个叫 acore 的 user, 并指定它将会从 localhost 来访问, 而 IDENTIFIED BY 'acore' 则是说设定该服务器的密码为 acore | ||
-- MySQL CREATE USER 命令的官方文档: https://dev.mysql.com/doc/refman/8.0/en/create-user.html | ||
CREATE USER 'acore'@'localhost' IDENTIFIED BY 'acore' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0; | ||
-- 给这个用户所有的数据库权限, 后面的 WITH GRANT OPTION 是指它不仅自己有这些权限, 还能将这些权限 GRANT 给别人 | ||
GRANT ALL PRIVILEGES ON * . * TO 'acore'@'localhost' WITH GRANT OPTION; | ||
-- 创建需要的三个数据库, 没什么好说的 | ||
CREATE DATABASE `acore_world` DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_general_ci; | ||
CREATE DATABASE `acore_characters` DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_general_ci; | ||
CREATE DATABASE `acore_auth` DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_general_ci; | ||
-- 给之前创建的 user 对于三个数据库的最大权限 | ||
GRANT ALL PRIVILEGES ON `acore_world` . * TO 'acore'@'localhost' WITH GRANT OPTION; | ||
GRANT ALL PRIVILEGES ON `acore_characters` . * TO 'acore'@'localhost' WITH GRANT OPTION; | ||
GRANT ALL PRIVILEGES ON `acore_auth` . * TO 'acore'@'localhost' WITH GRANT OPTION; |
17 changes: 17 additions & 0 deletions
17
...务器-Installation-Guide/06-用亚马逊云部署生产服务器-AWS-Prod-Server-Deployment/create_mysql_aws_rds.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
这段代码是对 AzerothCore 官方 SQL https://github.com/azerothcore/azerothcore-wotlk/blob/master/data/sql/create/create_mysql.sql 的修改, 以适用 AWS RDS 的使用场景. | ||
*/ | ||
-- 注意这里不是 @'localhost' 了, 因为我们是从游戏服务器 EC2 连接到数据库, 这里的 111.111.111.111 要替换成 EC2 的 Private IPv4 addresses. 注意这里不是 EC2 的公网 IP, 而是私网 IP. 后面所有的 @'localhost' 都要改. | ||
DROP USER IF EXISTS 'acore'@'111.111.111.111'; | ||
-- 注意这里 'your_password' 是 acore 用户的密码. 不用默认密码而用你自己的密码有助于增加数据库安全性. 但你要知道如果黑客能成功的黑进你的 EC2, 就意味着能看到 authserver.conf 文件, 里面可是明文记录了你的密码的. 所以你还需要保证 EC2 的安全. 当然在 Key Pair + Security Group 的双重保护下一般是没问题的 | ||
CREATE USER 'acore'@'111.111.111.111' IDENTIFIED BY 'your_password' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0; | ||
-- RDS 不允许用 ALL PRIVILEGES, 下面是我们需要给 user 的权限 | ||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON * . * TO 'acore'@'111.111.111.111' WITH GRANT OPTION; | ||
CREATE DATABASE `acore_world` DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_general_ci; | ||
CREATE DATABASE `acore_characters` DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_general_ci; | ||
CREATE DATABASE `acore_auth` DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_general_ci; | ||
-- RDS 不允许用 ALL PRIVILEGES, 而且这一步是将对特定数据库的权限给 user, 所以这些权限要比前面的全局权限小. | ||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `acore_world` . * TO 'acore'@'111.111.111.111' WITH GRANT OPTION; | ||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `acore_characters` . * TO 'acore'@'111.111.111.111' WITH GRANT OPTION; | ||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `acore_auth` . * TO 'acore'@'111.111.111.111' WITH GRANT OPTION; | ||
|
29 changes: 29 additions & 0 deletions
29
...2-搭建服务器-Installation-Guide/06-用亚马逊云部署生产服务器-AWS-Prod-Server-Deployment/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.. _aws-prod-server-deployment: | ||
|
||
用亚马逊云部署生产服务器 AWS Prod Server Deployment | ||
============================================================================== | ||
|
||
|
||
架构选择 | ||
------------------------------------------------------------------------------ | ||
|
||
|
||
选择游戏服务器 EC2 | ||
------------------------------------------------------------------------------ | ||
根据 AC Wiki 上 https://www.azerothcore.org/wiki/memory-usage 的说法, 当游戏玩家探索到一片地图后, 这个区域的地图就会被加载进内存, 而玩家多的时候几乎所有的地图都会被加载进内存, 这些地图至少占用 11G 左右. 而且操作系统本身大约会占用 1G 左右的内存. 而且大约每 100 个玩家需要占用 1G 内存. 你需要留给服务器大约 1 - 2G 内存左右供临时使用. 根据这篇 AC 上的讨论 https://github.com/azerothcore/azerothcore-wotlk/discussions/3891, 维护者 FrancescoBorzi 说了, CPU 一般不是瓶颈, 而 RAM 才是. < 200 个玩家的话, 16GB 内存是足够了的. 这和我们之前计算的 200 玩家 = 11G + 2G + 1G = 占用 14G 内存一致. | ||
|
||
在官服, 一个服务器最大玩家容量在 3000 - 5000 左右, 按照 5000 玩家计算, 我们需要 5000 / 100 ~= 50G 内存, 加上 11G 地图和操作系统的 1G 大约是 62G 内存. 显然我们用 64G 内存的服务器会有随时崩溃的危险, 由于内存在 64 以上一般是 32G 一档, **所以对于 5000 玩家的服务器我们需要用 96G 内存的虚拟机比较合适** | ||
|
||
同理我们可以计算出不同玩家数量下所需的内存: | ||
|
||
- | ||
|
||
|
||
|
||
|
||
1. | ||
|
||
- | ||
- https://aws.amazon.com/ec2/instance-types/ | ||
|
||
https://github.com/azerothcore/azerothcore-wotlk/blob/master/data/sql/create/create_mysql.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import typing as T | ||
import attr | ||
import cottonformation as cf | ||
from cottonformation.res import ec2 | ||
|
||
|
||
@attr.s | ||
class MainStack(cf.Stack): | ||
project_name: str = attr.ib() | ||
stage: str = attr.ib() | ||
vpc_id: str = attr.ib() | ||
default_sg_id: str = attr.ib() | ||
sg_authorized_ips: T.List[str] = attr.ib(factory=list) | ||
|
||
@property | ||
def env_name(self): | ||
""" | ||
A prefix for most of naming convention. Isolate resource from each other. | ||
""" | ||
return f"{self.project_name}-{self.stage}" | ||
|
||
@property | ||
def stack_name(self): | ||
""" | ||
CloudFormation stack name. | ||
""" | ||
return f"{self.env_name}" | ||
|
||
def mk_rg1(self): | ||
""" | ||
Make resource group 1 | ||
""" | ||
name = f"{self.env_name}/sg/project-default" | ||
self.sg_project_default = ec2.SecurityGroup( | ||
"SecurityGroupProjectDefault", | ||
rp_GroupDescription="Resources that has this security can talk to each other", | ||
p_GroupName=name, | ||
p_VpcId=self.vpc_id, | ||
p_SecurityGroupIngress=[ | ||
ec2.PropSecurityGroupIngress( | ||
rp_IpProtocol="-1", | ||
p_FromPort=-1, | ||
p_ToPort=-1, | ||
p_CidrIp=f"{authorized_ip}/32", | ||
) | ||
for authorized_ip in self.sg_authorized_ips | ||
], | ||
p_Tags=cf.Tag.make_many( | ||
Name=name | ||
), | ||
) | ||
|
||
def mk_rg2(self): | ||
""" | ||
Make resource group 2 | ||
""" | ||
pass | ||
|
||
def mk_rg3(self): | ||
""" | ||
Make resource group 3 | ||
""" | ||
pass | ||
|
||
def post_hook(self): | ||
""" | ||
A user custom post stack initialization hook function. Will be executed | ||
after object initialization. | ||
We will put all resources in two different resource group. | ||
And there will be a factory method for each resource group. Of course | ||
we have to explicitly call it to create those resources. | ||
""" | ||
self.mk_rg1() | ||
self.mk_rg2() | ||
self.mk_rg3() | ||
|
||
""" | ||
mysql --host="prod-server.c7pwcs7oc5l0.us-east-1.rds.amazonaws.com" --user="admin" --password="gw8CH&wjRW%Q" | ||
GRANT ALL PRIVILEGES ON * . * TO 'acore'@'gw8CH&wjRW%Q' WITH GRANT OPTION; | ||
CREATE USER 'acore'@'localhost' IDENTIFIED BY 'acore' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0; | ||
CREATE USER 'new_master_user'@'%' IDENTIFIED BY 'password'; | ||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'new_master_user'@'%' WITH GRANT OPTION; | ||
""" |