Einrichtung eines Mehrspieler-Servers

From Vintage Story Wiki
This page is a translated version of the page Setting up a Multiplayer Server and the translation is 16% complete.
Outdated translations are marked like this.
Other languages:


Einfache Einrichtung

Lokaler Server

Wenn du ein temporäres Multiplayer-Erlebnis haben möchtest, reicht es, eine Einzelspielerwelt zu öffnen und dann im Escape-Menü auf "Open to Lan" zu klicken. Dies ermöglicht es Spielern in Ihrem lokalen Netzwerk, dem Spiel beizutreten. Wenn du Spielern außerhalb deines lokalen Netzwerks den Beitritt ermöglichen willst, kannst du auch auf "Open to Internet" klicken, wodurch versucht wird, eine externe Verbindung zu deinem Server aus dem Internet herzustellen. Dies geschieht über eine Technik namens UPnP, die auf deinem Internet-Router aktiviert sein muss, was oft standardmäßig der Fall ist. Kurz gesagt, wir schätzen, dass die Wahrscheinlichkeit, dass "Open to Internet" sofort und ohne Probleme funktioniert, bei etwa 60 % liegt. Wenn dies nicht der Fall ist, musst du eine so genannte "Portweiterleitung" auf deinem Internet-Router einrichten, was leider manchmal sehr schwierig und frustrierend sein kann. In diesem Fall musst du den TCP-Port 42420 an deinen Computer weiterleiten. (Google 'Portweiterleitung' mit dem Namen oder Modell Ihres Internet-Routers, um Hilfe zu finden.)

Damit dieser Server funktioniert, muss deine Einzelspielerwelt geöffnet bleiben.


Dedizierter Server

Alternativ wird das Spiel mit einem eigenen Serverprogramm ausgeliefert, das du starten und dauerhaft laufen lassen kannst, ohne dich selbst anmelden zu müssen. Es gibt mehrere Möglichkeiten, einen dedizierten Server einzurichten und laufen zu lassen.


Bezahlte Hosts

Einige kommerzielle Hosting-Dienste bieten kostenpflichtiges Server-Hosting an. Derzeit wird das Hosting von Vintage Story von den Entwicklern des Spiels angeboten sowie: PingPerfect, Citadel Server, Creeperhost, Akliz und GPortal

Dedizierte Server auf Windows

  • Geben Sie den Anwendungsordner für das Spiel ein, standardmäßig ist das %appdata%/VintageStory
  • Starte VintagestoryServer.exe
  • Möglicherweise musst du eine Portweiterleitung auf deinem Internet-Router einrichten, wenn der Server von außerhalb deines lokalen Netzwerks (Internet) erreichbar sein soll.

Dedizierte Server auf Linux

Hier wird beschrieben, wie du den Server als Dienst auf Linux-Systemen einrichtest.

Voraussetzungen für CentOS 7 (RHEL, Fedora, ...)

1. EPEL/screen/wget/curl Installation

 yum -y install epel-release screen wget curl

2. Mono Installation

 yum -y install yum-utils
 rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
 yum-config-manager --add-repo http://download.mono-project.com/repo/centos/
 yum -y install mono mono-devel

Voraussetzungen für Ubuntu (Debian, Mint, ...)

1. screen/wget/curl Installation

 sudo apt install -y screen wget curl

2. Mono Installation

Ab Vintage Story Version 1.12.7 und höher wird empfohlen, Mono Version 5 oder höher zu verwenden.
Dieses Tutorial wurde unter der Annahme geschrieben, dass Ubuntu 18.04 das Basis-Betriebssystem ist.
Um die neueste stabile Version für deine spezielle Distribution zu installieren, folge bitte den Anweisungen auf der Offiziellen Mono Projekt Download Seite.

 sudo apt install gnupg ca-certificates
 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
 echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
 sudo apt update
 sudo apt install -y mono-complete


3. Lade das Spiel herunter

Advice: Erstelle ein separates Verzeichnis für Vintage Story, da die tar.gz-Datei keine Unterordner enthält.

 mkdir server && cd server

Goto http://account.vintagestory.at/downloads
Copy the link of the newest "vs_server_*.*.*.tar.gz" package (Tar.gz Archive/Linux (server only) under Show other available downloads of Vintage Story)
Download with "wget" via console (Vintage Story version 1.12.9 in this example).

 wget https://cdn.vintagestory.at/gamefiles/stable/vs_server_1.12.9.tar.gz

4. Extract tar.gz package

 tar xzf vs_server_*.*.*.tar.gz

5. Make server.sh script executeable

 chmod +x server.sh

6. Edit server.sh file

For security reasons you should not run the server as root user, so by default USERNAME is set to vintagestory. On most linux operating systems you can create a user with the command adduser.

 adduser vintagestory

Then change these options for your needs:

 USERNAME='<your-vs-server-username>'
 VSPATH='<your-vs-directory>'

7. Open the port at the firewall (if needed)

firewalld

 firewall-cmd --permanent --zone=public --add-port=42420/tcp
 firewall-cmd --reload

