当前位置:   article > 正文

linux搭建饥荒服务器_linux饥荒搭服务器

linux饥荒搭服务器

系统环境

腾讯云CentOS 8


一、安装steamcmd

  1. 安装依赖

    # 用于支持64位系统运行32位的文件
    yum install glibc.i686
    
    • 1
    • 2
  2. 下载并运行

    mkdir /opt/steamcmd
    cd /opt/steamcmd
    # 下载 steamcmd
    wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
    # 解压 steamcmd
    tar -xvzf steamcmd_linux.tar.gz
    # 运行 steamcmd
    ./steamcmd.sh
    # 退出 steamcmd
    quit
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

二、安装开服程序

  1. 下载开服程序

    # 进入 steamcmd 的命令行
    ./steamcmd.sh
    # 设置安装目录为 /opt/dontstarve
    force_install_dir /opt/dontstarve
    # 匿名登录
    login anonymous
    # 下载开服软件
    app_update 343050 validate
    # 退出 steamcmd
    quit
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
  2. 安装依赖

    # 安装 curl
    yum install libcurl.i686
    cd /usr/lib
    ln -s libcurl.so.4 libcurl-gnutls.so.4
    
    # 安装 stdc++
    yum update -y libstdc++.x86_64
    yum install libstdc++.i686
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
  3. 启动

    cd /opt/dontstarve
    ./bin/dontstarve_dedicated_server_nullrenderer
    
    • 1
    • 2

    启动应该是失败了,因为缺少配置,但是没关系,继续看下一条。


