走啊走
加油

如何用阿里云服务器搭建饥荒专用服务器?

服务器价格表

前几天我一朋友在steam上邀请我一起玩饥荒,可是联机的时候,总是一卡一卡的,好不容易玩的正尽兴的时候,我朋友突然有事就离开了房间,好不容易打的怪,建的家,房主一退就不能再次玩了只能等待他回来。

针对这样个的问题,我决定自己搭建饥荒的专有服务器,解决两个问题,

1、在服务器有个长时间运行的房间,如果房间内没有任何玩家则世界暂停,

2、我的阿里云服务器有1mb的带宽足够我们6个人一起玩了(解决不卡顿)

我的阿里云服务器是Ubuntu 64位的机器

首先使用ssh 连接服务器:

1、安装依赖关系

64位机器:

sudo apt-get install libstdc ++ 6:i386 libgcc1:i386 libcurl4-gnutls-dev:i386 
 
32位机器:
sudo apt-get install libstdc ++ 6 libgcc1 libcurl4-gnutls-dev

2、安装steamcmd

按照以下说明下载并安装steamcmd:https :  //developer.valvesoftware.com/wiki/SteamCMD#Linux  
//本指南将假定您已将steamcmd安装到〜/ steamcmd。如果您愿意,可以跳过关于创建新用户的部分。 

缩短版本的必要命令:

mkdir〜/ steamcmd
cd〜/ steamcmd
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz

3、创建专有服务器文件夹(目录)

您需要创建这些文件夹:

~/.klei/DoNotStarveTogether/MyDediServer/Master
~/.klei/DoNotStarveTogether/MyDediServer/Caves
您可以使用以下命令:

mkdir -p ~/.klei/DoNotStarveTogether/MyDediServer/Master
mkdir -p ~/.klei/DoNotStarveTogether/MyDediServer/Caves

4、创建cluster_token.txt

从steam上运行饥荒 点击play

点击Acct Info按钮

点击”Generate Server Token“ 按钮并复制token粘贴到一下文件中

  • ~/.klei/DoNotStarveTogether/MyDediServer/cluster_token.txt

您可以通过运行以下命令快速执行此操作,将YourServerTokenHere替换为服务器令牌(将引号保留在令牌周围)。

echo 'YourServerTokenHere' > ~/.klei/DoNotStarveTogether/MyDediServer/cluster_token.txt

5、创建cluster.ini 文件

拷贝以下文本

  • ~/.klei/DoNotStarveTogether/MyDediServer/cluster.ini
  • [GAMEPLAY]
    game_mode = survival
    max_players = 6
    pvp = false
    pause_when_empty = true
    
    
    [NETWORK]
    cluster_description = This server is super duper!
    cluster_name = Super Server
    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

    你也可以使用这个自动执行的命令

    base64 -di > ~/.klei/DoNotStarveTogether/MyDediServer/cluster.ini <<< 'W0dBTUVQTEFZXQpnYW1lX21vZGUgPSBzdXJ2aXZhbAptYXhfcGxheWVycyA9IDYKcHZwID0gZmFsc2UKcGF1c2Vfd2hlbl9lbXB0eSA9IHRydWUKCgpbTkVUV09SS10KY2x1c3Rlcl9kZXNjcmlwdGlvbiA9IFRoaXMgc2VydmVyIGlzIHN1cGVyIGR1cGVyIQpjbHVzdGVyX25hbWUgPSBTdXBlciBTZXJ2ZXIKY2x1c3Rlcl9pbnRlbnRpb24gPSBjb29wZXJhdGl2ZQpjbHVzdGVyX3Bhc3N3b3JkID0gCgoKW01JU0NdCmNvbnNvbGVfZW5hYmxlZCA9IHRydWUKCgpbU0hBUkRdCnNoYXJkX2VuYWJsZWQgPSB0cnVlCmJpbmRfaXAgPSAxMjcuMC4wLjEKbWFzdGVyX2lwID0gMTI3LjAuMC4xCm1hc3Rlcl9wb3J0ID0gMTA4ODkKY2x1c3Rlcl9rZXkgPSBzdXBlcnNlY3JldGtleQo='

6、编辑你的cluster.ini文件

