山城淑敬.jp

Since:2002.05.02 連絡先: shukukei@mojizuri.jp

PaperでMinecraftマルチプレイサーバを立ててみた

今回は“Paper”をインストールしてみました。


検証に使用したサーバのスペックは以下の通りです。
OS:Ubuntu 20.04 LTS (x86_64)
CPU:2コア
RAM:1GB

Java 11を使用したところ以下のようなワーニングが発生しました。

WARNING: Java 9 currently causes significant issues for a lot of Bukkit plugins due to new ClassLoading semantics.
WARNING: For the time being, it is recommended to stick with Java 8 until plugins are updated.
問題になる場合はuniverseリポジトリからJava 8をインストールして使用します。

# apt install software-properties-common
# add-apt-repository universe
# apt install openjdk-8-jre-headless
複数バージョンのJavaがインストールされている環境で、使用するJavaのバージョンを変更するためには次のコマンドを実行します。

# update-alternatives --config java
 There are 2 choices for the alternative java (providing /usr/bin/java).
 
   Selection    Path                                            Priority   Status
 ------------------------------------------------------------
 * 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
   1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
   2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode
今回は使用するJavaのバージョンは変更せず、Java 11を使用しました。

# apt install screen default-jre-headless openjdk-8-jre-headless
# su - minecraft
$ mkdir paper
$ cd paper
$ wget -O paper-1.12.2.jar https://papermc.io/api/v1/paper/1.12.2/latest/download

さっそく実行してみます。

