Server Setup

From GT New Horizons
Revision as of 17:18, 11 March 2023 by Fiyorin (talk | contribs) (add download link)

Jump to:


edit 

Java9 Servers

Java9 servers should be fully configured as downloaded. For additional instructions consult https://github.com/GTNewHorizons/lwjgl3ify#server

Server Update (All Platforms)

  1. Download a new server version of GTNH.
  2. Backup your server folder.
  3. Delete the config, mods, resources and scripts folders from your server folder.
  4. Replace the deleted folders with the ones from the downloaded archive.
  5. Port over any customized config settings. Use your backup as a reference.
  6. Move over JourneymapServer\world.cfg. this file contains your world uuid. If this file is lost server would generate new map uuid and clients would lose their journeymap map data for your server.

Server Setup for Linux (Oracle Cloud)

Warnings

  • In less than half a year, Oracle has changed the terms of the Always Free tier from 4 TPU cores and 24 GB ram to 3k OCPU hours and 18k GB RAM hours. They can change the rules again in the future. Be wary.
  • Your Oracle account will be terminated if you connect to the instance through VPN, so don't.
  • Backup your server periodically to a non-Oracle platform, so you don't suddenly discover that your account was terminated along with all data.

Introduction

This Linux setup uses an Oracle blogpost about how to set up a server on their platform.

You will need a debit/credit card on the signup step. Oracle will withdraw 1 Euro and put it back to check that the card is valid.

As of February 2023, you can have a free server with 4 OCPU cores, 24GB RAM, and 200 GB storage on the Oracle platform.

This setup was tested on the GTNH version 2.2.3.

The steps are as follows:

  1. Sign up for Oracle Cloud.
  2. Set up an instance.
  3. Set up a GTNH server.
  4. Install software that regularly backs up the server.

The only hurdle during the signup step is that the debit/plastic card is mandatory. It also takes roughly a minute for the system to create your account.

You might encounter the "Out of capacity" error when you request an instance in some of the available regions. In that case if you really need an instance in this region, please try again after a while. Due to the popularity of the service, it can take up to two months until you are able to create an instance in this region.

Set up an instance

Create an instance

This step is taken from the Oracle's manual, so check it out if you need more info. A concise version of it is given in this guide.

Go to "Create a VM instance". VM means Virtual Machine. This action should be in Quick Actions or in the dropdown menu that is on the upper left.

You will be presented with many fields. First is the server name. Choose whatever you see fit -- this name will not be shown anywhere on the GTNH server.

Compartment is just a way to organize machines, so you can leave it as it is.

Availability Domain can be left defaults too, however do mind that you can accidentally choose something that is not in the Always Free price tier if you change it.

The important part is the Image and Shape section. That's where you select what Operating System (OS) and hardware your server is going to use.

In Image, this guide suggests to use the Oracle Linux Cloud Developer image because it requires less actions to set up at the cost of taking more space. Alternatively, you can use the Oracle Linux image to reduce the bloat, but you will need to install Java 8 on it by yourself.

In Shape, select Ampere architecture. The current free tier allows 4 CPUs and 24GB RAM, so if you don't plan to host more servers, might as well use the full capacity that you are given (4 CPUs, 24 GB RAM). After you selected the Shape, check that you still have the Always Free Eligible tag near it. If you don't, you might have selected something wrong.

Next up is the Networking part. Select "Create new cloud network" and "Create new public subnet" if it's your first instance, or use the already-existing nets if not.

Also select "Assign a public IPv4 address". You will use this address to connect to the server.

Next is the SSH part. You can google how it works -- this guide will describe one of the options without getting into details. Select "Generate SSH key pair", then download the private key and save it -- you will need it every time you log into the instance.

Leave the Boot volume defaults and press Create. This will start the process of creating the instance.

You will see the yellow sign on the left that says "Provisioning". After a minute, it will change to green "Running". It means you can connect to the instance. Note the fields Username and Public IP Address -- you will need them.

Set up network rules