使用文本编辑器中打开~/.klei/DoNotStarveTogether/MyDediServer/cluster.ini,并更改所需的所有内容。你可以将cluster_name从“Super Server”更改为别的内容。这是在服务器列表中显示的名称。

7、创建你主机的server.ini

拷贝一下文本到文件

~/.klei/DoNotStarveTogether/MyDediServer/Master/server.ini
[NETWORK]
server_port = 11000


[SHARD]
is_master = true


[STEAM]
master_server_port = 27018
authentication_port = 8768

或使用一下快捷命令

base64 -di > ~/.klei/DoNotStarveTogether/MyDediServer/Master/server.ini <<< 'W05FVFdPUktdCnNlcnZlcl9wb3J0ID0gMTEwMDAKCgpbU0hBUkRdCmlzX21hc3RlciA9IHRydWUKCgpbU1RFQU1dCm1hc3Rlcl9zZXJ2ZXJfcG9ydCA9IDI3MDE4CmF1dGhlbnRpY2F0aW9uX3BvcnQgPSA4NzY4Cg=='

8、建Caves server.ini文件

复制以下文本到文件

  • ~/.klei/DoNotStarveTogether/MyDediServer/Caves/server.ini
[NETWORK]
server_port = 11001


[SHARD]
is_master = false
name = Caves


[STEAM]
master_server_port = 27019
authentication_port = 8769

或使用以下快捷命令:

base64 -di > ~/.klei/DoNotStarveTogether/MyDediServer/Caves/server.ini <<< 'W05FVFdPUktdCnNlcnZlcl9wb3J0ID0gMTEwMDEKCgpbU0hBUkRdCmlzX21hc3RlciA9IGZhbHNlCm5hbWUgPSBDYXZlcwoKCltTVEVBTV0KbWFzdGVyX3NlcnZlcl9wb3J0ID0gMjcwMTkKYXV0aGVudGljYXRpb25fcG9ydCA9IDg3NjkK'

9、创建 Caves worldgenoverride.lua 文件

复制以下文本到文件中

  • ~/.klei/DoNotStarveTogether/MyDediServer/Caves/worldgenoverride.lua
return {
    override_enabled = true,
    preset = "DST_CAVE",
}

也可以使用这里的快捷命令

base64 -di > ~/.klei/DoNotStarveTogether/MyDediServer/Caves/worldgenoverride.lua <<< 'cmV0dXJuIHsKICAgIG92ZXJyaWRlX2VuYWJsZWQgPSB0cnVlLAogICAgcHJlc2V0ID0gIkRTVF9DQVZFIiwKfQo='

10、创建将运行服务的脚本

复制以下文本到文件

  • ~/run_dedicated_servers.sh

头部一定加上"#!/bin/bash" 或者直接运行下面的快捷命令

#!/bin/bash

steamcmd_dir="$HOME/steamcmd"
install_dir="$HOME/dontstarvetogether_dedicated_server"
cluster_name="MyDediServer"
dontstarve_dir="$HOME/.klei/DoNotStarveTogether"

function fail()
{
        echo Error: "$@" >&2
        exit 1
}

function check_for_file()
{
    if [ ! -e "$1" ]; then
            fail "Missing file: $1"
    fi
}

cd "$steamcmd_dir" || fail "Missing $steamcmd_dir directory!"

check_for_file "steamcmd.sh"
check_for_file "$dontstarve_dir/$cluster_name/cluster.ini"
check_for_file "$dontstarve_dir/$cluster_name/cluster_token.txt"
check_for_file "$dontstarve_dir/$cluster_name/Master/server.ini"
check_for_file "$dontstarve_dir/$cluster_name/Caves/server.ini"

./steamcmd.sh +force_install_dir "$install_dir" +login anonymous +app_update 343050 validate +quit

check_for_file "$install_dir/bin"

cd "$install_dir/bin" || fail 

run_shared=(./dontstarve_dedicated_server_nullrenderer)
run_shared+=(-console)
run_shared+=(-cluster "$cluster_name")
run_shared+=(-monitor_parent_process $$)

"${run_shared[@]}" -shard Caves  | sed 's/^/Caves:  /' &
"${run_shared[@]}" -shard Master | sed 's/^/Master: /'

