Instalacja serwera Minecraft na Ubuntu 20.04
Poniższy poradnik opisuje w jaki sposób dokonamy instalacji serwera Minecraft  na Ubuntu 20.04.
Całość wykonamy za pomocą kilku kroków.
Logujemy się do konsoli jako root i dokonujemy aktualizacji repozytoriów i systemu:
1 2  | apt-get update -y apt-get upgrade -y  | 
Kolejny krok to instalacja git
1  | apt-get install git build-essential -y  | 
Czas na instalację javy wykonamy to poleceniem:
1  | apt-get install openjdk-11-jre-headless -y  | 
Wersje javy możemy zweryfikować wydając polecenie:
1  | java -version  | 
Poniżej wynik:
1 2 3  | openjdk version "11.0.7" 2020-04-14 OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1) OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)  | 
Przechodzimy do instalacji serwera Minecraft
Na początek dodajemy użytkownika do systemu:
1  | useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft  | 
Przelogowujemy się na tego użytkownika:
1  | su - minecraft  | 
Tworzymy katalogi:
1  | mkdir ~/backups ~/tools ~/server  | 
Kolejny krok to instalacja mcron. Pobieramy go wydając polecenie:
1  | git clone https://github.com/Tiiffi/mcrcon.git ~/tools/mcrcon  | 
Następnie:
1 2  | cd ~/tools/mcrcon gcc -std=gnu11 -pedantic -Wall -Wextra -O2 -s -o mcrcon mcrcon.c  | 
Pobieramy serwer minecraft
1  | wget https://launcher.mojang.com/v1/objects/a0d03225615ba897619220e256a266cb33a44b6b/server.jar -P ~/server  | 
Możemy go uruchomić:
1 2  | cd ~/server java -Xmx1024M -Xms1024M -jar server.jar nogui  | 
Najprawdopodobniej zobaczymy błądo braku zgody licencyjnej jak w logu poniżej:
1 2 3  | [07:46:12] [main/ERROR]: Failed to load properties from file: server.properties [07:46:12] [main/WARN]: Failed to load eula.txt [07:46:12] [main/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.  | 
Edytujemy plik
1  | nano ~/server/eula.txt  | 
I zmieniamy z false na true
1  | eula=true  | 
Kolejny krok to nadanie hasła rcon
Edytujemy plik:
1  | nano ~/server/server.properties  | 
I konfigurujemy w następujący sposób podając swoje hasło:
1 2  | rcon.password=NASZEHASŁO enable-rcon=true   | 
Tworzymy demona usługi:
1  | nano /etc/systemd/system/minecraft.service  | 
O zawartości:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  | [Unit] Description=Minecraft Server After=network.target [Service] User=minecraft Nice=1 KillMode=none SuccessExitStatus=0 1 ProtectHome=true ProtectSystem=full PrivateDevices=true NoNewPrivileges=true WorkingDirectory=/opt/minecraft/server ExecStart=/usr/bin/java -Xmx1024M -Xms1024M -jar server.jar nogui ExecStop=/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p NASZEHASŁO stop [Install] WantedBy=multi-user.target  | 
Przeładowujemy demona i uruchamiamy usługę:
1 2 3  | systemctl daemon-reload systemctl start minecraft systemctl enable minecraft  | 
Po sprawdzeniu statusu poleceniem:
1  | systemctl status minecraft  | 
Powinniśmy już widzieć uruchomiony nasz serwer minecraft:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  |  minecraft.service - Minecraft Server      Loaded: loaded (/etc/systemd/system/minecraft.service; disabled; vendor preset: enabled)      Active: active (running) since Thu 2020-07-02 08:05:24 UTC; 1min 0s ago    Main PID: 11704 (java)       Tasks: 30 (limit: 4691)      Memory: 1.0G      CGroup: /system.slice/minecraft.service              ??11704 /usr/bin/java -Xmx1024M -Xms1024M -jar server.jar nogui Jul 02 08:06:06 ubuntu2004 java[11704]: [08:06:06] [Worker-Main-2/INFO]: Preparing spawn area: 94% Jul 02 08:06:06 ubuntu2004 java[11704]: [08:06:06] [Server thread/INFO]: Preparing spawn area: 95% Jul 02 08:06:07 ubuntu2004 java[11704]: [08:06:07] [Worker-Main-2/INFO]: Preparing spawn area: 96% Jul 02 08:06:07 ubuntu2004 java[11704]: [08:06:07] [Worker-Main-2/INFO]: Preparing spawn area: 96% Jul 02 08:06:08 ubuntu2004 java[11704]: [08:06:08] [Worker-Main-2/INFO]: Preparing spawn area: 99% Jul 02 08:06:08 ubuntu2004 java[11704]: [08:06:08] [Server thread/INFO]: Time elapsed: 26283 ms Jul 02 08:06:08 ubuntu2004 java[11704]: [08:06:08] [Server thread/INFO]: Done (26.613s)! For help, type "help" Jul 02 08:06:08 ubuntu2004 java[11704]: [08:06:08] [Server thread/INFO]: Starting remote control listener Jul 02 08:06:08 ubuntu2004 java[11704]: [08:06:08] [Server thread/INFO]: Thread RCON Listener started Jul 02 08:06:08 ubuntu2004 java[11704]: [08:06:08] [RCON Listener #1/INFO]: RCON running on 0.0.0.  | 
Konsolę minecraft możemy uruchomić wydając polecenie:
1  | /opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p NASZEHASLO -t  | 





