Steam饥荒专属服务器

作者:zhangyunlong 发布时间: 2025-09-07 阅读量:2 评论数:0

0. 服务器准备

推荐: 2核4G3M, 不要求公网IP

  • CPU: 饥荒属于单核游戏, CPU主频越高越好, 推荐2.5GHz

  • 内存: 地上世界和洞穴属于不同的进程, 如果需要开洞穴, 最少需要2G内存

  • 带宽: 1M带宽可满足1-3人联机, 3M带宽满足3-6人联机

  • OS: Centos7或者Ubuntu18

本示例使用的服务器信息: Centos7, 2核2G,3M

本示例创建的房间信息: 仅地上世界, 5个mod

本示例创建的房间空载时服务器负载如下:

top - 14:18:13 up 443 days,  3:02,  1 user,  load average: 0.44, 0.28, 0.24
Tasks:  86 total,   2 running,  84 sleeping,   0 stopped,   0 zombie
%Cpu(s):  8.1 us,  2.5 sy,  0.0 ni, 89.4 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1798504 total,    78576 free,  1093596 used,   626332 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   546184 avail Mem 
​
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                        
 6824 root      20   0 1037984 907100  20528 R  15.2 50.4   3:17.97 dontstarve_dedi       

1. 安装环境

[root@iZf8z3zcbp57dpq4pdo4e7Z ~]# yum install -y glibc.i686 libstdc++.i686 libcurl.i686 screen wget tar libcurl-gnutls.so.4
已加载插件:fastestmirror
Determining fastest mirrors
base                                                                                                                                                        | 3.6 kB  00:00:00     
epel                                                                                                                                                        | 4.3 kB  00:00:00     
extras                                                                                                                                                      | 2.9 kB  00:00:00     
updates                                                                                                                                                     | 2.9 kB  00:00:00     
软件包 wget-1.14-18.el7_6.1.x86_64 已安装并且是最新版本
软件包 2:tar-1.26-35.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
...
已安装:
  glibc.i686 0:2.17-326.el7_9.3         libcurl.i686 0:7.29.0-59.el7_9.2         libstdc++.i686 0:4.8.5-44.el7         screen.x86_64 0:4.1.0-0.27.20120314git3c2946.el7_9        
​
作为依赖被安装:
  cyrus-sasl-lib.i686 0:2.1.26-24.el7_9           keyutils-libs.i686 0:1.5.8-3.el7        krb5-libs.i686 0:1.15.1-55.el7_9        libcom_err.i686 0:1.42.9-19.el7                 
  libdb.i686 0:5.3.21-25.el7                      libgcc.i686 0:4.8.5-44.el7              libidn.i686 0:1.28-4.el7                libselinux.i686 0:2.5-15.el7                    
  libsepol.i686 0:2.5-10.el7                      libssh2.i686 0:1.8.0-4.el7_9.1          libverto.i686 0:0.2.5-4.el7             ncurses-libs.i686 0:5.9-14.20130511.el7_4       
  nspr.i686 0:4.35.0-1.el7_9                      nss.i686 0:3.90.0-2.el7_9               nss-pem.i686 0:1.0.3-7.el7_9.1          nss-softokn.i686 0:3.90.0-6.el7_9               
  nss-softokn-freebl.i686 0:3.90.0-6.el7_9        nss-util.i686 0:3.90.0-1.el7_9          openldap.i686 0:2.4.44-25.el7_9         openssl-libs.i686 1:1.0.2k-26.el7_9             
  pcre.i686 0:8.32-17.el7                         readline.i686 0:6.2-11.el7              sqlite.i686 0:3.7.17-8.el7_7.1          zlib.i686 0:1.2.7-21.el7_9                      
​
作为依赖被升级:
  glibc.x86_64 0:2.17-326.el7_9.3        glibc-common.x86_64 0:2.17-326.el7_9.3        glibc-devel.x86_64 0:2.17-326.el7_9.3        glibc-headers.x86_64 0:2.17-326.el7_9.3       
  nscd.x86_64 0:2.17-326.el7_9.3        
​
完毕!
[root@iZf8z3zcbp57dpq4pdo4e7Z ~]# 

