饥荒联机版-Centos7-阿里云服务器-搭建

参考博客:

steamCMD

steam社区教程

ttionya

ttionya

HoPGoldy

服务器替换存档linux下steamcmd和饥荒配置

本文使用centos 7.7版本作为案例

一、服务器相关依赖的安装与配置

这里先简单说一下Linux不同发行版本的区别:常用的个人linux系统一般使用ubuntu,为debian系列的linux发行版本;deepin这种为国产系统(不予讨论);本文使用的centos为red-hat系列的linux发行版本。在搭建服务器的过程中,主要的区别就在于安装各种依赖和包的方式不同,ubuntu 一般是apt-get install; sudo apt-get install等等。 centos 一般为yum install; yum remove 等等。并且各种包的依赖管理不一致,有些包在ubuntu上可以直接install,但是使用Yum就找不到,这个时候就需要手动进行安装。但是一般可以根据官方文档的提示进行安装。废话太多,进入主要环节。

1、阿里云服务器的购买、选型、安装

这一步骤自行百度,一般阿里云服务器购买有两种,ECS服务器(弹性计算)和轻量应用服务器,两者区别不大,前者带宽只有1M,后者带宽有5M,建议选后者(我用的是ECS,感觉还行,也不是很卡,偶尔有点网络波动)。PS:25岁以下自动视为学生,享受学生优惠,10元/月,就很划算。

搭建好之后,下载安装Xshell破解版,愿意折腾的可以连带着下一个ftp用于服务器与本机的文件传输。

2、相关依赖安装

这里默认你已经购买并启动了阿里云服务器,使用xshell连接你的服务器,然后使用账号密码进行登录。

首先进行相关依赖的安装:

useradd -m dst
cd /home/dst
yum -y install glibc.i686 libstdc++.i686 screen libcurl.i686 lrzsz

3、steam命令以及饥荒服务器的安装

参考steamCMD,新建专门用于服务器的用户,并在该用户目录下面进行相关文件的配置。

mkdir ~/steamcmd
cd ~/steamcmd
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz
./steamcmd.sh +login anonymous +force_install_dir ~/dst +app_update 343050 validate +quit

这一步里面,在wget的时候可能会出错,因为阿里云无法访问steam的网址,这里需要在本机自己下载网址中的文件,然后使用rz命令将文件上传到服务器

cd ~/steamcmd
rz
# rz之后会打开一个窗口,选择你下载好的文件进行上传,这一步用于代替上个代码中的wget那一行

然后检查是否缺乏相关依赖

cd ~/dst/bin
ldd dontstarve_dedicated_server_nullrenderer
./dontstarve_dedicated_server_nullrenderer

如果有错误,可以参考ttionya的博客

/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found
#一般是因为安装的C运行库版本过低导致的,比如说CentOS从YUM源中安装的仅支持GLIBCXX到3.4.13
#所幸SteamCMD中也需要该动态链接库,并且自带了该动态链接库,只需要拷贝至DST文件夹中即可
cp ~/steamcmd/linux32/libstdc++.so.6 ~/dst/bin/lib32/
 