When your Instance Details turns green and Running, click on the Subnet link in the Primary VNIC section. Then in Security Lists click on the only one that is there, the default one, then click on Add Ingress Rules.

You need to add two rules, one for each IP protocol. One for TCP, and one for UDP. Here's what you need to put in:

  • Stateless field unchecked.
  • Source type: CIDR.
  • Source CIDR: 0.0.0.0/0.
  • IP protocol: first rule TCP, second rule UDP.
  • Source port range: leave it empty.
  • Destination port range: 25565.

When you filled out the two rules, press Add Ingress Rules.

Tweak the instance

In order to connect to the instance, you need a "shell" program. If you're on Windows, this guide suggests to install Git Bash for that.

When you launch Git Bash, use the following command to connect to the instance:

ssh opc@instance_IP -i path_to_SSH_key

A finished example can look like this:

ssh opc@144.24.170.229 -i ~/ssh-key-2022-09-07.key
  • ssh is the name of the command,
  • opc is the user name,
  • @ can be read as "at",
  • 144.24.170.229 is the IPv4 address of the instance,
  • -i is the flag that tells ssh to use a file as a password,
  • ~/ssh-key-2022-09-07.key is the path to the private key that you downloaded.

"~" is the shortcut to your user folder that is usually located at C:/Users/%Username%. It was given just as an example of how to circumvent the issues of linux-to-windows pathing in GitBash by placing your key somewhere in your user folder.

Okay, you connected to the instance, now what? The upside of the image Oracle Linux Cloud Developer that we chose during the installation is that we don't need to bother installing Java 8 because it's pre-installed -- we just need to choose it among other versions. Type in the following to start the choice:

sudo alternatives --config java

You will be given a list of numbers and names. Type in the number that corresponds to java-1.8.0-openjdk.aarch64.

There are 8 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
   1           java-1.8.0-openjdk.aarch64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-1.el8_5.aarch64/jre/bin/java)
   2           java-11-openjdk.aarch64 (/usr/lib/jvm/java-11-openjdk-11.0.15.0.9-2.el8_5.aarch64/bin/java)
   3           /usr/java/jre1.8.0_311-aarch64/bin/java
   4           /usr/java/jdk1.8.0_311-aarch64/bin/java
*  5           /usr/java/jdk-17.0.1/bin/java
   6           /usr/java/jdk-11.0.13/bin/java
   7           /usr/lib64/graalvm/graalvm22-ee-java11/bin/java
 + 8           /usr/lib64/graalvm/graalvm22-ee-java17/bin/java

Enter to keep the current selection[+], or type selection number: 1

Other options that use Java 8 (also called 1.8.0) might work but they were not tested.

If you have chosen the bare Image at the installation step, you would use "yum list jdk*" to see available java versions and then install java1.8 which is the screen name of Java 8.

The next step is to tell the instance firewall to let the connections through:

sudo firewall-cmd --permanent --zone=public --add-port=25565/tcp
sudo firewall-cmd --permanent --zone=public --add-port=25565/udp
sudo firewall-cmd --reload

Set up a GTNH server

1. Download the server zip from here: http://downloads.gtnewhorizons.com/ServerPacks/

wget http://downloads.gtnewhorizons.com/ServerPacks/GT_New_Horizons_server_version_SERVER.zip

2. Check that you have unzip installed with "yum list unzip*". Install it if you didn't have it on the server.

3. Unzip the server into a folder

unzip server.zip -d destination

The complete command might be like:

unzip GTNH-1.7.10-2.1.2.3qf.zip -d ~/minecraft_server

4. In the server folder, agree to Minecraft End User License Agreement (EULA):

cd your_minecraft_server_folder
echo "eula=true" > eula.txt

You should have eula.txt in your server folder after this command.

5. Launch the server to test that things work:

bash startserver.sh

It will take several minutes to launch. The last line will likely be from [FML] about unloading world 1.

6. Whitelist yourself to get on the server:

whitelist add your_nick

