In this lab, you set up a game application—a Minecraft server.
The Minecraft server software will run on a Compute Engine instance.
You use an e2-medium machine type that includes a 10-GB boot disk, 2 virtual CPU (vCPU), and 4 GB of RAM. This machine type runs Debian Linux by default.
To make sure there is plenty of room for the Minecraft server's world data, you also attach a high-performance 50-GB persistent solid-state drive (SSD) to the instance. This dedicated Minecraft server can support up to 50 players.
Objectives
In this lab, you learn how to perform the following tasks:
Customize an application server
Install and configure necessary software
Configure network access
Schedule regular backups
Setup and Requirements
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method.
On the left is the Lab Details panel with the following:
The Open Google Cloud console button
Time remaining
The temporary credentials that you must use for this lab
Other information, if needed, to step through this lab
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
Note: If you see the Choose an account dialog, click Use Another Account.
If necessary, copy the Username below and paste it into the Sign in dialog.
{{{user_0.username | "Username"}}}
You can also find the Username in the Lab Details panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
{{{user_0.password | "Password"}}}
You can also find the Password in the Lab Details panel.
Click Next.
Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials.
Note: Using your own Google Cloud account for this lab may incur extra charges.
Click through the subsequent pages:
Accept the terms and conditions.
Do not add recovery options or two-factor authentication (because this is a temporary account).
Do not sign up for free trials.
After a few moments, the Google Cloud console opens in this tab.
Note: To view a menu with a list of Google Cloud products and services, click the Navigation menu at the top-left, or type the service or product name in the Search field.
Task 1. Create the VM
In this task, you create a VM that will host your Minecraft-server and install the software.
Define a VM using advanced options
In the Google Cloud console, in the Navigation menu (), click Compute Engine > VM instances.
Click Create instance.
Specify the following and leave the remaining settings as their defaults:
Property
Value (type value or select option as specified)
Name
mc-server
Region
Zone
Click OS and storage.
Ensure that the boot disk image is shown as Debian GNU/Linux 12 (bookworm). If not, click Change and select it from the Version drop down list, and then click Select.
Click Add new disk.
Specify the following and leave the remaining settings as their defaults:
Property
Value (type value or select option as specified)
Name
minecraft-disk
Disk source type
Blank Disk
Disk settings
SSD Persistent Disk
Size (GB)
50
Encryption
Google-managed encryption key
Click Save. This creates the disk and automatically attaches it to the VM when the VM is created.
Click Networking.
Specify the following and leave the remaining settings as their defaults:
Property
Value (type value or select option as specified)
Network tags
minecraft-server
Network interfaces
Click default to edit the interface
External IPv4 address
Reserve Static External IP Address
Name
mc-server-ip
Click Reserve, and then click Done.
Click Security.
Specify the following and leave the remaining settings as their defaults:
Property
Value (type value or select option as specified)
Identity and API access > Access Scopes
Set access for each API
Storage
Read Write
Click Create.
Task 2. Prepare the data disk
In this task, you format and mount the minecraft disk.
Create a directory and format and mount the disk
The disk is attached to the instance, but it is not yet mounted or formatted.
For mc-server, click SSH to open a terminal and connect.
To create a directory that serves as the mount point for the data disk, run the following command:
sudo mount -o discard,defaults /dev/disk/by-id/google-minecraft-disk /home/minecraft
No output is displayed after the disk is mounted.
Click Check my progress to verify the objective.
Create the VM and prepare the data disk
Task 3. Install and run the application
In this task, you install and run the Minecraft application. The Minecraft server runs on top of the Java Virtual Machine (JVM), so it requires the Java Runtime Environment (JRE) to run. Because the server doesn't need a graphical user interface, you use the headless version of the JRE.
This reduces the JRE's resource usage on the machine, which helps ensure that the Minecraft server has enough room to expand its own resource usage if needed.
Install the Java Runtime Environment (JRE) and the Minecraft server
In the SSH terminal for mc-server, to update the Debian repositories on the VM, run the following command:
sudo apt-get update
After the repositories are updated, to install the headless JRE, run the following command:
sudo apt-get install -y default-jre-headless
To navigate to the directory where the persistent disk is mounted, run the following command:
cd /home/minecraft
To install wget, run the following command:
sudo apt-get install wget
If prompted to continue, type Y.
To download the current Minecraft server JAR file (1.11.2 JAR), run the following command:
[21:01:54] [main/ERROR]: Failed to load properties from file: server.properties
[21:01:54] [main/WARN]: Failed to load eula.txt
[21:01:54] [main/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
Note: The Minecraft server won't run unless you accept the terms of the End User Licensing Agreement (EULA).
Click Check my progress to verify the objective.
Install the Java Runtime Environment (JRE) and the Minecraft server
To see the files that were created in the first initialization of the Minecraft server, run the following command:
sudo ls -l
Note: You could edit the server.properties file to change the default behavior of the Minecraft server.
To edit the EULA, run the following command:
sudo nano eula.txt
Change the last line of the file from eula=false to eula=true.
Press Ctrl+O, ENTER to save the file and then press Ctrl+X to exit nano.
Note: Don't try to restart the Minecraft server yet. You use a different technique in the next procedure.
Create a virtual terminal screen to start the Minecraft server
If you start the Minecraft server again now, it is tied to the life of your SSH session: that is, if you close your SSH terminal, the server is also terminated. To avoid this issue, you can use screen, an application that allows you to create a virtual terminal that can be "detached," becoming a background process, or "reattached," becoming a foreground process. When a virtual terminal is detached to the background, it will run whether you are logged in or not.
To install screen, run the following command:
sudo apt-get install -y screen
To start your Minecraft server in a screen virtual terminal, run the following command (using the -S flag to name your terminal mcs):
To detach the screen terminal, press Ctrl+A, Ctrl+D. The terminal continues to run in the background. To reattach the terminal, run the following command:
sudo screen -r mcs
If necessary, exit the screen terminal by pressing Ctrl+A, Ctrl+D.
To exit the SSH terminal, run the following command:
exit
Congratulations! You set up and customized a VM and installed and configured application software—a Minecraft server!
Task 4. Allow client traffic
In this task, you configure a firewall rule to allow client connections to the Minecraft Server. Up to this point, the server has an external static IP address, but it cannot receive traffic because there is no firewall rule in place.
Minecraft server uses TCP port 25565 by default.
Create a firewall rule
In the Google Cloud console, in the Navigation menu (), click VPC network > Firewall.
Click Create firewall rule.
Specify the following and leave the remaining settings as their defaults:
Property
Value (type value or select option as specified)
Name
minecraft-rule
Target
Specified target tags
Target tags
minecraft-server
Source filter
IPv4 ranges
Source IPv4 ranges
0.0.0.0/0
Protocols and ports
Specified protocols and ports
For tcp, specify port 25565.
Click Create.
Users can now access your server from their Minecraft clients.
Verify server availability
In the Cloud console, in the Navigation menu (), click VPC network.
In the left pane, click IP addresses.
Locate and copy the External IP address for the mc-server VM.
In this task, you configure the system to back up Minecraft world data to Cloud Storage. Backing up your application data is a common activity.
Create a Cloud Storage bucket
In the Google Cloud console, in the Navigation menu (), click Compute Engine > VM instances.
For mc-server, click SSH.
Create a globally unique bucket name, and store it in the environment variable YOUR_BUCKET_NAME. To make it unique, you can use your Project ID. Run the following command:
export YOUR_BUCKET_NAME=<Enter your bucket name here>
Verify it with echo:
echo $YOUR_BUCKET_NAME
To create the bucket using the gcloud storage tool, part of the Cloud SDK, run the following command:
gcloud storage buckets create gs://$YOUR_BUCKET_NAME-minecraft-backup
Note: If this command failed, you might not have created a unique bucket name. If so, choose another bucket name, update your environment variable, and try to create the bucket again.Note: To make this environment variable permanent, you can add it to the root's .profile by running this command: echo YOUR_BUCKET_NAME=$YOUR_BUCKET_NAME >> ~/.profile
Create a backup script
In the mc-server SSH terminal, navigate to your home directory:
cd /home/minecraft
To create the script, run the following command:
sudo nano /home/minecraft/backup.sh
Copy and paste the following script into the file:
Press Ctrl+O, ENTER to save the file, and press Ctrl+X to exit nano.
Note: The script saves the current state of the server's world data and pauses the server's auto-save functionality. Next, it backs up the server's world data directory (world) and places its contents in a timestamped directory (<timestamp>-world) in the Cloud Storage bucket. After the script finishes backing up the data, it resumes auto-saving on the Minecraft server.
To make the script executable, run the following command:
sudo chmod 755 /home/minecraft/backup.sh
Test the backup script and schedule a cron job
In the mc-server SSH terminal, run the backup script:
. /home/minecraft/backup.sh
After the script finishes, return to the Cloud console.
To verify that the backup file was written, in the Navigation menu ( ), click Cloud Storage > Buckets.
Click on the backup bucket name. You should see a folder with a date-time stamp name. Now that you've verified that the backups are working, you can schedule a cron job to automate the task.
In the mc-server SSH terminal, open the cron table for editing:
sudo crontab -e
When you are prompted to select an editor, type the number corresponding to nano, and press ENTER.
At the bottom of the cron table, paste the following line:
0 */4 * * * /home/minecraft/backup.sh
Note: That line instructs cron to run backups every 4 hours.
Press Ctrl+O, ENTER to save the cron table, and press Ctrl+X to exit nano.
Note: This creates about 300 backups a month in Cloud Storage, so you will want to regularly delete them to avoid charges. Cloud Storage offers the Object Lifecycle Management feature to set a Time to Live (TTL) for objects, archive older versions of objects, or "downgrade" storage classes of objects to help manage costs.
Click Check my progress to verify the objective.
Schedule regular backups
Task 6. Server maintenance
In this task, you connect to the server and shut it down in order to perform server maintenance.
Connect via SSH to the server, stop it and shut down the VM
In the mc-server SSH terminal, run the following command:
sudo screen -r -X stuff '/stop\n'
In the Google Cloud console, in the Navigation menu ( ), click Compute Engine > VM instances.
Select mc-server.
Click Stop.
In the confirmation dialog, click Stop to confirm.
You will be logged out of your SSH session.
Note: To start up your instance again, visit the instance page and then click Start. To start the Minecraft server again, you can establish an SSH connection with the instance, remount your persistent disk, and start your Minecraft server in a new screen terminal, just as you did previously.
Automate server maintenance with startup and shutdown scripts
Instead of following the manual process to mount the persistent disk and launch the server application in a screen, you can use metadata scripts to create a startup script and a shutdown script to do this for you.
Click mc-server.
Click Edit.
For Metadata, click + Add Item and specify the following:
Note: You'll have to click Add item to add the shutdown-script-url. When you restart your instance, the startup script automatically mounts the Minecraft disk to the appropriate directory, starts your Minecraft server in a screen session, and detaches the session. When you stop the instance, the shutdown script shuts down your Minecraft server before the instance shuts down. It's a best practice to store these scripts in Cloud Storage.
Click Save.
Click Check my progress to verify the objective.
Server maintenance
Task 7. Review
In this lab, you created a customized virtual machine instance by installing base software (a headless JRE) and application software (a Minecraft game server). You customized the VM by attaching and preparing a high-speed SSD data disk, and you reserved a static external IP so the address would remain consistent. Then you verified availability of the gaming server online.
You set up a backup system to back up the server's data to a Cloud Storage bucket, and you tested the backup system. Then you automated backups using cron. Finally, you set up maintenance scripts using metadata for graceful startup and shutdown of the server.
End your lab
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
1 star = Very dissatisfied
2 stars = Dissatisfied
3 stars = Neutral
4 stars = Satisfied
5 stars = Very satisfied
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2025 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
Moduły tworzą projekt Google Cloud i zasoby na określony czas.
Moduły mają ograniczenie czasowe i nie mają funkcji wstrzymywania. Jeśli zakończysz moduł, musisz go zacząć od początku.
Aby rozpocząć, w lewym górnym rogu ekranu kliknij Rozpocznij moduł.
Użyj przeglądania prywatnego
Skopiuj podaną nazwę użytkownika i hasło do modułu.
Kliknij Otwórz konsolę w trybie prywatnym.
Zaloguj się w konsoli
Zaloguj się z użyciem danych logowania do modułu. Użycie innych danych logowania może spowodować błędy lub naliczanie opłat.
Zaakceptuj warunki i pomiń stronę zasobów przywracania.
Nie klikaj Zakończ moduł, chyba że właśnie został przez Ciebie zakończony lub chcesz go uruchomić ponownie, ponieważ spowoduje to usunięcie wyników i projektu.
Ta treść jest obecnie niedostępna
Kiedy dostępność się zmieni, wyślemy Ci e-maila z powiadomieniem
Świetnie
Kiedy dostępność się zmieni, skontaktujemy się z Tobą e-mailem
Jeden moduł, a potem drugi
Potwierdź, aby zakończyć wszystkie istniejące moduły i rozpocząć ten
Aby uruchomić moduł, użyj przeglądania prywatnego
Uruchom ten moduł w oknie incognito lub przeglądania prywatnego. Dzięki temu unikniesz konfliktu między swoim kontem osobistym a kontem do nauki, co mogłoby spowodować naliczanie dodatkowych opłat na koncie osobistym.
In this lab you will create a typical application VM and set it up with many of the necessary features. In this case a gaming system - a Minecraft server.
Czas trwania:
Konfiguracja: 0 min
·
Dostęp na 90 min
·
Ukończono w 45 min