2. 下载安装Steam客户端

创建steamcmd目录

[root@iZf8z3zcbp57dpq4pdo4e7Z ~]# mkdir /opt/steamcmd && cd /opt/steamcmd
[root@iZf8z3zcbp57dpq4pdo4e7Z steamcmd]#

下载SteamCMD的安装器

崇明岛[root@iZf8z3zcbp57dpq4pdo4e7Z steamcmd]# wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
--2025-08-27 16:09:31--  https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
正在解析主机 steamcdn-a.akamaihd.net (steamcdn-a.akamaihd.net)... 92.122.244.11, 92.122.244.40
正在连接 steamcdn-a.akamaihd.net (steamcdn-a.akamaihd.net)|92.122.244.11|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2428561 (2.3M) [application/octet-stream]
正在保存至: “steamcmd_linux.tar.gz”
​
100%[=========================================================================================================================================>] 2,428,561   1.12MB/s 用时 2.1s   
​
2025-08-27 16:09:36 (1.12 MB/s) - 已保存 “steamcmd_linux.tar.gz” [2428561/2428561])
[root@iZf8z3zcbp57dpq4pdo4e7Z steamcmd]# tar -xvzf steamcmd_linux.tar.gz
steamcmd.sh
linux32/steamcmd
linux32/steamerrorreporter
linux32/libstdc++.so.6
linux32/crashhandler.so
[root@iZf8z3zcbp57dpq4pdo4e7Z steamcmd]# ll
总用量 2380
drwxr-xr-x 2 root root    4096 8月  27 16:09 linux32
-rw-r--r-- 1 root root 2428561 1月   5 2018 steamcmd_linux.tar.gz
-rwxrw-r-- 1 5020 5020    1166 1月   5 2018 steamcmd.sh
[root@iZf8z3zcbp57dpq4pdo4e7Z steamcmd]#

安装SteamCMD

[root@iZf8z3zcbp57dpq4pdo4e7Z steamcmd]# ./steamcmd.sh
Redirecting stderr to '/root/Steam/logs/stderr.txt'
ILocalize::AddFile() failed to load file "public/steambootstrapper_english.txt".
[  0%] Checking for available update...
[----] Downloading update (0 of 52,378 KB)...
[  1%] Downloading update (1,113 of 52,378 KB)...
...
[ 99%] Downloading update (52,378 of 52,378 KB)...
[100%] Download Complete.
[----] Applying update...
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Extracting package...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Installing update...
[----] Cleaning up...
[----] Update complete, launching...
Redirecting stderr to '/root/Steam/logs/stderr.txt'
Logging directory: '/root/Steam/logs'
[  0%] Checking for available updates...
[----] Verifying installation...
UpdateUI: skip show logo
Steam Console Client (c) Valve Corporation - version 1751406682
-- type 'quit' to exit --
Loading Steam API...OK
Steam>^C
[root@iZf8z3zcbp57dpq4pdo4e7Z steamcmd]# 

3. 安装DST联机版

[root@iZf8z3zcbp57dpq4pdo4e7Z steamcmd]# ./steamcmd.sh +login anonymous +force_install_dir ./dst_server +app_update 343050 validate +quit
Redirecting stderr to '/root/Steam/logs/stderr.txt'
Logging directory: '/root/Steam/logs'
Looks like steam didn't shutdown cleanly, scheduling immediate update check
[  0%] Checking for available updates...
[----] Verifying installation...
UpdateUI: skip show logo
Steam Console Client (c) Valve Corporation - version 1751406682
-- type 'quit' to exit --
Loading Steam API...IPC function call IClientUtils::GetSteamRealm took too long: 42 msec
OK
​
Connecting anonymously to Steam Public...OK
Waiting for client config...OK
Waiting for user info...OK
Please use force_install_dir before logon!
 Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
 Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
 Update state (0x11) preallocating, progress: 27.56 (1164951365 / 4226199465)
 Update state (0x61) downloading, progress: 0.39 (16499168 / 4226199465)