so it will look like

whitelist add jonsnowwastaken

7. Connect to your server:

In client, use the same IPv4 that you used to connect through SSH and the port 25565 -- the default one for minecraft servers.

instance_IP:25565

8. Stop the server. We're not done with setting things up:

stop

After shutting down, it will begin the countdown to reboot, so press Ctrl+C to stop it completely.

Install a mod for backups

Two mods are needed to back up your server: FTB-Utilities and FTB-Library.

Below is an example of how the process can go. Check if it's the most recent version of the mods before proceeding.

It would be most convenient to download the mods directly through the "wget" command to the "mods" folder on the server:

cd server_directory/mods
wget https://github.com/GTNewHorizons/FTB-Utilities/releases/download/1.0.18.7-GTNH/FTBUtilities-1.7.10-1.0.18.7-GTNH.jar
wget https://github.com/GTNewHorizons/FTB-Library/releases/download/1.0.18.5-GTNH/FTBLib-1.7.10-1.0.18.5-GTNH.jar

If wget fails, we can download the mods directly.

Download the mods on your machine and copy them to the server through the scp command:

scp -i path_to_private_SSH_key path_to_FTBUtilities_on_your_computer opc@instance_ip:server_folder/mods/FTBUtilities_full_name.jar
scp -i path_to_private_SSH_key path_to_FTBLib_on_your_computer opc@instance_ip:server_folder/mods/FTBLib_full_name.jar

A finished example might look like this:

scp -i ~/.ssh/ssh-key-2022-09-07.key ~/Downloads/FTBUtilities-1.7.10-1.0.18.7-GTNH.jar opc@144.24.170.228:~/minecraft-server/mods/FTBUtilities-1.7.10-1.0.18.7-GTNH.jar
scp -i ~/.ssh/ssh-key-2022-09-07.key ~/Downloads/FTBLib-1.7.10-1.0.18.5-GTNH.jar opc@144.24.170.228:~/minecraft-server/mods/FTBLib-1.7.10-1.0.18.5-GTNH.jar
  • scp is the comand that stands for "secure copy",
  • -i is the flag that says to use the file to identify youself, like we did with ssh,
  • ~/.ssh/ssh-key-2022-09-07.key is the example of the path to the key, ~ is the shortcut for you user folder,
  • ~/Downloads/FTBLib.jar is the location of the mod jar on your computer,
  • opc@144.24.170.228:~/minecraft-server/mods/FTBLib-1.7.10-1.0.18.5-GTNH.jar is the location of the resulting file on the server.

Now you can launch your server again to check if the backup works.

A backup should be visible in the log immediately after the server is done loading.

The default frequency of the backups is once every two hours. To make the backups more frequent, open the config file that is created after the server is launched for the first time with the backup mods.

cd server_folder/local/ftbu
vim config.json
  1. In Vim, press "i" to go into an -- INSERT -- mode. It should be shown at the bottom of the command line.
  2. The backup settings are located at the top of the file in the "backups" section.
  3. Locate the line "backup_timer". Its default value should be 2.0, which stands for two hours.
  4. If you want to make a backup every 30 minutes, change the value to 0.5.
  5. You might want to increase the value in the line "backups_to_keep" to keep more backups. When the number reaches the specified maximum, the oldest backup is deleted.
  6. You might also change the folder where the backups are saved by changing the address in the "folder" line. The default works too.
  7. To exit vim and save the changes, first press Escape to exit the insert mode, then press ":wq", which means Write and Quit.
  8. If you get an error on this step and can't write into the file, check the file permissions. Although if the error is about that you can't write into the file and that's your default user, that likely means that you launched the server as root before, which can lead to many complications later, so please don't launch a server as root.

After that, we come to the last step in this manual -- actually testing that the backup works:

  1. Stop the server.
  2. Locate the "backup/" folder. By default it's in your server folder.
  3. Copy your world folder that is usually called "World/" to a place outside the server folder just in case the backup is broken.
  4. Delete your world folder in the server folder.
  5. Unzip the backup in the place of a deleted folder.
  6. Launch the server again to see if the backup is fine.

