0


魔兽世界服务端AzerothCore+Centos系统+docker编译教程

魔兽世界服务端AzerothCore+Centos系统+docker编译教程

声明:本文只做探讨性研究,不以盈利为目的,仅供个人娱乐。如果涉及侵权行为,请联系本作者删除。

1.1 准备工作

1.1.1 准备

  1. linux系统服务器1台, 推荐Centos7 系统,虚拟机即可
  2. 服务器能够访问外网
  3. 地图文件
  4. 下载魔兽世界客户端12340版本,即3.3.5 WLK版本

1.1.2 安装软件

安装docker CentOS 环境下安装 Docker
安装docker compose 12.2.2 二进制包
安装git:

yum install git

1.1.3 下载源码

cd /
git clone https://gitee.com/53957105/azerothcore-wotlk.git

下载完成后,会出现 /azerothcore-wotlk 目录

1.1.4 地图文件

地图文件下载地址 (data.zip)
上传地图数据文件到

docker/worldserver/data/

解压地图数据

cd /azerothcore-wotlk/docker/worldserver/data/
unzip data.zip 

1.2 修改配置文件

1.2.1 修改环境变量文件

进入 /azerothcore-wotlk 目录

[root@localhost ~]# cd /azerothcore-wotlk/[root@localhost azerothcore-wotlk]# cp .env.dist .env[root@localhost azerothcore-wotlk]# cat .envWORLDSERVER_DATA=./docker/worldserver/data
WORLDSERVER_ETC=./docker/worldserver/etc
WORLDSERVER_LOGS=./docker/worldserver/logs

AUTHSERVER_ETC=./docker/authserver/etc
AUTHSERVER_LOGS=./docker/authserver/logs

WORLD_EXTERNAL_PORT=1001AUTH_EXTERNAL_PORT=1002DB_EXTERNAL_PORT=1003DB_ROOT_PASSWORD=123456SOAP_EXTERNAL_PORT=1004

端口可自定义,后面操作同步修改

1.2.2 修改文件执行权限

chmod +x -R../azerothcore-wotlk

1.2.3 修改配置文件

[root@localhost azerothcore-wotlk]# cat docker/worldserver/etc/worldserver.conf################################################# AzerothCore World Server configuration file #################################################[worldserver]# Do NOT change those Dir configs
LogsDir ="/azeroth-server/logs"# will reflect on your host directory: docker/worldserver/logs
DataDir ="/azeroth-server/data"# Change this configuration accordingly with your docker setup# The format is "hostname;port;username;password;database":# - docker containers must be on the same docker network to be able to communicate# - the DB hostname will be the name of the database docker container
LoginDatabaseInfo     ="ac-database;3306;root;123456;acore_auth"
WorldDatabaseInfo     ="ac-database;3306;root;123456;acore_world"
CharacterDatabaseInfo ="ac-database;3306;root;123456;acore_characters"# Add more configuration overwrites by copying settings from worldserver.conf.dist
LogLevel =2# Disable idle connections automatic kick since it doesn't work well on macOS + Docker
CloseIdleConnections =0

SOAP.Enabled =1
SOAP.IP ="0.0.0.0"
SOAP.Port =7878[root@localhost azerothcore-wotlk]# cat docker/authserver/etc/authserver.conf################################################ AzerothCore Auth Server configuration file ################################################[authserver]# Do not change this
LogsDir ="/azeroth-server/logs"# will reflect on your host directory: docker/worldserver/logs# Change this configuration accordingly with your docker setup# The format is "hostname;port;username;password;database":# - docker containers must be on the same docker network to be able to communicate# - the DB hostname will be the name of the database docker container
LoginDatabaseInfo ="ac-database;3306;root;123456;acore_auth"# Add more configuration overwrites by copying settings from from authserver.conf.dist
LogLevel =3
SQLDriverLogFile ="SQLDriver.log"
SQLDriverQueryLogging =1

1.3 编译及启动

1.3.1 编译项目

./bin/acore-docker-build

1.3.2 启动容器

docker-compose up

如果失败,再试一次

显示下面内容,表示服务器启动成功:

