服务器软件下载地址
官方(VANILLA):
https://www.minecraft.net/en-us/article/minecraft-java-edition-1-16-5
官方最新版(VANILLA):
https://www.minecraft.net/zh-hans/download/server
第三方(spigot):
https://getbukkit.org/download/spigot
服务器启动脚本代码
java -Xmx1024M -Xms1024M -jar minecraft_server.1.19.3.jar nogui
系统服务脚本
[Unit]
Description=Minecraft Server
Wants=network.target
After=network.target
[Service]
User=minecraft # 注意根据情况修改
Group=minecraft # 注意根据情况修改
Type=simple
WorkingDirectory=/home/minecraft/1.16.5/ # 注意根据情况修改
ExecStart=/lib64/java/jdk1.8.0_351/bin/java -Xms2G -Xmx8G -jar /home/minecraft/1.16.5/server.jar nogui # 注意根据情况修改
RestartSec=30
Restart=on-failure
KillMode=process
KillSignal=SIGINT
SuccessExitStatus=130
StandardInput=null
[Install]
WantedBy=default.target
连不上?记得检查防火墙
systemctl status firewalld # 查看防火墙状态
systemctl disable firewalld # 如果你的服务器进程独占整个系统,建议直接关闭防火墙
自动备份存档
自动打包脚本
#!/bin/bash
# 存档目录
world_dir="/opt/minecraft/world"
# 备份目录
backup_dir="/opt/minecraft/backups"
# 创建备份目录
mkdir -p $backup_dir
# 备份文件名
backup_name="world_$(date +%Y%m%d_%H%M%S)"
# 打包备份
tar -czf $backup_dir/$backup_name.tar.gz $world_dir
# 删除三天前的备份
find $backup_dir -type f -name "world_*" -mtime +3 -delete
编辑crontab定时任务
* * * * bash /opt/minecraft/bak/bak.sh