Deploying a Minecraft server in Yandex Cloud
Follow this tutorial to deploy the current version of Minecraft
To deploy a Minecraft server of the current version in Yandex Cloud:
- Prepare your cloud.
- Create a security group.
- Create a VM for the Minecraft server.
- Install the required utilities.
- Download and run the Minecraft server.
- Test the solution.
If you no longer need the resources you created, delete them.
Prepare your cloud
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Required paid resources
The infrastructure support cost includes:
- Fee for continuously running VMs (see Yandex Compute Cloud pricing).
- Fee for using public IP addresses and outgoing traffic (see Yandex Virtual Private Cloud pricing).
Create a security group
Create a security group with a rule allowing traffic to port 25565
. This port is set by default in the server configuration file.
-
In the management console
, select your folder. -
In the list of services, select Virtual Private Cloud.
-
In the left-hand panel, select
Security groups. -
Click Create security group.
-
In the Name field, specify the name:
minecraft-sg
. -
In the Network field, select
default
. -
Under Rules, create the following traffic management rules:
Traffic
directionDescription Port range Protocol Source /
Destination nameCIDR blocks Incoming any
25565
Any
CIDR
0.0.0.0/0
Incoming any
22
Any
CIDR
0.0.0.0/0
Outgoing any
25565
Any
CIDR
0.0.0.0/0
-
Click Save.
Create a VM for the Minecraft server
-
Create an SSH key pair:
ssh-keygen -t ed25519
We recommend leaving the key file name unchanged.
-
Create a VM with a public IP address:
Management console-
In the management console
, select the folder to create your VM in. -
In the list of services, select Compute Cloud.
-
In the left-hand panel, select
Virtual machines. -
Click Create virtual machine.
-
Under Boot disk image, select the Ubuntu 22.04 LTS image.
-
Under Location, select an availability zone to place your VM in.
-
Under Disks and file storages, configure the boot disk:
- Type:
HDD
. - Size:
18 GB
.
- Type:
-
Under Computing resources, navigate to the Custom tab and specify the Minecraft server recommended parameters:
- Platform:
Intel Ice Lake
. - vCPU:
2
. - Guaranteed vCPU performance:
100%
. - RAM:
2 GB
.
- Platform:
-
Under Network settings:
-
In the Subnet field, enter the ID of a subnet in the new VM’s availability zone. Alternatively, you can select a cloud network from the list.
-
Each network must have at least one subnet. If there is no subnet, create one by selecting Create subnet.
-
If you do not have a network, click Create network to create one:
- In the window that opens, enter the network name and select the folder to host the network.
- (Optional) Select the Create subnets option to automatically create subnets in all availability zones.
- Click Create network.
-
-
In the Public IP field, select
Auto
to assign the VM a random external IP address from the Yandex Cloud pool or select a static address from the list if you reserved one in advance. -
In the Security groups field, select the
minecraft-sg
security group you created earlier.
-
-
Under Access, select SSH key and specify the information required to access the VM:
-
In the Login field, enter a name for the user you want to create on the VM, e.g.,
ubuntu
.Alert
Do not use
root
or other usernames reserved by the operating system. To perform operations requiring superuser permissions, use thesudo
command. -
In the SSH key field, select the SSH key saved in your organization user profile.
If there are no saved SSH keys in your profile, or you want to add a new key:
- Click Add key.
- Enter a name for the SSH key.
- Upload or paste the contents of the public key file. You need to create a key pair for the SSH connection to a VM yourself.
- Click Add.
The SSH key will be added to your organization user profile.
If users cannot add SSH keys to their profiles in the organization, the added public SSH key will only be saved to the user profile of the VM being created.
-
-
Under General information, specify the VM name:
minecraft-server
. -
Click Create VM.
Recommended virtual machine configuration:
Configuration Number of players vCPU RAM Disk size Minimum 1-4 2 1GB minimum 150MB HDD Recommended 5-10 2 2GB minimum 200MB HDD Ideal 10+ 4 4GB minimum 200MB SSD Warning
Note that this configuration table reflects the default settings defined in
server.properties
. The bigger the world grows, the higher the requirements, especially for RAM. The larger the rendered areas of the game world, villages, and other dynamic objects, the higher the virtual server requirements. -
Install the required utilities
-
Use SSH to connect to the created VM.
-
Install the necessary Java packages from the repository and the
screen
utility to run the terminal session in background mode:sudo add-apt-repository -y ppa:openjdk-r/ppa && sudo apt update -y && sudo apt install -y openjdk-17-jre-headless screen
Download and run the Minecraft server
-
Create a separate directory and navigate to it:
mkdir minecraft-server && cd minecraft-server
-
Follow the link
and copy the URL to download the distribution of the current server version. -
Download the distribution to the current directory using
wget
:wget -O minecraft_server_1.20.4.jar https://piston-data.mojang.com/v1/objects/8dd1a28015f51b1803213892b50b7b4fc76e594d/server.jar
-
Create the
eula.txt
file to automatically accept the terms of the EULA :cat << EOF > eula.txt eula=true EOF
-
Run the background
screen
session:screen
-
In the background session, run the server:
java -Xms1024M -Xmx1024M -jar minecraft_server_1.20.4.jar nogui
Wait for the game world to be successfully completed.
[09:18:58] [Worker-Main-2/INFO]: Preparing spawn area: 81% [09:18:59] [Worker-Main-2/INFO]: Preparing spawn area: 82% [09:19:00] [Worker-Main-2/INFO]: Preparing spawn area: 83% ... [09:19:08] [Worker-Main-2/INFO]: Preparing spawn area: 97% [09:19:09] [Server thread/INFO]: Time elapsed: 75917 ms [09:19:09] [Server thread/INFO]: Done (92.666s)! For help, type "help"
-
(Optional) You can leave the
screen
session running in the background using thecontrol + a + d
hotkeys and return to the main terminal of the VM.To return to the background session with the server running, if there is only one such background session, run the following command:
screen -r
If there are multiple background sessions, get a list of them by running the following command:
screen -list
Result:
There is a screen on: 24257.pts-0.mcft-test (02/28/2024 09:17:15 AM) (Detached) 1 Socket in /run/screen/S-username.
Then enter the session using its ID from the list:
screen -r 24257
-
After running the server, new directories and the necessary files for server operation and configuration will be created in the directory, including the logs:
4096 Mar 16 09:50 . 4096 Mar 16 09:52 .. 2 Mar 16 09:16 banned-ips.json 2 Mar 16 09:16 banned-players.json 10 Mar 16 09:48 eula.txt 4096 Mar 16 09:50 libraries 4096 Mar 16 09:16 logs 49150256 Dec 7 09:04 minecraft_server_1.20.4.jar 2 Mar 16 09:16 ops.json 1303 Mar 16 09:16 server.properties 2 Mar 16 09:16 usercache.json 4096 Mar 16 09:50 versions 2 Mar 16 09:50 whitelist.json 4096 Mar 16 09:13 world
Test the solution
-
Add the server to the list of servers in the Minecraft client. Give the server a name of your choice. In the Server address field, specify the public IP address assigned to our virtual machine when it was created.
-
In the list of servers, select the server you added and click
Connect
.
How to delete the resources you created
To stop paying for the resources you created: