注:本教程在Vultr VPS上测试通过,如需部署请前往Vultr.com
介绍
什么是堇青石?
Cuberite是使用C ++编写的可扩展的开源Minecraft服务器实现。它具有易于使用的插件系统,允许用户使用Lua编写自定义插件,并且最初是在 MCServer
名称。
支持平台:
Cuberite是多平台的,可与大多数Linux操作系统和Windows一起使用。本教程仅涵盖在CentOS 6或7安装中服务器软件的安装。像大多数Minecraft服务器一样,插件和其他因素也会导致更大的内存占用。首先,建议您至少具有:
1 GB的RAM
1个CPU核心
Vultr以每月5美元的价格提供这些规格(包括25 GB的SSD和1 TB的带宽)。
安装
先决条件
在开始之前,我们必须确保系统是最新的并且具有适当的文本编辑器。这是配置服务器所必需的。我们还将需要适当的工具来构建和编译软件。
在安装任何东西之前,请执行以下命令来更新系统:
yum update -y
现在,我们将安装 nano
。 (您可以使用 vim
或您喜欢的任何其他编辑器):
yum install nano -y
完成后,运行以下命令进行安装 cmake
(编译器):
yum install cmake -y
现在,安装 screen
(允许应用程序在后台运行):
yum install screen -y
后 screen
安装后,您可以继续进行下一部分。
运行安装脚本
现在,我们已经具有完成安装所需的所有依赖关系,我们必须检索脚本。以下命令将在以下位置创建一个新目录 /root
, 要么 ~
。
cd ~ && mkdir server
cd server
wget -O install.sh https://compile.cuberite.org
现在,您可以运行安装脚本:
sh install.sh
您将在终端中看到以下消息:
[root@demo server]# sh install sh
Hello, this script will download and compile Cuberite.
On subsequent runs, it will update Cuberite.
The compilation and download will occur in the current directory.
If you're updating, you should run: /compile.sh
Compiling from srouce takes time, but it usually generates faster
executables. If you prefer ready-to-use binaries or if you want
more info, please visit: https://cuberite.org
Choose compile mode:
* (R)Release: Compiles normally.
Generates the fastest build.
* (D)Debug: Compiles in debug mode.
Makes your console and crashes more verbose.
A bit slower than Release mode. If you plan to help
development by reporting bugs, this is preferred.
Choose compile mode: (r/d) (Default: "Release"):
当您看到以上内容时,只需按键盘上的ENTER键。
现在,您将看到以下内容:
Choose the number of compilation threads.
You have 2 CPU threads.
If you have enough RAM, it is wise to choose your CPU's thread count.
Otherwise choose lower. Old Raspberry Pis should choose 1. If in doubt, choose 1
.
Please enter the number of compilation threads to use (Default: 1):
您可以选择使用更多线程进行编译(取决于您的实例)。除此之外,您只需按ENTER。
完成后,将提示您以下消息:
#### Settings Summary ####
Build Type: Release
Branch: master (Currently the only choice)
Compilation threads: 1
CPU Threads: 2
Previous Compilation: Not detected. We are assuming this is the first compile.sh run.
Upstream Link: https://github.com/cuberite/cuberite.git
Upstream Repo: origin
After pressing ENTER, the script will connect to https://github.com/cuberite/cuberite.git
to check for updates and/or fetch code. It will then compile your program.
If you compiled before, make sure you're in the proper directory and that "Previous
compilation" is detected.
Press ENTER to continue...
这是编译开始之前的最后一步。系统将提示您按ENTER键开始编译。大约需要15分钟,具体取决于您的系统。
注意:如果您在终端上看到一堆文本滚动,请不要惊慌。系统将软件完全编译成可执行程序包需要花费一些时间。
完成后,您将收到以下消息:
-----------------
Compilation done!
Cuberite awaits you at:
/root/server/cuberite/Server/Cuberite
You can always update Cuberite by executing:
/root/server/cuberite/compile.sh
Enjoy :)
这标志着安装的结束。您可以继续进行下一部分的服务器配置。
组态
要配置您的服务器,我们必须首先找到临时服务器并将其复制到我们的临时目录中:
cd cuberite
cp -r Server ~/server/cuberiteServer
cd ./cuberiteServer
您的服务器目录现在位于 /root/server/cuberiteServer
并且配置文件将位于 /root/server/cuberiteServer/settings.ini
。
现在,我们可以使用任何文本编辑器来编辑配置:
nano settings.ini
您将看到类似以下内容的内容:
[Server]
Description=Cuberite - in C++!
ShutdownMessage=Server shutdown
MaxPlayers=100
HardcoreEnabled=0
AllowMultiLogin=0
Ports=25565
为了编辑在任何给定时间可以在线的最大玩家数量,只需修改 MaxPlayers=100
符合您想要的任何数字。
例如,如果您最多需要25个玩家,则只需将行更改为 MaxPlayers=25
。
您也可以更改端口,但不建议这样做,因为用户连接到服务器的难度增加(Minecraft服务器的默认端口是 25565
)。
如果您正在使用 nano
,您可以先按CTRL + X,再按ENTER退出并保存。
启动,停止并连接到新服务器
启动服务器
要启动服务器,只需转到服务器目录(/root/server/cuberiteServer
)并启动一个屏幕:
cd ~/server/cuberiteServer
screen -S MinecraftServer && screen -r MinecraftServer
您可以重新连接到 screen
在任何给定时间使用 screen -r
命令。我们为屏幕命名 MinecraftServer
,因此重新连接可以通过执行 screen -r MinecraftServer
。
现在,执行服务器二进制文件:
./Cuberite
在使用服务器之前,可能需要花费几秒钟的时间才能生成地形。另外,使用以下组合退出屏幕:CTRL + A +D。
停止服务器
为了执行硬关闭,您所需要做的就是使用CTRL +C。要执行正常关闭,请在控制台中输入以下命令:
stop
连接到服务器
假设您已经配置了防火墙,则可以在Minecraft客户端中输入服务器地址。
您的地址应如下所示: 192.0.2.5:25565
(192.0.2.5
是您的实际服务器地址)。
结束语
此时,您可以将服务器地址与几个朋友一起传递并开始构建。
卸载Cuberite
删除软件很简单。您要做的就是确保服务器脱机并运行 rm -rf ~/server
。
注:本教程在Vultr VPS上测试通过,如需部署请前往Vultr.com