Minecraft/Java 版サーバー

提供: ArchWiki
ナビゲーションに移動 検索に移動

Minecraft is a multiplayer game. It uses the client-server model in which the game itself is a client which can be played standalone, or can be played with other players when the client connects to a public server.

ノート: Minecraft servers are ran by third parties. You should read their privacy policies to learn about how they process your data. Some servers require third party accounts to login, and some servers support microtransactions allowing you to pay for items on the server, although this could break the Minecraft EULA depending on what the server is selling.

Installation

The Java Edition Minecraft server can be installed via the minecraft-serverAUR package. It provides additional systemd unit files and includes a small control script.

Also see #Alternatives for an overview of alternative programs to host Minecraft.

Configuration

In the installation process, the minecraft user and group are created. Establishing a Minecraft-specific user is recommended for security reasons. By running Minecraft under an unprivileged user account, anyone who successfully exploits your Minecraft server will only get access to that user account, and not yours. However, you may safely add your user to the minecraft group and add group write permission to the directory /srv/minecraft (default) to modify Minecraft server settings. Make sure that all files in the /srv/minecraft directory are either owned by the minecraft user, or that the user has by other means read and write permissions. The server will error out if it is unable to access certain files and might even have insufficient rights to write an according error message to the log.

The package provides a systemd service and timer to take automatic backups. By default, the backups are located in the backup folder under the server root directory. Though to keep the disk footprint small only the 10 most recent backups are preserved (configurable via KEEP_BACKUPS). The related systemd files are minecraftd-backup.timer and minecraftd-backup.service. They may easily be adapted to your liking, e.g. to follow a custom backup interval.

Starting the server

To start the server, you may either use systemd or run it directly from the command line. Either way, the server is encapsulated in a tmux session which is owned by the minecraft user. Using systemd, you may start/enable the included minecraftd.service. Alternatively, run

# minecraftd start

Accepting the EULA

In order to run the Minecraft server, you must accept the End User License Agreement. This only needs to happen once after installation. The EULA file resides under /srv/minecraft/eula.txt after being created by the package. You will need to edit this file to state that you have agreed to the contract in order to run the server. All you need to do is change:

eula=false

to the value true. Here is an example of an accepted EULA:

/srv/minecraft/eula.txt
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
#Sat Sep 11 11:11:11 PDT 2011
eula=true

Firewall configuration

There are three settings in the server.properties which determine ports that your server will use.

server-port determines the TCP port at which the server will listen for incoming connections. The default port is 25565.

query.port determines the UDP port at which the server will share game info/advertising information. The default port is 25565. Note that since the server and query ports are TCP and UDP, they can share the same port. To enable query, you also have to specify enable-query=true.

rcon.port determines the TCP port if you choose to allow remote access to admin console. The default port is 25575. To enable rcon, you also have to specify enable-rcon=true and rcon.password=....

You will need to allow incoming connections at least on the server-port. It is advisable to allow query and its query.port. On the other hand, enabling remote console access is a security risk, and you should be careful of allowing it.

The above information is for the official Minecraft server. If you are using an alternative server, please see its documentation for details about its configuration.

See [1] and [2] for more information.

Server management script

To easily control the server, you may use the provided minecraftd script. It is capable of doing basic commands like start, stop, restart or attaching to the session with console. Moreover, it may be used to display status information with status, backup the server world directory with backup, restore world data from backups with restore or run single commands in the server console with command do-something.

ノート: Regarding the server console (reachable via minecraftd console), remember that you can exit any tmux session with ctrl+b d.

Tweaking

To tweak the default settings (e.g. the maximum RAM, number of threads etc.), edit the file /etc/conf.d/minecraft.

For example, more advanced users may wish to enable IDLE_SERVER by setting it to true. This will enable the management script to suspend the server if no player was online for at least IDLE_IF_TIME (defaults to 20 minutes). When the server is suspended, an idle_server will listen on the Minecraft port using ncat(1) from nmap (or any other implementation of netcat) and will immediately start the server at the first incoming connection. Though this obviously delays joining for the first time after suspension, it significantly decreases the CPU and memory usage leading to more reasonable resource and power consumption levels.

ノート: If running for the first time with this option enabled, the /srv/minecraft/eula.txt file will not get created. You need to disable it to initially start.

Alternatives

Spigot (respectively Craftbukkit)

Spigot is the most widely-used modded Minecraft server in the world. It can be installed with the spigotAUR package. The spigot PKGBUILD builds on top of the files from the minecraft-serverAUR package. This means that the spigot server provides its own systemd unit files, spigot script and corresponding script configuration file. The binary is called spigot and is capable of fulfilling the same commands as minecraftd. The configuration file resides under /etc/conf.d/spigot.

Be sure to read #Configuration and replace minecraftd with spigot wherever you encounter it.

It is somewhat affiliated with Bukkit and has grown in popularity since Bukkit's demise.

Cuberite

Cuberite is a highly efficient and extensively moddable Minecraft server, written in C++ and Lua. It achieves much better performances than the vanilla Minecraft server, but it is not fully compatible with the latest Minecraft client (some game aspects might be missing or not working).

The Cuberite Minecraft server can be installed as a cuberiteAUR package, which provides a simple web interface by default at port 8080 with which most server operations can easily be done through the browser. The cuberite PKGBUILD builds on top of the files from the minecraft-serverAUR package. This means that the cuberite server provides its own systemd unit files, cuberite script and corresponding script configuration file. The binary is called cuberite and is capable of fulfilling the same commands as minecraftd. The configuration file resides under /etc/conf.d/cuberite.

Be sure to read #Configuration and replace minecraftd with cuberite wherever you encounter it.

PaperMC

PaperMC is a Minecraft server, compatible with Spigot plugins which aims to offer better performance. It can be installed via papermcAUR.

Be sure to read #Configuration and replace minecraftd with papermc wherever you encounter it.

Forge

Forge is a widely used Minecraft modding API. The following server packages are available:

Be sure to read #Configuration and replace minecraftd with forged (forge-x.x.xd for legacy versions) wherever you encounter it.

Fabric

Fabric is a lightweight, experimental modding toolchain for Minecraft. The server package can be installed via fabric-serverAUR.

Be sure to read #Configuration and replace minecraftd with fabricd wherever you encounter it.

Quilt

Quilt is an open-source, community-driven modding toolchain designed primarily for Minecraft. The server package can be installed via quilt-serverAUR.

Be sure to read #Configuration and replace minecraftd with quiltd wherever you encounter it.

It is originally forked from Fabric, meaning it is mostly backwards compatible with Fabric mods.

Tips and tricks

Minecraft server port

この記事またはセクションは加筆を必要としています。
理由: Document SRV record support to allow the use of a non-default port without needing to specify the port when using domain names (議論: トーク:Minecraft/Java 版サーバー#)

By default Minecraft servers run on port 25565, this port is assumed if an address is entered without a port specified.

Most Minecraft server providers will charge a premium for a server with the default minecraft port, therefore if your port differs from 25565 you must specify the port by appending a colon (:) to the end of the hostname or address followed by the port which was allocated to your server, for example if you address was 43.12.122.96 and port was 28543 you would connect to 43.12.122.96:28543.

See also

  • There are several server wrappers available providing everything from automatic backup to managing dozens of servers in parallel; refer to Server Wrappers for more information. However, the management script provided by the AUR packages should suffice most needs.
  • You might want to set up a systemd timer with e.g. mapper to generate periodic maps of your world.
  • Be sure to take periodic backups e.g. using the provided management script (see #Configuration) or plain rsync.