fedora21架设minecraft服务器

上周刚刚从dota2的坑中跳出来,这周就又跳入了mincraft的大坑中。作为买不起官网服务的穷人,自己玩单机也未免过于孤单。虽然网上有很多现成的“私服”,不过又不想受别人限制,那就自己搭建一个呗!

首先安装jdk,fedora执行: sudo yum install java-1.8.0-openjdk.x86_64 ubuntu则是: suso apt-get install openjdk-7-jre-headless 安装完成后可以执行java命令看是否成功,然后下载minecraft的服务端:

wget https://s3.amazonaws.com/Minecraft.Download/versions/1.8.8/minecraft_server.1.8.8.jar

这步最好新建一个目录,因为运行程序后会在当前目录生成一些文件。

运行:java -Xmx1024M -Xms1024M -d64 -jar minecraft_server.1.8.8.jar nogui 这里官网提示可用内存至少在1G以上,我自己添加了-d参数因为我的系统是64位的。

root@localhost:/var/local/mine# java -Xmx1024M -Xms1024M -jar minecraft_server.1.8.8.jar nogui
[02:37:30] [Server thread/INFO]: Starting minecraft server version 1.8.8
[02:37:30] [Server thread/INFO]: Loading properties
[02:37:30] [Server thread/WARN]: server.properties does not exist
[02:37:30] [Server thread/INFO]: Generating new properties file
[02:37:30] [Server thread/WARN]: Failed to load eula.txt
[02:37:30] [Server thread/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
[02:37:30] [Server thread/INFO]: Stopping server

第一次运行后会出现这个错误,编辑当前目录下生成的eula.txt,把eula设置为true即可。

修改保存后再次运行:

root@localhost:/var/local/mine# java -Xmx1024M -Xms1024M -jar minecraft_server.1.8.8.jar nogui
[02:37:49] [Server thread/INFO]: Starting minecraft server version 1.8.8
[02:37:49] [Server thread/INFO]: Loading properties
[02:37:49] [Server thread/INFO]: Default game type: SURVIVAL
[02:37:49] [Server thread/INFO]: Generating keypair
[02:37:49] [Server thread/INFO]: Starting Minecraft server on *:25565
[02:37:49] [Server thread/INFO]: Using epoll channel type
[02:37:49] [Server thread/INFO]: Preparing level "world"
[02:37:50] [Server thread/INFO]: Preparing start region for level 0
[02:37:51] [Server thread/INFO]: Preparing spawn area: 4%
[02:37:52] [Server thread/INFO]: Preparing spawn area: 10%
[02:37:53] [Server thread/INFO]: Preparing spawn area: 18%
[02:37:54] [Server thread/INFO]: Preparing spawn area: 31%
[02:37:55] [Server thread/INFO]: Preparing spawn area: 43%
[02:37:56] [Server thread/INFO]: Preparing spawn area: 57%
[02:37:57] [Server thread/INFO]: Preparing spawn area: 70%
[02:37:58] [Server thread/INFO]: Preparing spawn area: 86%
[02:37:59] [Server thread/INFO]: Preparing spawn area: 99%
[02:37:59] [Server thread/INFO]: Done (9.702s)! For help, type "help" or "?"

这里服务就成功启动了,但注意,这里服务端是正版的,如果使用的是盗版客户端,比如HMCL,选择多人游戏并添加服务器地址后是无法链接的,需要修改配置文件server.properties,把其中online-mode的值改成false,之后再次启动服务器即可链接。