...
 Update state (0x61) downloading, progress: 99.93 (4223048171 / 4226199465)
 Update state (0x81) verifying update, progress: 0.32 (13631488 / 4226199465)
 Update state (0x81) verifying update, progress: 8.73 (368869020 / 4226199465)
 Update state (0x81) verifying update, progress: 14.24 (601840061 / 4226199465)
 Update state (0x81) verifying update, progress: 20.11 (849726836 / 4226199465)
 Update state (0x81) verifying update, progress: 26.16 (1105515598 / 4226199465)
 Update state (0x81) verifying update, progress: 32.47 (1372157056 / 4226199465)
 Update state (0x81) verifying update, progress: 38.09 (1609849216 / 4226199465)
 Update state (0x81) verifying update, progress: 43.53 (1839847340 / 4226199465)
 Update state (0x81) verifying update, progress: 48.75 (2060324601 / 4226199465)
 Update state (0x101) committing, progress: 17.89 (755942931 / 4226199465)
 Update state (0x101) committing, progress: 26.94 (1138612491 / 4226199465)
 Update state (0x101) committing, progress: 37.99 (1605741794 / 4226199465)
IPC function call IClientAppManager::GetUpdateInfo took too long: 62 msec
Success! App '343050' fully installed.
Unloading Steam API...OK
[root@iZf8z3zcbp57dpq4pdo4e7Z steamcmd]# 

4. 配置世界存档

  1. 使用其他电脑登陆饥荒账号, 创建房间, 配置服务器mod, 确保可以进入到选择人物界面后退出游戏

  2. 找到存档目录:

  • Linux: ~/.klei/DoNotStarveTogether

  • Windows: Documents/Klei/DoNotStarveTogether

  1. 创建房间后存档目录下会出现新的目录(例如Cluster_1), 将此目录拷贝到服务器的指定目录下

    [root@iZf8z3zcbp57dpq4pdo4e7Z DoNotStarveTogether]# pwd
    /root/.klei/DoNotStarveTogether
    [root@iZf8z3zcbp57dpq4pdo4e7Z DoNotStarveTogether]# ls -lhra
    总用量 12K
    drwxrwxrwx 3 root root 4.0K 8月  27 20:52 Cluster_1
    drwxr-xr-x 4 root root 4.0K 8月  27 20:45 ..
    drwxr-xr-x 3 root root 4.0K 8月  27 20:52 .
    [root@iZf8z3zcbp57dpq4pdo4e7Z DoNotStarveTogether]# 

5. 账号令牌

  1. 使用其他电脑登陆饥荒账号, 通过资料页获取认证令牌

  2. 在指定目录下创建cluster_token.txt文件, 将令牌写入文件中

    [root@iZf8z3zcbp57dpq4pdo4e7Z Cluster_1]# pwd
    /root/.klei/DoNotStarveTogether/Cluster_1
    [root@iZf8z3zcbp57dpq4pdo4e7Z Cluster_1]# ls -lhra
    总用量 20K
    drwxrwxrwx 4 root root 4.0K 8月  28 09:40 Master
    -rw-r--r-- 1 root root   63 8月  27 20:48 cluster_token.txt
    -rw-rw-rw- 1 root root  469 8月  27 19:56 cluster.ini
    drwxr-xr-x 3 root root 4.0K 8月  27 20:52 ..
    drwxrwxrwx 3 root root 4.0K 8月  27 20:52 .
    [root@iZf8z3zcbp57dpq4pdo4e7Z Cluster_1]# 