三、配置

  1. 创建目录

    首先为房间创建一个目录,这个房间内的所有配置都在这个目录下。

    mkdir /opt/dontstarve/config
    mkdir /opt/dontstarve/config/Clusters
    mkdir /opt/dontstarve/config/Clusters/Cluster_1
    cd /opt/dontstarve/config/Clusters/Cluster_1
    
    • 1
    • 2
    • 3
    • 4
  2. token配置

    先从官网获取token,流程如下:进入游戏,点击账号,点击上方导航栏游戏,点击饥荒联机版的游戏服务器,输入集群名,点击添加新服务器,然后就能看到新生成的token了。回到服务器,执行以下命令。

    cd /opt/dontstarve/config/Clusters/Cluster_1
    vim cluster_token.txt
    
    • 1
    • 2

    将token粘贴到这个文件中,保存并关闭文件。

  3. 服务器配置

    cd /opt/dontstarve/config/Clusters/Cluster_1
    vim cluster.ini
    
    • 1
    • 2

    添加以下内容,汉字部分需要根据含义修改,配置的解释见附录

    [GAMEPLAY]
    game_mode = survival
    max_players = 6
    pvp = false
    pause_when_empty = true
    
    [NETWORK]
    cluster_description = 服务器描述
    cluster_name = 服务器名称,根据这个名称在游戏中搜索和加入
    cluster_intention = cooperative
    cluster_password = 服务器密码
    
    [MISC]
    console_enabled = true
    
    [SHARD]
    shard_enabled = true
    bind_ip = 127.0.0.1
    master_ip = 127.0.0.1
    master_port = 10889
    cluster_key = supersecretkey
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
  4. 管理员配置(可选)

    先从官网获取用户ID,流程如下:进入游戏,点击账户信息,左上角能看到KLEI用户ID。回到服务器,执行以下命令。

    cd /opt/dontstarve/config/Clusters/Cluster_1
    vim adminlist.txt
    
    • 1
    • 2

    将用户ID粘贴到文件中,每行可以放一个ID,房间创建者默认就是管理员,不需要再添加了。

  5. 主地图配置

    创建主地图目录

    cd /opt/dontstarve/config/Clusters/Cluster_1
    mkdir Master
    cd Master
    
    • 1
    • 2
    • 3

    创建主地图服务器配置

    vim server.ini
    
    • 1

    添加以下内容

    [NETWORK]
    server_port = 10898
    
    [SHARD]
    is_master = true
    
    [STEAM]
    master_server_port = 27018
    authentication_port = 8768
    
    [ACCOUNT]
    encode_user_path = true
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    创建主地图世界配置

    vim worldgenoverride.lua
    
    • 1

    输入以下内容

    return {
        override_enabled = true,
        preset = "SURVIVAL_TOGETHER",
        misc = {
            world_size = "huge"
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
  6. 洞穴配置(可选)

    创建洞穴目录

    cd /opt/dontstarve/config/Clusters/Cluster_1
    mkdir Caves
    cd Caves
    
    • 1
    • 2
    • 3

    创建洞穴服务器配置

    vim server.ini
    
    • 1

    添加以下内容

    [NETWORK]
    server_port = 10899
    
    [SHARD]
    is_master = false
    name = Caves
    id = 1811570792
    
    [STEAM]
    master_server_port = 27019
    authentication_port = 8769
    
    [ACCOUNT]
    encode_user_path = true
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    创建洞穴世界配置

    vim worldgenoverride.lua
    
    • 1

    输入以下内容

    return {
        override_enabled = true,
        preset = "DST_CAVE",
        misc = {
            world_size = "huge"
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

四、后台运行

  1. 安装 screen

    yum install epel-release
    yum install screen
    
    • 1
    • 2
  2. 启动主地图

    编写启动脚本

    cd /opt/dontstarve/config/Clusters/Cluster_1
    vim start_master.sh
    
    • 1
    • 2

    添加以下内容

    #!/bin/sh
    
    home=/opt/dontstarve
    storage=$home/config
    clusters=Clusters
    cluster=Cluster_1
    shard=Master
    
    command='./dontstarve_dedicated_server_nullrenderer'
    command="$command -console"
    command="$command -persistent_storage_root $storage"
    command="$command -conf_dir $clusters"
    command="$command -cluster $cluster"
    command="$command -shard $shard"
    
    cd $home/bin
    /usr/bin/screen -S "dstmaster" /bin/sh -c "$command"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    执行脚本,启动服务器

    sh start_master.sh
    
    • 1

    启动完成后,就可以在客户端搜索到了。按ctrl + A,然后按D,退出此窗口,服务会继续在后台运行。输入screen -r dstmaster可以回到此窗口。

  3. 启动洞穴(可选)

    编写启动脚本

    cd /opt/dontstarve/config/Clusters/Cluster_1
    vim start_caves.sh
    
    • 1
    • 2

    添加以下内容

    #!/bin/sh
    
    home=/opt/dontstarve
    storage=$home/config
    clusters=Clusters
    cluster=Cluster_1
    shard=Caves
    
    command='./dontstarve_dedicated_server_nullrenderer'
    command="$command -console"
    command="$command -persistent_storage_root $storage"
    command="$command -conf_dir $clusters"
    command="$command -cluster $cluster"
    command="$command -shard $shard"
    
    cd $home/bin
    /usr/bin/screen -S "dstcaves" /bin/sh -c "$command"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    执行脚本,启动服务器

    sh start_caves.sh
    
    • 1

    按ctrl + A,然后按D,退出此窗口,服务会继续在后台运行。输入screen -r dstcaves可以回到此窗口。


五、更新

如果服务器版本较低,可能会导致启动失败或无法加入房间,这时候需要更新服务器到最新版本。需要已经按照第一步安装过steamcmd。

cd /opt/dontstarve
vim update_dst.sh
  • 1
  • 2

添加以下内容

#!/bin/sh

/opt/steamcmd/steamcmd.sh +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +login anonymous +force_install_dir /opt/dontstarve +app_update 343050 validate +quit

/opt/dontstarve/bin/dontstarve_dedicated_server_nullrenderer -only_update_server_mods
  • 1
  • 2
  • 3
  • 4
  • 5

添加可执行权限

chmod +x update_dst.sh
  • 1

执行脚本

./update_dst.sh
  • 1

六、mod

暂时用不到,以后如果用到再写。


七、附录

  1. settings.ini

    [GAMEPLAY]
    game_mode = endless | survival | wilderness
    max_players = 6 [1 - 64]
    pvp = true | false
    ;When the dedicated server is empty, pause the simulation. This is especially useful for private dedicated servers, when a GSA wants to resume where they left off with a group of friends. Defaults to false.
    pause_when_empty = true | false
    
    [NETWORK]
    cluster_description = A very nice server description
    cluster_name = A unique server name
    cluster_intention = cooperative | social | competitive | madness
    cluster_password = password
    
    [MISC]
    ;Snapshots allow GSAs the ability to fully roll back a server to an older state.  This feature is pretty new and has been observed to cause problems on some servers.
    max_snapshots = 6
    console_enabled = true | false
    
    [SHARD]
    shard_enabled = true | false
    bind_ip = 127.0.0.1
    master_ip = 127.0.0.1
    master_port = 10889
    cluster_key = supersecretkey
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
  2. worldgenoverride.lua

    return {
     
     override_enabled = true,
           unprepared = { -- "never", "rare", "default", "often", "always"
                   berrybush = "default",
                   cactus = "default",
                   carrot = "default",
                   mushroom = "default",
           },
           misc = {
                   task_set = "default", -- Biomes: "classic", "cave_default"
                   start_location = "default", -- Start: "plus", "darkness", "caves"
                   autumn = "default", -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random"
                   boons = "default", -- "never", "rare", "default", "often", "always"
                   branching = "default", -- "never", "least", "default", "most"
                   day = "default", -- "default", "longday", "longdusk", "longnight", "noday", "nodusk", "nonight", "onlyday", "onlydusk", "onlynight"
                   frograin = "default", -- "never", "rare", "default", "often", "always"
                   lightning = "default", -- "never", "rare", "default", "often", "always"
                   loop = "default", -- "never", "default", "always"
                   season_start = "default", -- "default", "winter", "spring", "summer", "random"
                   spring = "default", -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random"
                   summer = "default", -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random"
                   touchstone = "default", -- "never", "rare", "default", "often", "always"
                   weather = "default", -- "never", "rare", "default", "often", "always"
                   wildfires = "default", -- "never", "rare", "default", "often", "always"
                   winter = "default", -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random"
                   world_size = "default", -- "default", "medium", "large", "huge"
           },
           animals = { -- "never", "rare", "default", "often", "always"
                   alternatehunt = "default",
                   angrybees = "default",
                   beefalo = "default",
                   beefaloheat = "default",
                   bees = "default",
                   birds = "default",
                   butterfly = "default",
                   buzzard = "default",
                   catcoon = "default",
                   frogs = "default",
                   hunt = "default",
                   lightninggoat = "default",
                   moles = "default",
                   penguins = "default",
                   perd = "default",
                   pigs = "default",
                   rabbits = "default",
                   tallbirds = "default",
           },
           monsters = { -- "never", "rare", "default", "often", "always"
                   bearger = "default",
                   chess = "default",
                   deciduousmonster = "default",
                   deerclops = "default",
                   dragonfly = "default",
                   goosemoose = "default",
                   houndmound = "default",
                   hounds = "default",
                   krampus = "default",
                   liefs = "default",
                   lureplants = "default",
                   merm = "default",
                   spiders = "default",
                   tentacles = "default",
                   walrus = "default",
           },
           resources = { -- "never", "rare", "default", "often", "always"
                   flint = "default",
                   flowers = "default",
                   grass = "default",
                   marshbush = "default",
                   meteorshowers = "default",
                   meteorspawner = "default",
                   reeds = "default",
                   rock = "default",
                   rock_ice = "default",
                   sapling = "default",
                   trees = "default",
                   tumbleweed = "default",
           },
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
  3. Command Line Options

    Command line options override settings.ini options.

    Force the server to use a specific port

    -port [1024 .. 65535]
    
    • 1

    Force the server to run at a specific tick rate

    -tick [15 .. 60]
    
    • 1

    Force the maximum number of players allowed in the server.

    -players [1 .. 64]
    
    • 1

    Enable a command line console input mechanism. Allows GSAs to execute privileged lua directly in the server window.

    -console
    
    • 1

    Force the server into lan mode. The server will not require token authentication, and will not appear in the server listings. Only users on the same network will be able to join.

    -lan
    
    • 1

    Force the server to load save and settings data from an alternative directory. Note that this is the directoryname, not the path. For example, a directory name of DoNotStarveServerDirectory would translate into a path of ~/.klei/DoNotStarveServerDirectory.

    -conf_dir DoNotStarveServerDirectory
    
    • 1

    Setting the root directory of persistent storage. E.g. on Windows this defaults to the current user documents folder / klei. This is used in conjunction with conf_dir to generate the path where files are stored.

    -persistent_storage_root <AltPersistentStorageRoot>
    
    • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/164972?site
推荐阅读
相关标签
  

闽ICP备14008679号