AlmaLinuxRHEL Based

How To Install Minecraft Server on AlmaLinux 9

Install Minecraft Server on AlmaLinux 9

In this tutorial, we will show you how to install Minecraft Server on AlmaLinux 9.  Minecraft, the beloved sandbox game, offers endless possibilities for creativity and adventure. For many players, hosting a private server is the ultimate way to enhance their gaming experience. This guide will walk you through the process of installing and configuring a Minecraft server on AlmaLinux 9, a robust and stable Linux distribution perfect for server deployments. Whether you’re a seasoned system administrator or a gaming enthusiast looking to dive into server management, this tutorial will provide you with the knowledge and steps needed to create your own Minecraft world.

Prerequisites

Before we embark on our Minecraft server journey, let’s ensure we have all the necessary components in place. A successful server setup begins with meeting the right system requirements and having the essential software ready.

System Requirements

To run a Minecraft server smoothly, your AlmaLinux 9 system should meet or exceed the following specifications:

  • CPU: Dual-core processor (3.0+ GHz)
  • RAM: Minimum 4GB, recommended 8GB or more
  • Storage: At least 20GB of free space (SSD preferred)
  • Network: Stable internet connection with at least 10 Mbps upload speed

Remember, these are baseline requirements. For optimal performance, especially with multiple players or mods, consider upgrading your hardware accordingly.

Required Software Components

Before installing the Minecraft server, ensure you have the following software installed on your AlmaLinux 9 system:

  • Java Development Kit (JDK)
  • Screen (for running the server in the background)
  • wget (for downloading server files)

We’ll cover the installation of these components in the next section.

Server Preparation Checklist

To streamline the installation process, complete the following tasks:

  • Ensure root access or sudo privileges on your AlmaLinux 9 system
  • Update your system to the latest packages
  • Configure your firewall to allow incoming connections on port 25565 (default Minecraft port)
  • Disable SELinux or configure it to allow Minecraft server operations

Initial Server Setup

With our prerequisites in check, let’s begin the initial setup of our AlmaLinux 9 system for hosting a Minecraft server.

Updating System Packages

Start by updating your system to ensure you have the latest security patches and software versions:

sudo dnf update -y
sudo dnf upgrade -y

Installing Java Development Kit

Minecraft requires Java to run. Install the latest version of OpenJDK:

sudo dnf install java-17-openjdk -y

Verify the installation by checking the Java version:

java -version

Creating a Dedicated Minecraft User

For security reasons, it’s best to run the Minecraft server under a dedicated user account:

sudo useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft

Configuring Firewall Settings

Allow incoming traffic on the Minecraft port:

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

Setting up SSH Access

If you haven’t already, secure your SSH access by configuring key-based authentication and disabling password login. This step is crucial for maintaining server security.

Minecraft Server Installation

Now that our AlmaLinux 9 system is prepared, let’s proceed with installing the Minecraft server software.

Creating Server Directory

Switch to the minecraft user and create a directory for the server files:

sudo su - minecraft
mkdir ~/server
cd ~/server

Downloading Server Files

Download the latest Minecraft server JAR file from the official Minecraft website:

wget https://piston-data.mojang.com/v1/objects/45810d238246d90e811d896f87b14695b7fb6839/server.jar

Note: Always check for the latest version on the official Minecraft website and update the URL accordingly.

Initial Server Configuration

Start the server for the first time to generate configuration files:

java -Xmx1024M -Xms1024M -jar server.jar nogui

The server will start and then stop, generating the necessary files.

EULA Setup and Acceptance

Edit the eula.txt file and change “eula=false” to “eula=true” to accept the End User License Agreement:

nano eula.txt

Server Properties Configuration

Customize your server by editing the server.properties file:

nano server.properties

Here you can set options like gamemode, difficulty, and max-players. Save the file after making your desired changes.

Server Management

With the Minecraft server installed, let’s explore how to manage and operate it effectively.