6. 配置mod

  1. 查看mod配置文件内容(modoverrides.lua), 记录每个mod编号备用(例如["workshop-3365508467"]其中编号为3365508467)

    [root@iZf8z3zcbp57dpq4pdo4e7Z Master]# pwd
    /root/.klei/DoNotStarveTogether/Cluster_1/Master
    [root@iZf8z3zcbp57dpq4pdo4e7Z Master]# ls -lhra
    总用量 580K
    -rw-r--r-- 1 root root 540K 8月  29 13:16 server_log.txt
    -rw-rw-rw- 1 root root   93 8月  27 21:12 server.ini
    -rw-r--r-- 1 root root 2.1K 8月  29 00:19 server_chat_log.txt
    drwxrwxrwx 8 root root 4.0K 8月  27 20:53 save
    -rw-rw-rw- 1 root root 2.2K 8月  27 19:56 modoverrides.lua
    -rw-rw-rw- 1 root root 6.0K 8月  27 19:56 leveldataoverride.lua
    drwxr-xr-x 4 root root 4.0K 8月  27 20:45 backup
    drwxrwxrwx 3 root root 4.0K 8月  27 20:52 ..
    drwxrwxrwx 4 root root 4.0K 8月  28 09:40 .
    [root@iZf8z3zcbp57dpq4pdo4e7Z Master]#
  2. 编辑指定文件(dedicated_server_mods_setup.lua), 写入上一步记录的每个mod编号, 格式如示例

    [root@iZf8z3zcbp57dpq4pdo4e7Z dst_server]# mkdir -p /opt/steamcmd/dst_server/data/mods
    [root@iZf8z3zcbp57dpq4pdo4e7Z dst_server]# mkdir -p /opt/steamcmd/dst_server/ugc_mods
    [root@iZf8z3zcbp57dpq4pdo4e7Z dst_server]# chown -R $(whoami):$(whoami) /opt/steamcmd/dst_server/data
    [root@iZf8z3zcbp57dpq4pdo4e7Z dst_server]# chown -R $(whoami):$(whoami) /opt/steamcmd/dst_server/ugc_mods
    [root@iZf8z3zcbp57dpq4pdo4e7Z dst_server]# cd mods
    [root@iZf8z3zcbp57dpq4pdo4e7Z mods]# pwd
    /opt/steamcmd/dst_server/mods
    [root@iZf8z3zcbp57dpq4pdo4e7Z mods]# ls -lhra
    总用量 32K
    drwxr-xr-x  3 root root 4.0K 8月  27 20:45 workshop-786556008
    drwxr-xr-x  3 root root 4.0K 8月  27 20:45 workshop-458587300
    -rwxr-xr-x  1 root root  819 8月  27 16:28 modsettings.lua
    -rwxr-xr-x  1 root root  466 8月  27 16:28 MAKING_MODS.txt
    -rwxr-xr-x  1 root root  272 8月  27 16:28 INSTALLING_MODS.txt
    -rwxr-xr-x  1 root root 1.1K 8月  27 20:40 dedicated_server_mods_setup.lua
    drwxr-xr-x 10 root root 4.0K 8月  27 21:15 ..
    drwxr-xr-x  4 root root 4.0K 8月  27 20:45 .
    [root@iZf8z3zcbp57dpq4pdo4e7Z mods]# cat dedicated_server_mods_setup.lua
    ServerModSetup("3365508467")
    ServerModSetup("378160973")
    ServerModSetup("458587300")
    ServerModSetup("623749604")
    ServerModSetup("786556008")
    [root@iZf8z3zcbp57dpq4pdo4e7Z mods]# 

7. 配置放行策略

  1. 去云服务器控制台-安全组放行10800到12000范围端口, 协议选择udp

  2. 防火墙放行10800到12000范围端口, 或者停用防火墙

8. 编写启停脚本

  • 创建启动脚本/opt/steamcmd/dst_server/start_dst.sh, 写入以下内容

    #!/bin/bash
    # Don't Starve Together Dedicated Server 启动脚本
    ​
    DST_HOME="/opt/steamcmd/dst_server"
    BIN_DIR="$DST_HOME/bin"
    CLUSTER_NAME="Cluster_1"
    ​
    # 切换到 DST bin 目录执行
    cd "$BIN_DIR" || exit 1
    ​
    # 启动地上世界
    screen -dmS DST_Master ./dontstarve_dedicated_server_nullrenderer \
        -console -cluster "$CLUSTER_NAME" -shard Master
    ​
    # 启动洞穴(如果没有, 可注释掉)
    #if [ -d "/root/.klei/DoNotStarveTogether/$CLUSTER_NAME/Caves" ]; then
    #    screen -dmS DST_Caves ./dontstarve_dedicated_server_nullrenderer \
    #        -console -cluster "$CLUSTER_NAME" -shard Caves
    #fi
    ​
    echo "DST 服务器已启动 (Cluster: $CLUSTER_NAME)"
    echo "查看地上世界: screen -r DST_Master"
    #echo "查看洞穴 : screen -r DST_Caves"
  • 创建停止脚本/opt/steamcmd/dst_server/stop_dst.sh, 写入以下内容

    #!/bin/bash
    ​
    # 关闭地上世界
    if screen -list | grep -q "DST_Master"; then
        screen -S DST_Master -X quit
        echo "已停止地上世界服务器"
    else
        echo "地上世界未运行"
    fi
    ​
    # 关闭洞穴
    if screen -list | grep -q "DST_Caves"; then
        screen -S DST_Caves -X quit
        echo "已停止洞穴服务器"
    else
        echo "洞穴未运行"
    fi

