29 mai 2019

Minecraft server

Minecraft server enable to create a virtual world. Then you can connect from Minecraft from "Multiplayer".

Requirements

Installing Java is mandatory.

apt install default-jre screen nano wget git
apt install software-properties-common
apt install openjdk-16-jdk-headless

Init

Download the server binary located here : https://www.minecraft.net/fr-fr/download/server/.

Then you need to accept EULA by editing the file EULA.txt generated after launching the server for the first time.

Manual method

java -Xmx1024M -Xms1024M -jar minecraft_server.1.17.jar nogui

Screen method

Starting server :

screen -S minecraft -d -m java -Xmx1024M -Xms1024M -jar server.jar nogui

Displaying launched program :
screen -ls will list "screened" programs
screen -r minecraft will show you the terminal where your program is launched
Ctrl + a > c will let you go back to your initial terminal

Service method

Install following code to /etc/systemd/system/minecraft_server.service :

[Unit] Description=Minecraft server

[Service]
User=minecraft
# The configuration file application.properties should be here:
WorkingDirectory=/opt/minecraft/servers/myserver
ExecStart=/usr/bin/java -Xmx1024M -Xms1024M -jar ./server.jar nogui
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Reload service file :

systemctl daemon-reload

Start :

service minecraft_server start

Stop :

service minecraft_server stop

Minecraft commands

To exit the program :
/stop

For help : /help

WSL 2 upgrade on windows

Few days ago I would like to use docker from windows with docker composer. And because I am using ansible, I found easier to deal from Linux...