It's suggested to keep your world folder named World to prevent further complications.

If you want to use a different option, like AromaBackup, please refer to the page Backups and Recovery.

Run the server

So, you can launch the server, but when you leave the ssh connection, the server closes. That happens because together your ssh connection keeps things running.

To make the server run without you being connected to the ssh, one of the solutions is to use the "screen" command.

# Connect to the instance
ssh opc@instance_IP -i path_to_SSH_key

# Check that screen is installed
screen --version

# Initiate a screen
screen

# Start the server
cd server_folder
bash startserver.sh

To detach from the screen without terminating it, use Ctrl+A and then Ctrl+D.

To reattach to the screen, use

screen -r

There are more options that you can use with this command, such as multiple named screens. You can check this manual for the instructions.

Improvements

More Space

It's very likely that 50GB will not be enough for a lategame server. You will need more storage space.

You can create an additional volume to attach to your instance.

Oracle gives 200GB for free, and the default instance takes 47GB, so it's safe to create a 150GB block-volume, as Oracle calls it.

In short, you will do the following:

  1. Create a 150GB block-volume. Use this manual. Make a 150GB volume instead of 50GB that is in the guide.
  2. Attach the block-volume to your instance on the site. Use the same manual.
  3. Attach the block-volume in the virtual machine. Use the same manual.
  4. Format the block-volume. This tutorial likely has the right information, but it is not certain. Please check it in other sources before applying.
  5. Mount the block-volume. Same as the step above -- the info was forgotten, so please check what is written in the manual.
  6. Either move the whole server to the new block-volume or move only backups. Better to move the whole server in order to reduce the chance of error.
  7. Optionally, you can make the block-volume to mount automatically when the instance launches. Use this manual. However, be very careful on this step. As written at the bottom of the manual, you can brick your instance if you make a mistake and would have to use the site-console to revert changes. However, the result is well worth it -- you won't have to remember how to mount a block-volume if you need to restart the instance.

Chunk Loading

The 16x16 pieces of the world are called chunks. When a player loads into the world, the server starts to simulate the chunks around them -- it loads these chunks. You want some chunks to remain loaded when you're away. For example, for the machines to continue working, or for the crops to grow.

To have the functionality to load chunks, you need to add two mods both to the client and server -- FTB-Utilities and FTB-Library. To add the mods, copy .jar files to the "mods" folders -- two jars in total. The exact commands for that are provided in the "mods for backups" chapter above.

After adding the mods, restart both the server and the client. After connecting to the server, you should see new icons to the left of the inventory. You can hide some of the icons through their settings. One of the icons opens a top-down map where you can manage the chunks. You can claim them and then select them again to load them -- a tooltip will indicate if a chunk is claimed or loaded when you hover over it. On FTBLib 1.0.18.5 and FTBUtilities 1.0.18.7, the LMB claims a chunk, Ctrl+LMB chunkloads a chunk, RMB unloads and unclaims a chunk.

If the described way to load chunks is not fitting, the Windows part of the manual describes the alternatives.

Server Setup for Windows

Warnings

This part of the guide was last revised in November 2020 with version 2.0.9.0. The download links are compatible with each other.

If you follow this guide and try to connect, your launcher may have downloaded the latest client instead.

Introduction

This structure of this guide is as follows:

  • Downloading the Files
  • Server Setup
  • Starting and Stopping the Server
  • Server Backups
  • FAQ (Frequently Asked Questions)

Downloading the Files

While our pack is hosted on many launchers we also maintain a repository of all of our releases. For the purpose of this guide we will be utilizing our hosted repositories as well as the MultiMC launcher.

  1. Download the server pack from here: http://downloads.gtnewhorizons.com/ServerPacks/
  2. Download MultiMC from here: https://files.multimc.org/downloads/mmc-stable-win32.zip
  3. Download the client pack from here: http://downloads.gtnewhorizons.com/Multi_mc_downloads/