9. 启动世界

[root@iZf8z3zcbp57dpq4pdo4e7Z dst_server]# pwd
/opt/steamcmd/dst_server
[root@iZf8z3zcbp57dpq4pdo4e7Z dst_server]# sh start_dst.sh 
DST 服务器已启动 (Cluster: Cluster_1)
查看 Master: screen -r DST_Master
[root@iZf8z3zcbp57dpq4pdo4e7Z dst_server]# screen -r DST_Master
...
[00:00:45]: Check for read access: TRUE
[00:00:45]: Available disk space for save files: 17291 MB
[00:00:45]: ModIndex: Load sequence finished successfully.      
[00:00:45]: Reset() returning
[00:00:46]: Validating portal[10] <-> <nil>[10] (inactive)      
[00:00:46]: Validating portal[2] <-> <nil>[2] (inactive)        
[00:00:46]: Validating portal[1] <-> <nil>[1] (inactive)        
[00:00:46]: Validating portal[3] <-> <nil>[3] (inactive)        
[00:00:46]: Validating portal[4] <-> <nil>[4] (inactive)        
[00:00:46]: Validating portal[7] <-> <nil>[7] (inactive)        
[00:00:46]: Validating portal[8] <-> <nil>[8] (inactive)        
[00:00:46]: Validating portal[5] <-> <nil>[5] (inactive)        
[00:00:46]: Validating portal[6] <-> <nil>[6] (inactive)        
[00:00:46]: Validating portal[9] <-> <nil>[9] (inactive)        
[00:00:46]: Server registered via geo DNS in ap-southeast-1
[00:00:46]: Sim paused

当看到启动日志结尾出现Sim paused, 说明服务器启动成功, 此时使用Ctrl+A然后按D保持后台运行即可

10. 后续添加mod

  • 先从其他客户端创建房间, 选择mod后, 获取到mod配置

  • 将mod配置同步更新到此文件中

    vim /root/.klei/DoNotStarveTogether/Cluster_1/Master/modoverrides.lua
    # 例如新增一个mod, 在此文件中添加一对配置, 注意格式, 每个mod之间有逗号间隔
      ["workshop-2771698903"]={
        configuration_options={
          MOD_RESTART_ALLOW_KILL=true,
          MOD_RESTART_ALLOW_RESTART=true,
          MOD_RESTART_ALLOW_RESURRECT=true,
          MOD_RESTART_CD_BONUS=0,
          MOD_RESTART_CD_KILL=0,
          MOD_RESTART_CD_MAX=0,
          MOD_RESTART_CD_RESTART=0,
          MOD_RESTART_CD_RESURRECT=0,
          MOD_RESTART_FORCE_DROP_MODE=1,
          MOD_RESTART_IGNORING_ADMIN=true,
          MOD_RESTART_MAP_SAVE=1,
          MOD_RESTART_RESURRECT_HEALTH=100,
          MOD_RESTART_TRIGGER_MODE=1,
          MOD_RESTART_WELCOME_TIPS=true,
          MOD_RESTART_WELCOME_TIPS_TIME=10
        },
        enabled=true
      }
    ​
  • 更新dedicated_server_mods_setup.lua配置

    vim /opt/steamcmd/dst_server/mods/dedicated_server_mods_setup.lua
    # 添加mod唯一id
    ServerModSetup("2771698903")
  • 更换和删除mod同理

11. 存档

所有世界数据都保存在/root/.klei/DoNotStarveTogether/Cluster_1, 备份整个目录即可

为避免存档损坏, 建议先停服, 再备份

评论