也可以使用快捷命令

base64 -di > ~/run_dedicated_servers.sh <<< 'IyEvYmluL2Jhc2gKCnN0ZWFtY21kX2Rpcj0iJEhPTUUvc3RlYW1jbWQiCmluc3RhbGxfZGlyPSIkSE9NRS9kb250c3RhcnZldG9nZXRoZXJfZGVkaWNhdGVkX3NlcnZlciIKY2x1c3Rlcl9uYW1lPSJNeURlZGlTZXJ2ZXIiCmRvbnRzdGFydmVfZGlyPSIkSE9NRS8ua2xlaS9Eb05vdFN0YXJ2ZVRvZ2V0aGVyIgoKZnVuY3Rpb24gZmFpbCgpCnsKICAgICAgICBlY2hvIEVycm9yOiAiJEAiID4mMgogICAgICAgIGV4aXQgMQp9CgpmdW5jdGlvbiBjaGVja19mb3JfZmlsZSgpCnsKICAgIGlmIFsgISAtZSAiJDEiIF07IHRoZW4KICAgICAgICAgICAgZmFpbCAiTWlzc2luZyBmaWxlOiAkMSIKICAgIGZpCn0KCmNkICIkc3RlYW1jbWRfZGlyIiB8fCBmYWlsICJNaXNzaW5nICRzdGVhbWNtZF9kaXIgZGlyZWN0b3J5ISIKCmNoZWNrX2Zvcl9maWxlICJzdGVhbWNtZC5zaCIKY2hlY2tfZm9yX2ZpbGUgIiRkb250c3RhcnZlX2Rpci8kY2x1c3Rlcl9uYW1lL2NsdXN0ZXIuaW5pIgpjaGVja19mb3JfZmlsZSAiJGRvbnRzdGFydmVfZGlyLyRjbHVzdGVyX25hbWUvY2x1c3Rlcl90b2tlbi50eHQiCmNoZWNrX2Zvcl9maWxlICIkZG9udHN0YXJ2ZV9kaXIvJGNsdXN0ZXJfbmFtZS9NYXN0ZXIvc2VydmVyLmluaSIKY2hlY2tfZm9yX2ZpbGUgIiRkb250c3RhcnZlX2Rpci8kY2x1c3Rlcl9uYW1lL0NhdmVzL3NlcnZlci5pbmkiCgouL3N0ZWFtY21kLnNoICtmb3JjZV9pbnN0YWxsX2RpciAiJGluc3RhbGxfZGlyIiArbG9naW4gYW5vbnltb3VzICthcHBfdXBkYXRlIDM0MzA1MCB2YWxpZGF0ZSArcXVpdAoKY2hlY2tfZm9yX2ZpbGUgIiRpbnN0YWxsX2Rpci9iaW4iCgpjZCAiJGluc3RhbGxfZGlyL2JpbiIgfHwgZmFpbCAKCnJ1bl9zaGFyZWQ9KC4vZG9udHN0YXJ2ZV9kZWRpY2F0ZWRfc2VydmVyX251bGxyZW5kZXJlcikKcnVuX3NoYXJlZCs9KC1jb25zb2xlKQpydW5fc2hhcmVkKz0oLWNsdXN0ZXIgIiRjbHVzdGVyX25hbWUiKQpydW5fc2hhcmVkKz0oLW1vbml0b3JfcGFyZW50X3Byb2Nlc3MgJCQpCgoiJHtydW5fc2hhcmVkW0BdfSIgLXNoYXJkIENhdmVzICB8IHNlZCAncy9eL0NhdmVzOiAgLycgJgoiJHtydW5fc2hhcmVkW0BdfSIgLXNoYXJkIE1hc3RlciB8IHNlZCAncy9eL01hc3RlcjogLycKCgo='

11、给脚本一个执行权限

在终端运行

chmod u+x ~/run_dedicated_servers.sh

12、运行专有服务器的启动脚本

在终端运行

~/run_dedicated_servers.sh

运行之后大概十多秒后你就可以在steam中查找你的专有服务器名称,进去如果你设置了密码输入密码,就可以打开你的饥荒世界了。。。。。。【文章来源转载】[服务器和技术仅能用于合法的用途]