在Ubuntu上搭建并通过systemctl管理Minecraft基岩版服务器

在Ubuntu系统上运行并管理Minecraft基岩版服务器可以通过systemctl实现更高效的服务管理。本文将全面介绍如何从搭建服务器开始到使用systemctl进行管理的整个过程。

第一部分:搭建Minecraft基岩版服务器

1. 下载服务器软件

首先,访问 Minecraft官网 并下载Linux版本的基岩服务器软件。假设下载的文件为bedrock-server.zip

2. 安装和配置

在您的Ubuntu系统上,执行以下命令以解压服务器软件并进入服务器目录:

bash 复制代码
unzip bedrock-server.zip -d minecraft_server
cd minecraft_server
3. 安装运行依赖

安装运行Minecraft服务器所需的依赖:

bash 复制代码
sudo apt-get update
sudo apt-get install -y libcurl4 openssl libssl1.1
4. 修改配置文件

使用文本编辑器打开server.properties文件,根据需要配置服务器,例如设置服务器端口、最大玩家数等。

第二部分:配置Systemd服务

1. 创建服务单元文件

使用文本编辑器创建一个新的systemd服务单元文件:

bash 复制代码
sudo nano /etc/systemd/system/minecraft-server.service

在文件中粘贴以下内容,并根据您的实际情况调整相应的路径和用户信息:

ini 复制代码
[Unit]
Description=Minecraft Bedrock Server
After=network.target

[Service]
User=minecraft
Group=minecraft
WorkingDirectory=/home/minecraft/minecraft_server
ExecStart=/home/minecraft/minecraft_server/bedrock_server
ExecStop=/bin/kill -SIGINT $MAINPID
Restart=on-failure
RestartSec=20
LimitNOFILE=4096

[Install]
WantedBy=multi-user.target
2. 重新加载Systemd配置

更新systemd以识别新的服务:

bash 复制代码
sudo systemctl daemon-reload
3. 启动服务

通过systemctl启动Minecraft服务器:

bash 复制代码
sudo systemctl start minecraft-server.service
4. 设置服务开机自启

使Minecraft服务器在系统启动时自动运行:

bash 复制代码
sudo systemctl enable minecraft-server.service
5. 监控服务状态

检查服务状态:

bash 复制代码
sudo systemctl status minecraft-server.service
6. 停止和重启服务

管理服务的停止和重启:

bash 复制代码
sudo systemctl stop minecraft-server.service
sudo systemctl restart minecraft-server.service

第三部分:创建和配置专用用户

为了安全性和管理方便,建议为Minecraft服务器创建一个专用用户:

bash 复制代码
sudo useradd -r -m -U -d /home/minecraft -s /bin/bash minecraft
sudo passwd minecraft

通过上述步骤,您不仅能搭建一个Minecraft基岩版服务器,还能通过systemctl实现对服务器的有效管理,确保服务器的高可用性和安全运行。

相关推荐
读书,代码与猫7 分钟前
【裸机装机系列】10.kali(ubuntu)-安装nvidia独立显卡步骤
ubuntu·kali·nvidia·linux安装nvidia显卡·ubuntu安装nvidia·裸机安装linux
小宋10218 分钟前
玩转RabbitMQ声明队列交换机、消息转换器
服务器·分布式·rabbitmq
m0_6090004211 分钟前
向日葵好用吗?4款稳定的远程控制软件推荐。
运维·服务器·网络·人工智能·远程工作
kejijianwen2 小时前
JdbcTemplate常用方法一览AG网页参数绑定与数据寻址实操
服务器·数据库·oracle
厨 神6 小时前
vmware中的ubuntu系统扩容分区
linux·运维·ubuntu
Karoku0666 小时前
【网站架构部署与优化】web服务与http协议
linux·运维·服务器·数据库·http·架构
geek_Chen016 小时前
虚拟机共享文件夹开启后mnt/hgfs/下无sharefiles? --已解决
linux·运维·服务器
(⊙o⊙)~哦6 小时前
linux 解压缩
linux·运维·服务器
鸡鸭扣8 小时前
虚拟机:3、(待更)WSL2安装Ubuntu系统+实现GPU直通
linux·运维·ubuntu
友友马9 小时前
『 Linux 』HTTP(一)
linux·运维·服务器·网络·c++·tcp/ip·http