Note: Please reference this guide on how to setup and install our pack in MultiMC (this guide will only cover the server portion.): Installing and Migrating

Download Directory Image
Your downloads folder should look like this.


Server Setup

Step 1: Extract the Server Files

Extract Server Files Image
Right click on the server files ZIP archive and choose "Extract All..."
Extraction Destination Image
Once you've chosen your name for the folder you can hit extract. Whether or not you uncheck the "Show extracted files when complete" checkbox is up to you.

Step 2: Preparing to Start the Server

New File Image
Open up the folder you extracted the files into (in our case it is GTNH-2.0.9.0-Server). Right click in the empty space and choose:New > Text Document.
Change Filename Image
Change the name of this TXT file to: eula.txt.
File Content
Add the following text to the eula.txt file. Then save and close the file.

By setting the text of the EULA.txt file to true you are agreeing to the following EULA.

Step 3: Starting and Stopping the Server

Starting the server at this point is very straight forward. Simply double click:

startserver.bat
Firewall Prompt
If you get the following prompt while the server is starting you can hit Allow Access. It is recommended making sure you're only allowing access on Private Networks (this doesn't impact if you want to open your modem/router for friends to join but is just best practice).


Note: It will take quite some time for the server to startup.


Console Window Image
When your server is ready you will typically see what is boxed in by red at the bottom. At this point your server is running and you can connect to it!

In order to stop the server simply type "stop" and press Enter:

stop

The server will scroll some information by and then the window will close when it shuts down entirely.

DO NOT just close the command window instead of using stop. Doing so may corrupt your world data and your world will become unplayable.


Step 4: Whitelisting Players

In order to connect to the server yourself or allow other players to connect you must add them to the whitelist. To do this use the following command inside the server console window:

Syntax: whitelist add <playername>

Example: whitelist add shawnbyday

Server Backups

Go ahead and follow the above procedure to stop the server.

In this step we are going to download and install AromaBackup (a simple backup mod). Running a server means you're responsible for everything on it. The best way to have your own back is to run a backup. We see many people coming into Discord asking for help and they don't have a backup. Backups are deliberate not magic. Don't just set it up but also take the time to ensure it is working. Better yet also take the time to validate the backup itself can be restored. That's what makes a good administrator.

Note: You need AromaBackup and AromaCore.

  1. Download AromaBackup here: https://www.curseforge.com/minecraft/mc-mods/aromabackup/download/2284754/file
  2. Download AromaCore here: https://www.curseforge.com/minecraft/mc-mods/aroma1997core/download/2257644/file
Cut Image
Holding CTRL on your keyboard single left click on both: AromaBackup and AromaCore. Right click on them and select "Cut". (Alternatively you can hold down CTRL and press X on your keyboard).
Paste Image
Next we need to go into our server folder. If you've been following along to this guide this will be located here: C:\Users\<username>\Downloads\GTNH-2.0.9.0-Server\mods Right click on any empty space in this folder and choose "Paste". (Alternatively you can hold down CTRL and press V on your keyboard).


At this point you can go ahead and start your server again. By default AromaBackup will backup your server every 30 minutes. You can change this in the AromaBackup configuration file which will be located in: C:\Users\<username>\Downloads\GTNH-2.0.9.0-Server\config folder. Modifying configuration files is outside of the scope of this guide, however, it is recommended to set the backup interval to be equal to or less the amount of work you are willing to lose.

FAQ (Frequently Asked Questions)

  1. How do I connect to my server?
    1. On the Multiplayer Game you need to add a server and the server address can be (note by default the server is set to use the default Minecraft port which is 25565):
      1. localhost
      2. 127.0.0.1
  2. How do I let my friends connect?
    1. You will need to find out what your external IP address is (you can find this using Google).
    2. You then need to setup port forwarding on your modem/router (this is outside the scope of this guide and requires special attention to detail for privacy and security reasons - again Google is your friend here).