/lib/libc.so.6: version `GLIBC_2.15' not found
#一般是因为安装的glibc版本过低导致的,比如说CentOS从YUM源中安装的仅有2.12版本
#从Klei官方提供的链接下载与glibc相关的3个文件,Debian系也是这样解决
cd ~/dst/bin/lib32/
wget https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/libc.so.6
wget https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/libpthread.so.0
wget https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/librt.so.1
 
error while loading shared libraries: libcurl-gnutls.so.4: cannot open shared object file: No such file or directory
#这是因为系统没有搜索到该文件
#使用cp方法运行时会出现./lib32/libcurl-gnutls.so.4: no version information available警告,无视之~
sudo apt-get install libcurl4-gnutls-dev:i386 #Debian系
cp /usr/lib/libcurl.so.4 ~/dst/bin/lib32/libcurl-gnutls.so.4 #RedHat系,Debian系未测试该方法是否可行
 
#博主只遇到了这几个错误,其他错误就不是很清楚了= =

4、创建用于配置服务器的脚本文件

cd ~/dst/bin/
echo ./dontstarve_dedicated_server_nullrenderer -console -cluster MyDediServer -shard Master > dst_overworld.sh
echo ./dontstarve_dedicated_server_nullrenderer -console -cluster MyDediServer -shard Caves > dst_caves.sh
sh dst_overworld.sh
#待出现Your Server Will Not Start后,按Ctrl+C终止进程(没有什么是靠Ctrl+C不能解决的,如果一下不行,那就两下)
sh dst_caves.sh
#待出现Your Server Will Not Start后,按Ctrl+C终止进程(没有什么是靠Ctrl+C不能解决的,如果一下不行,那就两下)
 
rm -rf ~/.klei/DoNotStarveTogether/Cluster_*
#删除之前创建的默认文件

在 ~/.klei/DoNotStarveTogether/ 中就生成了一个 DediServer 文件夹,该文件夹下有名为 Master 和 Caves 的两个子文件夹,这两个文件夹分别是地上和洞穴的配置目录。

当饥荒升级之后,需要重新运行下列代码进行升级:

~/steamcmd/steamcmd.sh +login anonymous +force_install_dir ~/dst +app_update 343050 validate +quit
#注意这就是之前安装的命令,如果有修改路径的话,记得用实际路径哟

二、服务器的配置

先说下服务器配置的相关文件和路径,主要用到的是这几个目录.建议在本机新建一个tmp文件夹,创建相同的路径,然后将配置文件在对应路径下创建好,最后上传到服务器。

/home/dst/.klei/DoNotStarveTogether\MyDediServer
|---Master
|---Caves
/home/dst/dst/mods

Master为地上的配置,Caves为地下的配置,mods为你的mod安装位置,这里建议mod的安装方式参考哔哩哔哩。即现在本机上下载好服务器mod,通常是work-*,work-*.然后将这些文件夹通过ftp上传到服务器,或者是使用rz的方式,这里简单说以下使用rz的方式.

#本机端
找到你的mods文件夹下的所有用于服务器的mod,因为mod只有编号,
如果你不清除你哪个编号对应哪个,进去mod文件下,用写字本或者其它
文本编辑软件打开modinfo.lua,然后你就可以看到它是什么mod了。
选中你需要上传的mod文件夹,
1、使用ftp上传,直接拖就行。
2、rz方式。
这里说第二种,首先选中所有mod文件夹,压缩成mods.rar文件,
#linux端
cd ~/dst/mods
rz
# 选中rar文件
unrar x mods.rar
# 就可以了

1、配置token文件

打开游戏客户端,在游戏主界面,在右下角找到 Account 图标,点开。

饥荒联机版-Centos7-阿里云服务器-搭建_第1张图片

点击 Account 按钮

在打开的页面下部,找到 Generate Server Token 按钮,在右侧的输入框内输入相应描述,比如输入 DST Dedi Server Token,然后点击 Generate Server Token 按钮,即生成了一个不会失效的 token。可以在按钮上方找到相应描述的 token,复制备用。

之后,将复制的 token 粘贴到 cluster_token.txt 文件中。

2、配置世界地图(必须)

地上部分,将文件保存为 worldgenoverride.lua,并放进 Master 文件夹中:

return {
    override_enabled = true,
    preset = "SURVIVAL_TOGETHER",       -- "SURVIVAL_TOGETHER", "MOD_MISSING", "SURVIVAL_TOGETHER_CLASSIC", "SURVIVAL_DEFAULT_PLUS", "COMPLETE_DARKNESS", "DST_CAVE", "DST_CAVE_PLUS"
    overrides = {
        -- default is "never", "rare", "default", "often", "always"
 
        -- MISC
        task_set = "default",           -- "classic", "default", "cave_default"
        start_location = "default",     -- "caves", "default", "plus", "darkness"
        world_size = "default",         -- "small", "medium", "default", "huge"
        branching = "default",          -- "never", "least", "default", "most"
        loop = "default",               -- "never", "default", "always"
        autumn = "default",             -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random"
        winter = "default",             -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random"
        spring = "default",             -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random"
        summer = "default",             -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random"
        season_start = "default",       -- "default", "winter", "spring", "summer", "autumnorspring", "winterorsummer", "random"
        day = "default",                -- "default", "longday", "longdusk", "longnight", "noday", "nodusk", "nonight", "onlyday", "onlydusk", "onlynight"
        weather = "default",
        earthquakes = "default",
        lightning = "default",
        frograin = "default",
        wildfires = "default",
        touchstone = "default",
        regrowth = "default",           -- "veryslow", "slow", "default", "fast", "veryfast"
        cavelight = "default",          -- "veryslow", "slow", "default", "fast", "veryfast"
        boons = "default",
        prefabswaps_start = "default",  -- "classic", "default", "highly random"
        prefabswaps = "default",        -- "none", "few", "default", "many", "max"
 
        -- RESOURCES
        flowers = "default",
        grass = "default",
        sapling = "default",
        marshbush = "default",
        tumbleweed = "default",
        reeds = "default",
        trees = "default",
        flint = "default",
        rock = "default",
        rock_ice = "default",
        meteorspawner = "default",
        meteorshowers = "default",
        mushtree = "default",
        fern = "default",
        flower_cave = "default",
        wormlights = "default",
 
        -- UNPREPARED
        berrybush = "default",
        carrot = "default",
        mushroom = "default",
        cactus = "default",
        banana = "default",
        lichen = "default",
 
        -- ANIMALS
        rabbits = "default",
        moles = "default",
        butterfly = "default",
        birds = "default",
        buzzard = "default",
        catcoon = "default",
        perd = "default",
        pigs = "default",
        lightninggoat = "default",
        beefalo = "default",
        beefaloheat = "default",
        hunt = "default",
        alternatehunt = "default",
        penguins = "default",
        cave_ponds = "default",
        ponds = "default",
        bees = "default",
        angrybees = "default",
        tallbirds = "default",
        slurper = "default",
        bunnymen = "default",
        slurtles = "default",
        rocky = "default",
        monkey = "default",
 
        -- MONSTERS
        spiders = "default",
        cave_spiders = "default",
        hounds = "default",
        houndmound = "default",
        merm = "default",
        tentacles = "default",
        chess = "default",
        lureplants = "default",
        walrus = "default",
        liefs = "default",
        deciduousmonster = "default",
        krampus = "default",
        bearger = "default",
        deerclops = "default",
        goosemoose = "default",
        dragonfly = "default",
        bats = "default",
        fissure = "default",
        worms = "default",
    },
}

洞穴部分,将文件保存为 worldgenoverride.lua,并放进 Caves 文件夹中:

return {
    override_enabled = true,
    preset = "DST_CAVE",                 -- "SURVIVAL_TOGETHER", "MOD_MISSING", "SURVIVAL_TOGETHER_CLASSIC", "SURVIVAL_DEFAULT_PLUS", "COMPLETE_DARKNESS", "DST_CAVE", "DST_CAVE_PLUS"
    overrides = {
        -- defalut is "never", "rare", "default", "often", "always"
 
        -- MISC
        task_set = "cave_default",       -- "classic", "default", "cave_default"
        start_location = "default",      -- "caves", "default", "plus", "darkness"
        world_size = "default",          -- "small", "medium", "default", "huge"
        branching = "default",           -- "never", "least", "default", "most"
        loop = "default",                -- "never", "default", "always"
        autumn = "default",              -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random"
        winter = "default",              -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random"
        spring = "default",              -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random"
        summer = "default",              -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random"
        season_start = "default",        -- "default", "winter", "spring", "summer", "autumnorspring", "winterorsummer", "random"
        day = "default",                 -- "default", "longday", "longdusk", "longnight", "noday", "nodusk", "nonight", "onlyday", "onlydusk", "onlynight"
        weather = "default",
        earthquakes = "default",
        lightning = "default",
        frograin = "default",
        wildfires = "default",
        touchstone = "default",
        regrowth = "default",            -- "veryslow", "slow", "default", "fast", "veryfast"
        cavelight = "default",           -- "veryslow", "slow", "default", "fast", "veryfast"
        boons = "default",
        prefabswaps_start = "default",   -- "classic", "default", "highly random"
        prefabswaps = "default",         -- "none", "few", "default", "many", "max"
 
        -- RESOURCES
        flowers = "default", 
        grass = "default",
        sapling = "default",
        marshbush = "default",
        tumbleweed = "default",
        reeds = "default",
        trees = "default",
        flint = "default",
        rock = "default",
        rock_ice = "default",
        meteorspawner = "default",
        meteorshowers = "default",
        mushtree = "default",
        fern = "default",
        flower_cave = "default",
        wormlights = "default",
 
        -- UNPREPARED
        berrybush = "default",
        carrot = "default",
        mushroom = "default",
        cactus = "default",
        banana = "default",
        lichen = "default",
 
        -- ANIMALS
        rabbits = "default",
        moles = "default",
        butterfly = "default",
        birds = "default",
        buzzard = "default",
        catcoon = "default",
        perd = "default",
        pigs = "default",
        lightninggoat = "default",
        beefalo = "default",
        beefaloheat = "default",
        hunt = "default",
        alternatehunt = "default",
        penguins = "default",
        cave_ponds = "default",
        ponds = "default",
        bees = "default",
        angrybees = "default",
        tallbirds = "default",
        slurper = "default",
        bunnymen = "default",
        slurtles = "default",
        rocky = "default",
        monkey = "default",
 
        -- MONSTERS
        spiders = "default",
        cave_spiders = "default",
        hounds = "default",
        houndmound = "default",
        merm = "default",
        tentacles = "default",
        chess = "default",
        lureplants = "default",
        walrus = "default",
        liefs = "default",
        deciduousmonster = "default",
        krampus = "default",
        bearger = "default",
        deerclops = "default",
        goosemoose = "default",
        dragonfly = "default",
        bats = "default",
        fissure = "default",
        worms = "default",
    },
}

3、配置通用配置文件(必须)

文件名为cluster.ini,下面为相关解释。

[MISC]
max_snapshots = 6                  # 最大快照数,决定了可回滚的天数
console_enabled = true             # 是否开启控制台

[SHARD]
shard_enabled = true               # 服务器共享,要开启洞穴服务器的必须启用
bind_ip = 127.0.0.1                # 服务器监听的地址,当所有实例都运行在同一台机器时,可填写 127.0.0.1,会被 server .ini 覆盖
master_ip = 127.0.0.1              # master 服务器的 IP,针对非 master 服务器,若与 master 服务器运行在同一台机器时,可填写 127.0.0.1,会被 server.ini 覆盖
master_port = 10888                # 监听 master 服务器的 UDP 端口,所有连接至 master 服务器的非 master 服务器必须相同
cluster_key = dst                  # 连接密码,每台服务器必须相同,会被 server.ini 覆盖

[STEAM]
steam_group_only = false           # 只允许某 Steam 组的成员加入
steam_group_id = 0                 # 指定某个 Steam 组,填写组 ID
steam_group_admins = false         # 开启后,Steam 组的管理员拥有服务器的管理权限

[NETWORK]
offline_server = false             # 离线服务器,只有局域网用户能加入,并且所有依赖于 Steam 的任何功能都无效,比如说饰品掉落
tick_rate = 15                     # 每秒通信次数,越高游戏体验越好,但是会加大服务器负担
whitelist_slots = 0                # 为白名单用户保留的游戏位
cluster_password =                 # 游戏密码,不设置表示无密码
cluster_name = ttionya test        # 游戏房间名称
cluster_description = description  # 游戏房间描述
lan_only_cluster = false           # 局域网游戏
cluster_intention = madness        # 游戏偏好,可选 cooperative, competitive, social, or madness,随便设置,没卵用

[GAMEPLAY]
max_players = 16                   # 最大游戏人数
pvp = true                         # 能不能攻击其他玩家,能不能给其他玩家喂屎
game_mode = survival               # 游戏模式,可选 survival, endless or wilderness,与玩家死亡后的负面影响有关
pause_when_empty = false           # 没人服务器暂停,刷天数必备
vote_kick_enabled = false          # 投票踢人

直接复制下面的内容:

[MISC]
max_snapshots =6
console_enabled = true
 
[SHARD]
shard_enabled = true
bind_ip = 127.0.0.1
master_ip = 127.0.0.1
master_port = 11001
cluster_key = dst
 
[STEAM]
steam_group_only = false
steam_group_id = 0
steam_group_admins = false
 
[NETWORK]
offline_server = false
tick_rate = 15
whitelist_slots = 2
cluster_name = ttionya test
cluster_description = just test
lan_only_cluster = false
cluster_intention = cooperative
 
[GAMEPLAY]
max_players = 16
pvp = true
game_mode = endless
pause_when_empty = true
vote_kick_enabled = true

4、配置独立配置文件(必须)

相关解释

[SHARD]
is_master = true /false      # 是否是 master 服务器,只能存在一个 true,其他全是 false
name = caves                 # 针对非 master 服务器的名称
id = ???                     # 随机生成,不用加入该属性

[STEAM]
authentication_port = 8766   # Steam 用的端口,确保每个实例都不相同
master_server_port = 27016   # Steam 用的端口,确保每个实例都不相同

[NETWORK]
server_port = 10999          # 监听的 UDP 端口,只能介于 10998 - 11018 之间,确保每个实例都不相同

地上部分,保存为 server.ini,并放到 Master 文件夹内:

[SHARD]
is_master = true

[STEAM]
authentication_port = 12345
master_server_port = 12346

[NETWORK]
server_port = 10999

洞穴部分,保存为 server.ini,放到 Caves 文件夹内:

[SHARD]
is_master = false
name = caves

[STEAM]
authentication_port = 12347
master_server_port = 12348

[NETWORK]
server_port = 11000

5、mod配置

参考本章开头,将mod文件上传到指定目录。并在Master和Caves下面分别配置使用的mod。这个文件保存为 modoverrides.lua,并且分别往 Master 和 Caves 文件夹里复制一份。

return {
["workshop-458940297"] = { enabled = true },
["workshop-375859599"] = { enabled = true },
["workshop-375850593"] = { enabled = true },
["workshop-343762271"] = { enabled = true },
["workshop-556027744"] = { enabled = true },
["workshop-444438334"] = { enabled = true,
    configuration_options =
    {
        keybind = 103,
        maxLights = 2,
        backpackCategory = "food"
    }
},
["workshop-378160973"] = { enabled = true },
["workshop-347079953"] = { enabled = true }
}

上面双引号中的编号替换为你自己的mod编号,严格注意格式,不能有任何差异。

6、管理员设置(可选) 6、7、8直接参考ttionya的8、9、10

有两种方法:

1、让该玩家加入游戏,再查看日志,你会在日志中找到 KU_ 开头的一串用户 id

2、让该玩家点击游戏主页面的 Account 按钮(和获得 token 一样),在页面中会有用户 id

之后,用户 id 一行放一个,保存在 adminlist.txt 文件中。下面是栗子:

KU_3N5kE2Zp
KU_BJY3CxYT
KU_DF1orNGA
KU_FAd2Yr8m
KU_vvbUjgIX

7、Ban 用户(可选)

从日志中找到他的 SteamID64,添加到 blocklist.txt 中,一行一个。

8、白名单席位(可选)

与 blocklist.txt 对应,这个文件是 whitelist.txt,但是里面的内容是以 KU_ 开头的用户 id

9、将文件移动到相关位置(重要)

/home/dst/.klei/DoNotStarveTogether\MyDediServer
|
|   adminlist.txt(/adminlist.txt)
|   blocklist.txt(/blocklist.txt)
|   cluster.ini(/cluster.ini)
|   cluster_token.txt(/cluster_token.txt)
|   whitelist.txt(/whitelist.txt)
|
|---Master
|   |   modoverrides.lua(/Master/modoverrides.lua)
|   |   server.ini(/Master/server.ini)
|   |   worldgenoverride.lua(/Master/worldgenoverride.lua)
|   |   其他文件
|   |
|   |---其他文件夹
|
|---Caves
    |   modoverrides.lua(/Caves/modoverrides.lua)
    |   server.ini(/Caves/server.ini)
    |   worldgenoverride.lua(/Caves/worldgenoverride.lua)
    |   其他文件
    |
    |---其他文件夹

/home/dst/dst/mods
|
|   dedicated_server_mods_setup.lua(/dedicated_server_mods_setup.lua)# 这个非必须

10、启动服务器

#该代码需要一行一行输,不能全部复制
su - dst
script /dev/null
cd ~/dst/bin
screen -S ground
# 手动按 ctrl + A,然后按D退出窗口
screen -S cave
# 手动按ctrl +A,然后按D退出窗口
screen -r ground
 sh ./dst_overworld.sh
# 手动按 Ctrl + A 键,之后按 D
screen -r cave
sh ./dst_caves.sh

11、加载旧存档、重启服务器

先说停止服务器,两种方式,一种是直接在对应的screen中按ctrl+c停止服务,另外一种是进入游戏,以管理员的身份按~打开控制台,输入c_shutdown()。

加载旧存档,把Master和Caves里面的文件,除了server.ini以外的全部替换即可。

重启服务器:停止、启动。

OK,到此结束。今天踩坑踩了2个多小时。终于结束了。

你可能感兴趣的:(环境配置,游戏,饥荒,服务器搭建,饥荒联机版)