阿里雲搭建饑荒專用伺服器

前幾天我一朋友在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?/ steamcmdcd?/ steamcmdwget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gztar -xvzf steamcmd_linux.tar.gz

3、創建專有伺服器文件夾(目錄)

您需要創建這些文件夾:~/.klei/DoNotStarveTogether/MyDediServer/Master~/.klei/DoNotStarveTogether/MyDediServer/Caves您可以使用以下命令:mkdir -p ~/.klei/DoNotStarveTogether/MyDediServer/Mastermkdir -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 = survivalmax_players = 6pvp = falsepause_when_empty = true[NETWORK]cluster_description = This server is super duper!cluster_name = Super Servercluster_intention = cooperativecluster_password =[MISC]console_enabled = true[SHARD]shard_enabled = truebind_ip = 127.0.0.1master_ip = 127.0.0.1master_port = 10889cluster_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 = 27018authentication_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 = falsename = Caves[STEAM]master_server_port = 27019authentication_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/bashsteamcmd_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 +quitcheck_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中查找你的專有伺服器名稱,進去如果你設置了密碼輸入密碼,就可以打開你的饑荒世界了。。。。。。


推薦閱讀:

《饑荒》新出的船難模式,遊戲平衡性是不是有些問題?
在《饑荒》裡衣食無憂之後可以幹什麼?

TAG:饥荒游戏 | DontStarve游戏 | 生存 |