如何使用 docker 搭建饥荒专用服务器 以及安装mod 基于Mac版本
使用docker 搭建 饥荒服务器 并且 安装mod 基于Mac版本的饥荒
最近喜欢上玩饥荒刚好阿里云新账号可以免费使用3个月的ecs就想着搭建一个饥荒服务器以下是我的安装过程
- 购买ecs
我选择的是2c4G的通用型 ubuntu服务器 - 安装docker
安装流程查看
https://www.runoob.com/docker/centos-docker-install.html - 使用docker命令安装饥荒服务器
感谢Jamesits大佬开源的项目 饥荒服务端Docker Github地址
docker run --network=host -v ${HOME}/.klei/DoNotStarveTogether:/data -p 10999-11000:10999-11000/udp -p 12346-12347:12346-12347/udp -e "DST_SERVER_ARCH=amd64" -it jamesits/dst-server:latest
安装完成后会在 当前登录的用户目录下生成一个.klei/DoNotStarveTogether 的文件目录,第一次启动后缺少配置文件 所以需要先control+c退出容器
退出后登录到科雷的账号中心
科雷用户中心链接
选择顶部的菜单的游戏进入游戏中心创建饥荒的游戏服务器
添加新服务器
然后复制密钥到 我们阿里云的服务器 /root/.klei/DoNotStarveTogether/DoNotStarveTogether/Cluster_1/cluster_token.txt 文件中
cat 密钥 > /root/.klei/DoNotStarveTogether/DoNotStarveTogether/Cluster_1/cluster_token.txt
接着修改配置文件/root/.klei/DoNotStarveTogether/DoNotStarveTogether/Cluster_1/cluster.ini
; DO change the name and description please!
cluster_name = 房间名称
cluster_description = 房间描述
cluster_password = 房间密码
offline_cluster = false
lan_only_cluster = false
whitelist_slots = 1
cluster_intention = social
autosaver_enabled = true
;tick_rate = 30
[GAMEPLAY]
game_mode = survival 游戏模式
max_players = 3 允许多少人进入
pvp = false 是否开启玩家对战
pause_when_empty = true
vote_kick_enabled = false
[STEAM]
steam_group_only = false
steam_group_id = 0
steam_group_admins = false
[MISC]
console_enabled = true
max_snapshots = 6
; ====================================================================
; STOP! Don't change configs below unless you know what you are doing.
; ====================================================================
[SHARD]
shard_enabled = true
bind_ip = 127.0.0.1
master_ip = 127.0.0.1
master_port = 10998
修改 房间名称 密码
修改完成后执行
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
383d274eb52f jamesits/dst-server:latest "entrypoint.sh super…" 21 hours ago Up 19 hours (healthy) frosty_euclid
这里可以看到我们容器的id 启动容器
docker start 383d274eb52f
查看日志
docker logs -f 383d274eb52f
看到输出下面内容说明服务器启动成功了
[00:00:38]: Server registered via geo DNS in ap-southeast-1
[00:00:38]: Sim paused
[00:00:40]: About to start a shard with these settings:
[00:00:40]: ShardName: Caves
[00:00:40]: ShardID: 3202734046
[00:00:40]: ShardRole: SECONDARY
[00:00:40]: MasterHost: 127.0.0.1
[00:00:40]: MasterBind: (null)
[00:00:40]: MasterPort: 10998
2024-11-06 13:49:27,519 INFO success: dst-server-cave entered RUNNING state, process has stayed up for > than 40 seconds (startsecs)
2024-11-06 13:49:27,519 INFO success: dst-server-master entered RUNNING state, process has stayed up for > than 40 seconds (startsecs)
接下来就是打开饥荒搜索你刚刚的房间 刚启动服务器可能需要等一分钟
输入密码进入房间就能开始享受原汁原味的饥荒啦
ecs 安全组配置
饥荒MOD如何在服务器中使用
我是mac版本的饥荒所以我以mac为例子
- 首先在steam中订阅你想使用的mod
- 把在Mac 上的mod上传到服务器上
steam下载的mod路径在 /Users/你的用户名/Library/Application Support/Steam/steamapps/workshop/
把这个下面的所有文件都打包上传到服务器的/root/.klei/DoNotStarveTogether/ugc 路径下
然后在Mac打开饥荒新建一个世界把想使用的mod都选择好 生成世界
- 打开 Mac电脑的文稿文件夹
路径如下
/Users/用户名//Documents/Klei/
注意区分文件夹
复制这两个文件到 这个是地下世界的mod配置文件~/.klei/DoNotStarveTogether/DoNotStarveTogether/Cluster_1/Caves 下
复制这两个文件到 这个是地下世界的mod配置文件~/.klei/DoNotStarveTogether/DoNotStarveTogether/Cluster_1/Master 下
复制好后 执行
docker restart 容器ID
如果少复制了文件会导致地下世界或者地上世界崩溃