VPS搭建Tshock服务

Tshock1是一个第三方的terraria开服工具。在这里,我们尝试在VPS搭建Tshock服务。

SWAP

查看系统内存:

1
free -h
1
2
3
4
             total       used       free     shared    buffers     cached
Mem: 489M 441M 48M 404K 55M 159M
-/+ buffers/cache: 227M 262M
Swap: 0B 0B 0B

由于Tshock建议需要2GB的内存,但我的VPS只有489M的物理内存。幸好有人测试使用swap也可以2,于是根据指南3尝试对Swap进行设置。

注意,只有XEN、KVM架构的VPS可以设置SWAP交换分区

创建swap文件

1
dd if=/dev/zero of=/swapfile count=2048 bs=1M

bs是每块的大小,count是块的数量,bs * count,就是swap文件的大小了,这里就是1M * 2048=2G。

测试:

1
2
ls / | grep swapfile
swapfile
激活swap文件

设置权限:

1
chmod 600 /swapfile

配置:

1
mkswap /swapfile

开启:

1
swapon /swapfile

测试:

1
2
3
4
5
6
free -m

total used free shared buffers cached
Mem: 489 481 7 0 36 213
-/+ buffers/cache: 231 258
Swap: 2047 0 2047

开机启动:

1
nano /etc/fstab

文件添加:

1
/swapfile   none    swap    sw    0   0

Mono4

1
2
3
4
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/ubuntu $(lsb_release -c --short) main" | sudo tee /etc/apt/sources.list.d/mono-official.list
sudo apt-get update
sudo apt-get install -y mono-complete mono-devel

Tshock

下载TShock中文版5

1
2
wget -O tshock.zip 'https://github.com/mistzzt/TShock/releases/download/cn-v3.1/tshock_cn_release.zip'
unzip tshock.zip -d ~/tshock

运行:

1
2
cd shock
MONO_THREADS_PER_CPU=50 mono TerrariaServer.exe