ac-worldserver_1  | Max allowed socket connections 1048576
ac-worldserver_1  | AzerothCore rev. 036a8c2450ef+ 2020-10-13 10:23:18 +0200 (master branch)(Unix, Release)(worldserver-daemon) ready...
[root@localhost azerothcore-wotlk]# docker ps
CONTAINER ID   IMAGE                     COMMAND                  CREATED        STATUS                  PORTS                                                                                  NAMES
a7c8660f835d   azerothcore/worldserver   "/azeroth-server/bin…"25 hours ago   Up 24 hours (healthy)0.0.0.0:1004->7878/tcp, :::1004->7878/tcp, 0.0.0.0:1001->8085/tcp, :::1001->8085/tcp   azerothcore-wotlk_ac-worldserver_1
a0a051f3a1ab   azerothcore/authserver    "/azeroth-server/bin…"2 days ago     Up 24 hours (healthy)0.0.0.0:1002->3724/tcp, :::1002->3724/tcp                                              azerothcore-wotlk_ac-authserver_1
f6d8ff788432   azerothcore/database      "docker-entrypoint.s…"2 days ago     Up 24 hours (healthy)33060/tcp, 0.0.0.0:1003->3306/tcp, :::1003->3306/tcp                                   azerothcore-wotlk_ac-database_1

当程序启动成功,可以切换至后台运行

docker-compose up -d

1.3.3 无法启动

1. 网络问题

如果出现网络问题,无法启动,可参考以下内容修改

[root@localhost azerothcore-wotlk]# cat docker-compose.yml
version: '3.2'

services:

  ac-database:
    image: azerothcore/database
    restart: unless-stopped
    build:
      context: .
      dockerfile: ./docker/database/Dockerfile
    networks:
      proxy:
        ipv4_address: 169.17.0.10
    ports:
      - ${DB_EXTERNAL_PORT:-3306}:3306
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD:-password}
    volumes:
      - type: volume
        source: ac-database
        target: /var/lib/mysql

  ac-worldserver:
    stdin_open: true
    tty: true
    image: azerothcore/worldserver
    restart: unless-stopped
    privileged: true
    build:
      context: ./docker/worldserver
      dockerfile: Dockerfile
    networks:
      proxy:
        ipv4_address: 169.17.0.11
    ports:
      - ${WORLD_EXTERNAL_PORT:-8085}:8085
      - ${SOAP_EXTERNAL_PORT:-7878}:7878
    volumes:
      - type: bind
        source: ./docker/worldserver/bin
        target: /azeroth-server/bin
      - type: bind
        source: ${WORLDSERVER_ETC:-./docker/worldserver/etc}
        target: /azeroth-server/etc
      - type: bind
        source: ${WORLDSERVER_LOGS:-./docker/worldserver/logs}
        target: /azeroth-server/logs
      - type: bind
        source: ${WORLDSERVER_DATA:-./docker/worldserver/data}
        target: /azeroth-server/data
    depends_on:
      - ac-database

  ac-authserver:
    image: azerothcore/authserver
    restart: unless-stopped
    build:
      context: ./docker/authserver
      dockerfile: Dockerfile
    networks:
      proxy:
        ipv4_address: 169.17.0.12
    ports:
      - ${AUTH_EXTERNAL_PORT:-3724}:3724
    volumes:
      - type: bind
        source: ./docker/authserver/bin
        target: /azeroth-server/bin
      - type: bind
        source: ${AUTHSERVER_ETC:-./docker/authserver/etc}
        target: /azeroth-server/etc
      - type: bind
        source: ${AUTHSERVER_LOGS:-./docker/authserver/logs}
        target: /azeroth-server/logs
    depends_on:
      - ac-database

volumes:
  ac-database:

networks:
  proxy:
    ipam:
      config:
      - subnet: 169.17.0.0/24

2.时区问题

如果因为时区问题,无法启动,参考如下修改

[root@localhost azerothcore-wotlk]# cat docker/authserver/Dockerfile
FROM ubuntu:20.04

# List of timezones: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones# set timezone environment variable
ENV TZ=Asia/Shanghai

# set noninteractive mode so tzdata doesn't ask to set timezone on install
ENV DEBIAN_FRONTEND=noninteractive

# install the required dependencies to run the authserver
RUN apt update &&aptinstall-y libmysqlclient-dev libssl-dev libace-6.4.5 libace-dev net-tools tzdata;# change timezone in container
RUN ln-snf /usr/share/zoneinfo/$TZ /etc/localtime &&echo$TZ> /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata

HEALTHCHECK --interval=5s --timeout=15s --start-period=30s --retries=1 CMD netstat-lnpt|grep :3724 ||exit1# run the authserver located in the directory "docker/authserver/bin" of the host machine
CMD ["/azeroth-server/bin/authserver"][root@localhost azerothcore-wotlk]# cat docker/database/Dockerfile
FROM alpine:3.9 as builder