$ java -Xms1G -Xmx1G -jar paper-1.12.2.jar
 WARNING: Java 9 currently causes significant issues for a lot of Bukkit plugins due to new ClassLoading semantics.
 WARNING: For the time being, it is recommended to stick with Java 8 until plugins are updated.
 Downloading original jar...
 Patching original jar...
 Loading libraries, please wait...
 [02:31:04 INFO]: Starting minecraft server version 1.12.2
 [02:31:04 INFO]: Loading properties
 [02:31:04 WARN]: server.properties does not exist
 [02:31:04 INFO]: Generating new properties file
 [02:31:04 WARN]: Failed to load eula.txt
 [02:31:04 INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
 [02:31:04 INFO]: Stopping server

EULAを読んで同意できる場合はeula.txtを編集してeula=trueとします。

$ vi eula.txt
 #By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
 #and also agreeing that tacos are tasty.
 #Sun Jun 07 02:31:04 JST 2020
 eula=true

再び実行してみます。

$ java -Xms1G -Xmx1G -jar paper-1.12.2.jar
 WARNING: Java 9 currently causes significant issues for a lot of Bukkit plugins due to new ClassLoading semantics.
 WARNING: For the time being, it is recommended to stick with Java 8 until plugins are updated.
 Loading libraries, please wait...
 [02:34:39 INFO]: Starting minecraft server version 1.12.2
 [02:34:39 INFO]: Loading properties
 [02:34:39 INFO]: Default game type: SURVIVAL
 [02:34:39 INFO]: This server is running Paper version git-Paper-1618 (MC: 1.12.2) (Implementing API version 1.12.2-R0.1-SNAPSHOT)
 [02:34:39 INFO]: Debug logging is disabled
 [02:34:39 INFO]: Server Ping Player Sample Count: 12
 [02:34:39 INFO]: Using 4 threads for Netty based IO
 [02:34:40 INFO]: Generating keypair
 [02:34:40 INFO]: Starting Minecraft server on *:25565
 [02:34:40 INFO]: Using epoll channel type
 [02:34:40 INFO]: **** Beginning UUID conversion, this may take A LONG time ****
 
 
 ~中略~
 
 
 [02:34:52 INFO]: Done (11.632s)! For help, type "help" or "?"
 [02:34:52 INFO]: Timings Reset
 > help
 [02:35:25 INFO]: --------- Help: Index ---------------------------
 [02:35:25 INFO]: Use /help [n] to get page n of help.
 [02:35:25 INFO]: Aliases: Lists command aliases
 [02:35:25 INFO]: Bukkit: All commands for Bukkit
 [02:35:25 INFO]: Minecraft: All commands for Minecraft
 [02:35:25 INFO]: /advancement: A Mojang provided command.
 [02:35:25 INFO]: /ban: A Mojang provided command.
 [02:35:25 INFO]: /ban-ip: A Mojang provided command.
 [02:35:25 INFO]: /banlist: A Mojang provided command.
 [02:35:25 INFO]: /blockdata: A Mojang provided command.
 [02:35:25 INFO]: /clear: A Mojang provided command.
 [02:35:25 INFO]: /clone: A Mojang provided command.
 [02:35:25 INFO]: /debug: A Mojang provided command.
 [02:35:25 INFO]: /defaultgamemode: A Mojang provided command.
 [02:35:25 INFO]: /deop: A Mojang provided command.
 [02:35:25 INFO]: /difficulty: A Mojang provided command.
 [02:35:25 INFO]: /effect: A Mojang provided command.
 [02:35:25 INFO]: /enchant: A Mojang provided command.
 [02:35:25 INFO]: /entitydata: A Mojang provided command.
 [02:35:25 INFO]: /execute: A Mojang provided command.
 [02:35:25 INFO]: /fill: A Mojang provided command.
 [02:35:25 INFO]: /function: A Mojang provided command.
 [02:35:25 INFO]: /gamemode: A Mojang provided command.
 [02:35:25 INFO]: /gamerule: A Mojang provided command.
 [02:35:25 INFO]: /give: A Mojang provided command.
 [02:35:25 INFO]: /help: Shows the help menu
 [02:35:25 INFO]: /kick: A Mojang provided command.
 [02:35:25 INFO]: /kill: A Mojang provided command.
 [02:35:25 INFO]: /list: A Mojang provided command.
 [02:35:25 INFO]: /locate: A Mojang provided command.
 [02:35:25 INFO]: /me: A Mojang provided command.
 [02:35:25 INFO]: /minecraft:help: A Mojang provided command.
 [02:35:25 INFO]: /minecraft:reload: A Mojang provided command.
 [02:35:25 INFO]: /minecraft:tell: A Mojang provided command.
 [02:35:25 INFO]: /op: A Mojang provided command.
 [02:35:25 INFO]: /paper: Paper related commands
 [02:35:25 INFO]: /pardon: A Mojang provided command.
 [02:35:25 INFO]: /pardon-ip: A Mojang provided command.
 [02:35:25 INFO]: /particle: A Mojang provided command.
 [02:35:25 INFO]: /playsound: A Mojang provided command.
 [02:35:25 INFO]: /plugins: Gets a list of plugins running on the server
 [02:35:25 INFO]: /recipe: A Mojang provided command.
 [02:35:25 INFO]: /reload: Reloads the server configuration and plugins
 [02:35:25 INFO]: /replaceitem: A Mojang provided command.
 [02:35:25 INFO]: /restart: Restarts the server
 [02:35:25 INFO]: /save-all: A Mojang provided command.
 [02:35:25 INFO]: /save-off: A Mojang provided command.
 [02:35:25 INFO]: /save-on: A Mojang provided command.
 [02:35:25 INFO]: /say: A Mojang provided command.
 [02:35:25 INFO]: /scoreboard: A Mojang provided command.
 [02:35:25 INFO]: /seed: A Mojang provided command.
 [02:35:25 INFO]: /setblock: A Mojang provided command.
 [02:35:25 INFO]: /setidletimeout: A Mojang provided command.
 [02:35:25 INFO]: /setworldspawn: A Mojang provided command.
 [02:35:25 INFO]: /spawnpoint: A Mojang provided command.
 [02:35:25 INFO]: /spigot: Spigot related commands
 [02:35:25 INFO]: /spreadplayers: A Mojang provided command.
 [02:35:25 INFO]: /stats: A Mojang provided command.
 [02:35:25 INFO]: /stop: A Mojang provided command.
 [02:35:25 INFO]: /stopsound: A Mojang provided command.
 [02:35:25 INFO]: /summon: A Mojang provided command.
 [02:35:25 INFO]: /teleport: A Mojang provided command.
 [02:35:25 INFO]: /tell: A Mojang provided command.
 [02:35:25 INFO]: /tellraw: A Mojang provided command.
 [02:35:25 INFO]: /testfor: A Mojang provided command.
 [02:35:25 INFO]: /testforblock: A Mojang provided command.
 [02:35:25 INFO]: /testforblocks: A Mojang provided command.
 [02:35:25 INFO]: /time: A Mojang provided command.
 [02:35:25 INFO]: /timings: Manages Spigot Timings data to see performance of the server.
 [02:35:25 INFO]: /title: A Mojang provided command.
 [02:35:25 INFO]: /toggledownfall: A Mojang provided command.
 [02:35:25 INFO]: /tp: A Mojang provided command.
 [02:35:25 INFO]: /tps: Gets the current ticks per second for the server
 [02:35:25 INFO]: /trigger: A Mojang provided command.
 [02:35:25 INFO]: /version: Gets the version of this server including any plugins in use
 [02:35:25 INFO]: /weather: A Mojang provided command.
 [02:35:25 INFO]: /whitelist: A Mojang provided command.
 [02:35:25 INFO]: /worldborder: A Mojang provided command.
 [02:35:25 INFO]: /xp: A Mojang provided command.

実際の運用ではSystemdを使いたいため、設定を行います。

# vi /etc/systemd/system/paper.service
 [Unit]
 Description=Paper server
 After=network.target
 
 [Service]
 Type=simple
 User=minecraft
 WorkingDirectory=/home/minecraft/paper
 ExecStart=/usr/bin/sh -c '/usr/bin/screen -DmS PaperScreen /usr/bin/java -Xms1G -Xmx1G -XX:+UseG1GC -jar /home/minecraft/paper/paper-1.12.2.jar --noconsole'
 ExecStop=/usr/bin/screen -S PaperScreen -X eval 'stuff "save-all"\\015'
 ExecStop=/usr/bin/screen -S PaperScreen -X eval 'stuff "stop"\\015'
 
 TimeoutStartSec=15
 TimeoutStopSec=60
 Restart=on-failure
 
 [Install]
 WantedBy=multi-user.target

# systemctl daemon-reload

主な操作方法は以下の通りです。
・起動させるとき
  # systemctl start paper.service
・終了させるとき
  # systemctl stop paper.service
・サーバ起動時に自動的に起動させるとき
  # systemctl enable paper.service
・現在の状態を確認するとき
  # systemctl status paper.service
・ログを確認するとき
  # journalctl -u paper.service

Paperの設定についてはオンラインドキュメントを参照して行います。
https://paper.readthedocs.io/

JVMの設定については『Tuning the JVM – G1GC Garbage Collector Flags for Minecraft』を参考に調整を行いたいと考えています。