iptables

 iptables -A INPUT -p tcp -m tcp --dport 42420 -j ACCEPT

8. Server start and first steps

 ./server.sh start
 Wait for the startup to finish, then you can give yourself OP with
 ./server.sh command "/op <youusername>"

9. Connect to your IP/Domain and have fun


Requirements for Alpine (Advanced, no support)

1. Install mono

As mono is in testing in Alpine, the testing URL (http://dl-cdn.alpinelinux.org/alpine/edge/testing) will have to be uncommented out in

 /etc/apk/repositories

after, run

 apk update
 apk add mono mono-dev

2. Install tmux

 apk add tmux

3. Certificates

 apk add ca-certificates

then run

 cert-sync /etc/ssl/certs/ca-certificates.crt

to update the certs.

4. Simplified Start Script

Download and extract the server into a location as normal, then put this into a script:

 #!/bin/ash
 mono VintagestoryServer.exe --dataPath ./data

This script will just run the server, putting the world save files into the same folder the server is extracted to. As an advanced user, you don't need to worry about having the dependancies, checking for new versions, or installing the server or save files under different users and locations.

Run the script in a tmux session.

The rest of the normal advice applies too (firewalling etc.).

Updating Servers

If you want to install a newer version, remove all installation files first, or you'll get unforseeable behavior. If you chose a data folder inside the installation folder, make sure to not delete that one, or you'll loose your save games, settings and player data. Download the "Tar.gz Archive/Linux (server only)" file and extract it. If you have a remote installation and only a FTP connection to your server, you will have to unpack it locally and upload each file.

Basic Configuration

Once your server is up and running you might want to look over some of the following configuration options. You can configure the server while its running through commands or by editing the serverconfig.json, for which the server needs to be stopped. On windows, by default this file is located at %appdata%/VintageStoryData/serverconfig.json. On Linux it's located at ./data/serverconfig.json of your server directory (e.g. /home/vintagestory/server/data/serverconfig.json if setup like described here)

Protip:
The easiest way to get a world configured to your wishes is to first create it in Single Player, using the advanced world creating options - and then upload it to use as your server world.


Explanation of values in serverconfig.json you can find here: Server Config

Here are some of the configurations set by commands, that you'd typically want to set.

  • /serverconfig upnp [0|1]
    If set to one, the game server will attempt to set up port forwarding for you
  • /serverconfig name Peaceful PvE Server
    Set up the server name, visible in the public server listing
  • /serverconfig description This is a medieval survival server, PvE only, everyone welcome! <3
    Set up the servers description, visible in the public server listing
  • /serverconfig motd Hi {playername}! Please remember to follow the rules!
    The message shown to players when they join
  • /serverconfig password asdaf
    Require a password for players to log in, if desired. Use /serverconfig nopassword to remove again.
  • /serverconfig advertise (1|0)
    Whether or not add this server to the public server listing

Lastly, you can configure a server that was created with the 'Open to Lan' method in the same way as you do for dedicated ones, be aware though, in that case a few of the configurations are overridden by the client, such as the save file location.

Acquiring server admin rights

If you have access to the server console, type /op playername. If not, open up the serverconfig.json and replace "StartupCommands": null, with "StartupCommands": "/op playername",

In both instances you should replace playername with your actual player name.

Advanced Dedicated Server

Debian with systemd service and rsyslog

If you prefer using systemd instead of screen to run your VS Server, you can follow these Instructions.
We also will setup rsyslog to split all logs into separate files.

Installation

1. mono Install Debian 9

 sudo apt install apt-transport-https dirmngr gnupg ca-certificates wget nano
 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
 echo "deb https://download.mono-project.com/repo/debian stable-stretch main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
 sudo apt update
 sudo apt install mono-devel

For Debian 10 use

 echo "deb https://download.mono-project.com/repo/debian stable-buster main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list

2. create a user

 adduser --shell /bin/bash --disabled-password gameserver

3. create directories

 mkdir -p /srv/gameserver/vintagestory
 mkdir -p /srv/gameserver/data/vs
 mkdir -p /usr/lib/systemd/system

3. Download the game

 cd /srv/gameserver/vintagestory

Goto http://account.vintagestory.at/downloads
Copy the link of the newest "vs_server_*.*.*.tar.gz" package (Tar.gz Archive/Linux (server only) under Show other available downloads of Vintage Story)
Download with "wget" via console (Vintage Story version 1.12.9 in this example).

 wget https://cdn.vintagestory.at/gamefiles/stable/vs_server_1.12.9.tar.gz

4. Extract tar.gz package

 tar xzf vs_server_1.12.9.tar.gz

5. Change owner

You have to set the owner of your gameserver directory to avoid write permission errors

 chown -R gameserver:gameserver /srv/gameserver

6. Create systemd service unit file

Use your favourite tool to create a service unit file (this example uses nano)

 nano /usr/lib/systemd/system/vintagestoryserver.service

Insert the following content

 [Unit]
 Description=Vintage Story Server Unit
 After=network.target
 
 [Service]
 WorkingDirectory=/srv/gameserver/vintagestory
 ExecStart=/usr/bin/mono VintagestoryServer.exe --dataPath /srv/gameserver/data/vs
 Restart=always
 RestartSec=30
 StandardOutput=syslog
 StandardError=syslog
 SyslogIdentifier=VSSRV
 User=gameserver
 Group=gameserver
 
 [Install]
 WantedBy=multi-user.target

7. Create config file for rsyslog

Use your favourite tool to create a rsyslog config file (this example uses nano)

 nano /etc/rsyslog.d/vintagestoryserver.conf

Insert the following content

 if $programname == 'VSSRV' then {
     if($msg contains "Chat") then {
         action(type="omfile" dirCreateMode="0755" FileCreateMode="0644" File="/var/log/vintagestory-server/chat.log")
     } else if($msg contains "verließ") then {
         action(type="omfile" dirCreateMode="0755" FileCreateMode="0644" File="/var/log/vintagestory-server/login.log")
     } else if($msg contains "join") then {
         action(type="omfile" dirCreateMode="0755" FileCreateMode="0644" File="/var/log/vintagestory-server/login.log")
     } else if($msg contains "Server Warning") then {
         action(type="omfile" dirCreateMode="0755" FileCreateMode="0644" File="/var/log/vintagestory-server/warn.log")
     } else if($msg contains "Server Notification") then {
         action(type="omfile" dirCreateMode="0755" FileCreateMode="0644" File="/var/log/vintagestory-server/info.log")
     } else if($msg contains "Server Debug") then {
         action(type="omfile" dirCreateMode="0755" FileCreateMode="0644" File="/var/log/vintagestory-server/debug.log")
     } else if($msg contains "Server Event") then {
         action(type="omfile" dirCreateMode="0755" FileCreateMode="0644" File="/var/log/vintagestory-server/event.log")
     } else {
         action(type="omfile" dirCreateMode="0755" FileCreateMode="0644" File="/var/log/vintagestory-server/other.log")
     }
 }
 # Discard 
 if $programname == 'VSSRV' then ~

8. restart rsyslog / enable service To activate rsyslog and your vintagestory server type these commands

 systemctl restart rsyslog.service;
 systemctl enable vintagestoryserver.service
 systemctl start vintagestoryserver.service

Stop, Start, Disable Server

To manually stop your VS Server use this command

 systemctl stop vintagestoryserver.service

To manually start your VS Server again type

 systemctl start vintagestoryserver.service

To disable the service use

 systemctl disable vintagestoryserver.service

Config

to change your servers configuration, stop the server and edit

 nano /srv/gameserver/data/vs/serverconfig.json

After you saved your changes, start server again.

Restart schedule

If you want your server to restart every day, you can setup a cronjob for this

 crontab -e

insert this line to stop the server at 04:30

 30 4 * * *      systemctl stop vintagestoryserver.service

you could now ececute backup tasks and then start it again with the next line at 04:32 (if you run a backup task plan some more time here)

 32 4 * * *      systemctl start vintagestoryserver

If you just want to restart the server this line instead of the other two should be fine

 30 4 * * *      systemctl restart vintagestoryserver.service

Logging

The rsyslog config splits the output logs into seperate files that you can watch with tail command
For Login/Logout see

 tail -f /var/log/vintagestory-server/login.log

For all chat messages see

 tail -f /var/log/vintagestory-server/chat.log

For all messages containing [Server Warning] see

 tail -f /var/log/vintagestory-server/warn.log

For all messages containing [Server Notification] see

 tail -f /var/log/vintagestory-server/info.log

For all messages containing [Server Debug] see

 tail -f /var/log/vintagestory-server/debug.log

For all messages containing [Server Event] see

 tail -f /var/log/vintagestory-server/event.log

For all other messages see

 tail -f /var/log/vintagestory-server/other.log

Multiple Server Instances

If you want to run multiple instances on the same machine you just have to redo some of the steps above. This is just an example for a second instance:

 mkdir -p /srv/gameserver/data/vs2
 nano /usr/lib/systemd/system/vintagestoryserver2.service

Copy from step 6 and change these lines:

 Description=Vintage Story Server 2 Unit
 ExecStart=/usr/bin/mono VintagestoryServer.exe --dataPath /srv/gameserver/data/vs2
 SyslogIdentifier=VSSRV2

Create rsyslog file and copy code from step 7

 nano /etc/rsyslog.d/vintagestoryserver2.conf

Change VSSRV to VSSRV2 and /var/log/vintagestory-server to /var/log/vintagestory-server2
Before you proceed make a copy of your first server configuration and edit it for your needs (change port!!!)

 cp /srv/gameserver/data/vs/serverconfig.json /srv/gameserver/data/vs2/
 nano /srv/gameserver/data/vs2/serverconfig.json

Now start the service

 systemctl restart rsyslog.service;
 systemctl enable vintagestoryserver2.service
 systemctl start vintagestoryserver2.service

Install cronjob

 crontab -e

Insert

 30 4 * * *      systemctl restart vintagestoryserver2.service

Have Fun!