# install bash
RUN apk add --no-cache bash# copy the sources from the host machine
COPY apps /azerothcore/apps
COPY bin /azerothcore/bin
COPY conf /azerothcore/conf
COPY data /azerothcore/data
COPY deps /azerothcore/deps
COPY acore.json /azerothcore/acore.json

# run the AzerothCore database assembler
RUN ./azerothcore/bin/acore-db-asm 1

FROM mysql:5.7

# List of timezones: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones# set timezone environment variable
ENV TZ=Asia/Shanghai

ENV LANG C.UTF-8

# copy files from the previous build stage - see: https://docs.docker.com/develop/develop-images/multistage-build/
COPY --from=builder /azerothcore/env/dist/sql /sql

# adding the "generate-databases.sh" to the directory "/docker-entrypoint-initdb.d"# because all scripts included in that directory will automatically be executed when the docker container starts
COPY docker/database/generate-databases.sh /docker-entrypoint-initdb.d

HEALTHCHECK --interval=5s --timeout=15s --start-period=30s --retries=1 CMD mysqladmin -uroot -p$MYSQL_ROOT_PASSWORDping-h localhost
[root@localhost azerothcore-wotlk]# cat docker/worldserver/Dockerfile
FROM ubuntu:20.04

# List of timezones: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones# set timezone environment variable
ENV TZ=Aisa/Shanghai

# set noninteractive mode so tzdata doesn't ask to set timezone on install
ENV DEBIAN_FRONTEND=noninteractive

# install the required dependencies to run the authserver
RUN apt update &&aptinstall-y libmysqlclient-dev libssl-dev libace-6.4.5 libace-dev libreadline-dev net-tools tzdata;# change timezone in container
RUN ln-snf /usr/share/zoneinfo/$TZ /etc/localtime &&echo$TZ> /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata

HEALTHCHECK --interval=5s --timeout=15s --start-period=30s --retries=1 CMD netstat-lnpt|grep :8085 ||exit1# run the worldserver located in the directory "docker/worldserver/bin" of the host machine
CMD ["/azeroth-server/bin/worldserver"]

1.3.4 数据库表修改

  1. 进入容器,连接数据库
[root@localhost azerothcore-wotlk]# docker exec -it azerothcore-wotlk_ac-database_1 bash
bash-4.2# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1416
Server version: 5.7.41 MySQL Community Server (GPL)

Copyright (c)2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.

mysql>
  1. 打开 acore_auth数据库, realmlist 数据表
mysql> use acore_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> show tables;
+----------------------+
| Tables_in_acore_auth |
+----------------------+
| account              || account_access       || account_banned       || account_muted        || autobroadcast        || ip2nation            || ip2nationCountries   || ip_banned            || logs                 || logs_ip_actions      || realmcharacters      || realmlist            ||uptime|| version_db_auth      |
+----------------------+
14 rows inset(0.00 sec)

mysql>select * from realmlist;
+----+-------------+---------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+
|id| name        | address       | localAddress | localSubnetMask | port | icon | flag | timezone | allowedSecurityLevel | population | gamebuild |
+----+-------------+---------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+
|1| AzerothCore |192.168.1.200 |127.0.0.1    |255.255.255.0   |1001|0|0|1|0|0|12340|
+----+-------------+---------------+--------------+-----------------+------+------+------+----------+----------------------+------------+-----------+
1 row inset(0.00 sec)
  1. address 修改为服务器ip或者域名,port 修改为 1001
update realmlist setaddress='192.168.1.200',port='1001';
  1. 重启服务器

1.4 游戏测试

1.4.1 创建GM账户

进入服务器容器,并创建gm账号

docker attach azerothcore-wotlk_ac-worldserver_1

account create admin 123456
account set gmlevel admin 3-1

创建完成,退出容器

1.4.2 客户端登录游戏

在客户端中,创建 login.bat 文件,并写入如下内容:

@echo y | rd /s "Cache"echo SET realmlist "192.168.1.200:1002"> realmlist.wtf
echo SET realmList "192.168.1.200:1002"> Data/zhCN/realmlist.wtf
echo SET realmList "192.168.1.200:1002"> Data/zhTW/realmlist.wtf
 
ren Data\commoo.MPQ common.MPQ
ren Data\expansioo.MPQ expansion.MPQ
start wow.exe
goto end
:end

1.5 GM指令

GM指令

ENJOR YOUR GAME!
在这里插入图片描述

标签: docker centos 运维

本文转载自: https://blog.csdn.net/u010230019/article/details/128876023
版权归原作者 壹只菜鸟 所有, 如有侵权,请联系我们删除。

“魔兽世界服务端AzerothCore+Centos系统+docker编译教程”的评论:

还没有评论