之前介绍了在 Windows 下搭建洞穴服务器的方法,详情见传送门。这里,向大家介绍 Linux (CentOS)上的搭建方法。

饥荒
饥荒

先为大家提个醒,顺便当作 Linux 平台的一些特性,若发现没有必要使用 Linux,还是乖♂乖回 Windows 平台搭建吧:

Linux 上搭建的优势是在 CPU 的消耗上,Linux 因为可以不运行 Desktop,所以系统可以更少地占用 CPU 而把 CPU 资源让给游戏。在游戏时,会占用较多 CPU,特别是在画面中单位较多的时候,比如许多杀人蜂、夏季 Boss 的小宝宝之类的,都会大量占用 CPU 资源;

Linux 平台上游戏的搭建比较麻烦,几乎都是依靠命令行完成,没有 Linux 使用经验的朋友建议绕道;

在占用内存方面,Linux 并不能比 Windows 占用更少内存,而且每个游戏进程大约需要 500-600M 内存,总共需要大概 1.2G 内存,小内存的还是算了吧;

网速是最重要的!网速是最重要的!网速是最重要的!不管是什么平台搭建服务器,没有足够的上行带宽,卡成狗。

 

博主这里依旧选择最蛋疼的 Linux 发行版——CentOS,版本是 CentOS 6.7,服务器搭建仅在该系统上经过测试,其余发行版未测试…

 

1、依旧为某些喜欢查看英文文档的人提供官方地址

由 V 社提供的 SteamCMD 使用方法的 Wiki 网址,点此进入

由 Klei 提供的 Don't Strave Together Dedicated Server 搭建教程,点此进入

由 Klei 建议的 Don't Strave Together Dedicated Server 搭建指南,点此进入指南中提供了在 Debian 系发行版上的安装方法,遇到问题可以去看看。就是说遇到问题不要问我,我也不懂!!

 

2、安装 Don’t Strave Together Dedicated Server

请用 root 用户登陆

安装系统环境,以下内容由官方提供:

Ubuntu/Debian 64-Bit
sudo apt-get install lib32gcc1 screen
RedHat/CentOS 32-Bit
yum -y install glibc libstdc++ screen libcurl
RedHat/CentOS 64-Bit
yum -y install glibc.i686 libstdc++.i686 screen libcurl.i686

新建用户,非常不建议使用 root 运行游戏,这将产生严重的安全隐患:

useradd -m dst
su - dst

开始下载并解压安装,默认目录选用户 home 目录。注意第 5 行,通过 force_install_dir 指定了 DST 的安装路径,这里取 ~/dst 作为安装目录,若有需要可自行更改,不指定则默认安装至 ~/Steam/steamapps/common/Don't Starve Together Dedicated Server

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

 

3、运行 Don’t Strave Together Dedicated Server

运行依赖的处理非常蛋疼,之前博主因为 libstdc++.so.6 库版本过低,甚至去重新编译 gcc 来提取该文件…

所以,先处理依赖,从而保证一次运行成功:

cd ~/dst/bin
ldd dontstarve_dedicated_server_nullrenderer
./dontstarve_dedicated_server_nullrenderer
#查看是否有错误信息

一般会有以下报错信息:

/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、创建脚本文件

解决完成全部报错后,创建两个脚本文件,作用是生成配置文件,配置文件的目录默认位于 ~/.klei/。注意第二第三行,相关可用命令在文章末尾。

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 文件夹,该文件夹下有名为 MasterCaves 的两个子文件夹,这两个文件夹分别是地上和洞穴的配置目录。

 

此时,安装终了,进行配置后即可开始游戏。配置在这——大家好,我是配置(=・ω・=)

 

PS:怎么升级?

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

 

这里列出了第四步中其他可用的命令:

拷贝自 http://steamcommunity.com/sharedfiles/filedetails/?id=590681995

-persistent_storage_root

Change the directory that your configuration directory resides in. This should be an absolute path. The full path to your files will be <persistent_storage_root>/<conf_dir>/ where <conf_dir> is the value set by -conf_dir. The default for this option depends on the platform:

Windows: <Your documents folder>/Klei
Mac OSX: <Your home folder>/Documents/Klei
Linux: ~/.klei

-conf_dir

Change the name of your configuration directory. This name should not contain any slashes. The full path to your files will be <persistent_storage_root>/<conf_dir> where <persistent_storage_root> is the value set by the -persistent_storage_root option. The default is: "DoNotStarveTogether".

-cluster

Set the name of the cluster directory that this server will use. The server will expect to find the cluster.ini file in the following location: <persistent_storage_root>/<conf_dir>/<cluster>/cluster.ini, where <persistent_storage_root> and <conf_dir> are the values set by the -persistent_storage_root and -conf_dir options. The default is "Cluster_1".

-shard

Set the name of the shard directory that this server will use. The server will expect to find the server.ini file in the following location:<persistent_storage_root>/<conf_dir>/<cluster>/<shard>/server.ini, where <persistent_storage_root>, <conf_dir>, and <cluster> are the values set by the -persistent_storage_root, -conf_dir, and -cluster options. The default is "Master".

-offline

Start the server in offline mode. In offline mode, the server will not be listed publicly, only players on the local network will be able to join, and any steam-related functionality will not work.

-console

Allow lua commands to be entered in the command prompt or terminal that the server is running in.

-bind_ip <bind_ip>

Change the address that the server binds to when listening for player connections. This is an advanced feature that most people will not need to use.

-port <port_number>

Valid values: 1..65535
The UDP port that this server will listen for connections on. This option overrides the [NETWORK] / server_port setting in server.ini. If you are running a multi-level cluster, this port must be different for each server. This port must be between 10998 and 11018 inclusive in order for players on the same LAN to see it in their server listing. Ports below 1024 are restricted to privileged users on some operating systems.

-players <max_players>

Valid values: 1..64
Set the maximum number of players that will be allowed to join the game. This option overrides the [GAMEPLAY] / max_players setting in cluster.ini.

-steam_master_server_port <port_number>

Valid values: 1..65535
Internal port used by steam. This option overrides the [STEAM] / master_server_port setting in server.ini. Make sure that this is different for each server you run on the same machine.

-steam_authentication_port <port_number>

Valid values: 1..65535
Internal port used by steam. This option overrides the [STEAM] / authentication_port setting in server.ini. Make sure that this is different for each server you run on the same machine.

-backup_logs

Create a backup of the previous log files each time the server is run. The backups will be stored in a directory called "backup" in the same directory as server.ini.

-tick <tick_rate>

Valid values: 15 .. 60
This is the number of times per-second that the server sends updates to clients. Increasing this may improve precision, but will result in more network traffic. This option overrides the [NETWORK] / tick_rate setting in cluster.ini. It is recommended to leave this at the default value of 15. If you do change this option, it is recommended that you do so only for LAN games, and use a number evenly divisible into 60 (15, 20, 30).

原创文章,转载请以链接形式注明出处:http://blog.ttionya.com/article-1233.html