Starting the Server

To start the server, use the following command:

java -Xmx2048M -Xms2048M -jar server.jar nogui

Adjust the -Xmx and -Xms values based on your server’s available RAM.

Using Screen Sessions

To keep the server running in the background, use the screen utility:

screen -S minecraft
java -Xmx2048M -Xms2048M -jar server.jar nogui

Detach from the screen session using Ctrl+A followed by D. To reattach, use:

screen -r minecraft

Basic Server Commands

Once the server is running, you can use various commands to manage it:

  • /stop – Safely stops the server
  • /op [username] – Grants operator status to a player
  • /whitelist add [username] – Adds a player to the whitelist
  • /save-all – Forces a world save

Memory Allocation

Adjust the server’s memory allocation based on your system’s resources and player count. For example, to allocate 4GB of RAM:

java -Xmx4G -Xms4G -jar server.jar nogui

Backup Procedures

Implement regular backups to protect your world data. Create a simple backup script:

#!/bin/bash
MINECRAFT_DIR="/opt/minecraft/server"
BACKUP_DIR="/opt/minecraft/backups"
DATE=$(date +%Y%m%d_%H%M%S)

tar -czf $BACKUP_DIR/minecraft_backup_$DATE.tar.gz $MINECRAFT_DIR

Schedule this script to run regularly using cron jobs.

Performance Optimization

To ensure your Minecraft server runs smoothly, consider these optimization techniques:

Java Garbage Collection Settings

Optimize Java’s garbage collection by adding these flags to your start command:

java -Xmx4G -Xms4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui

Server.properties Optimization

Fine-tune your server.properties file for better performance:

  • Set view-distance=8 to reduce chunk loading
  • Use simulation-distance=6 to optimize entity processing
  • Set max-players to a reasonable number based on your server’s capacity

Network Optimization

Improve network performance by adjusting your system’s TCP settings:

sudo sysctl -w net.ipv4.tcp_fastopen=3
sudo sysctl -w net.core.rmem_max=16777216
sudo sysctl -w net.core.wmem_max=16777216
sudo sysctl -w net.ipv4.tcp_rmem="4096 87380 16777216"
sudo sysctl -w net.ipv4.tcp_wmem="4096 65536 16777216"

Security Considerations

Maintaining a secure Minecraft server is crucial. Implement these security measures:

Firewall Configuration

Ensure your firewall only allows necessary incoming connections:

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

User Permissions

Restrict access to the Minecraft server directory:

sudo chown -R minecraft:minecraft /opt/minecraft
sudo chmod -R 750 /opt/minecraft

SSH Hardening

Secure SSH access by editing /etc/ssh/sshd_config:

  • Disable root login: PermitRootLogin no
  • Use key-based authentication: PasswordAuthentication no
  • Change the default SSH port: Port 2222 (replace 2222 with your chosen port)

Backup Security

Encrypt your backups and store them in a secure, off-site location to protect against data loss and unauthorized access.

Advanced Configuration

Take your Minecraft server to the next level with these advanced configurations:

Plugin Installation

Enhance your server’s functionality by installing plugins. For example, to install the Essentials plugin:

  1. Download the plugin JAR file from the official source
  2. Place the JAR file in the plugins directory of your server
  3. Restart the server to load the plugin

World Management

Manage multiple worlds using the Multiverse-Core plugin:

  1. Install the Multiverse-Core plugin
  2. Use commands like /mv create and /mv teleport to manage worlds

Server Monitoring

Set up server monitoring using tools like Prometheus and Grafana to track performance metrics and player activity.

Automated Backups

Implement automated backups using a combination of cron jobs and rsync to securely store your world data off-site.

Congratulations! You have successfully installed Minecraft. Thanks for using this tutorial for installing the Minecraft server on your AlmaLinux 9 system. For additional help or useful information, we recommend you check the official Minecraft website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button