[minecraft]
# 生成启动文件:https://blog.csdn.net/networken/article/details/84477537
视频地址:https://www.bilibili.com/video/BV13N411o7TU?spm_id_from=333.337.search-card.all.click&vd_source=e91b49672370bf602fa9705cd3915ec6
tmux操作指南:https://blog.csdn.net/qq_38156104/article/details/125093656
java -Xmx1024M -Xms512M -jar /root/minecraft/mc1.16.1/mc_server_1.16.1.jar nogui
java -Xmx1024M -Xms512M -jar /root/minecraft/mc1.19.1/mc_server_1.19.1.jar nogui
vim eula.txt (改为ture)
yum install tmux
touch start.bash
"""
#!/bin/bash
tmux new-session -s mc -d 'java -Xmx1024M -Xms512M -jar /root/minecraft/mc1.16.1/mc_server_1.16.1.jar nogui'
"""
"""
#!/bin/bash
tmux new-session -s mc -d 'java -Xmx1024M -Xms512M -jar /root/minecraft/mc1.19.1/mc_server_1.19.1.jar nogui'
"""
启动
[root@ti mc1.16.1]# chmod 777 start.bash
[root@ti mc1.16.1]# ./start.bash
查看
tmux a
firewall-cmd --zone=public --add-port=25565/tcp --permanent
[{"name":"JumboCoder25830","uuid":"d9a98c1e-37e9-4a42-a432-7000d5d4486a","expiresOn":"2022-11-01 14:01:42 +0800"},{"name":"WittedRose30654","uuid":"cef67c1f-3a9b-4f71-ba3c-7a0753f4c58f","expiresOn":"2022-11-01 11:18:22 +0800"}][root@ti mc1.19.1]
[root@ti survival]# cat usercache.json
[{"name":"JumboCoder25830","uuid":"d9a98c1e-37e9-4a42-a432-7000d5d4486a","expiresOn":"2022-11-04 10:04:15 +0800"},{"name":"WittedRose30654","uuid":"cef67c1f-3a9b-4f71-ba3c-7a0753f4c58f","expiresOn":"2022-11-04 09:56:03 +0800"}][root@ti survival]#
配置ops权限
1、服务端查看离线用户的UUID
root@mcserver:~# cat /opt/minecraft/instances/survival/usercache.json
[{"name":"steve","uuid":"53909932-f794-33c0-9329-948045a4c1ce","expiresOn":"2022-07-09 21:44:37 +0800"}]
2、配置 ops.json 文件,将用户steve设为op
root@mcserver:~# vim /opt/minecraft/instances/survival/ops.json
[
{
"uuid": "cef67c1f-3a9b-4f71-ba3c-7a0753f4c58f",
"name": "WittedRose30654",
"level": 6,
"bypassesPlayerLimit": false
},
{
"uuid": "d9a98c1e-37e9-4a42-a432-7000d5d4486a",
"name": "JumboCoder25830",
"level": 32,
"bypassesPlayerLimit": false
}
]
生成启动文件
3、创建minecraft服务启动文件,复制粘贴以下内容到命令行
mkdir -p /opt/minecraft/instances/survival
cat >/lib/systemd/system/minecraft-survival.service<<'EOF'
[Unit]
Description=Minecraft Server
Wants=network.target
After=network.target
[Service]
Type=simple
WorkingDirectory=/root/minecraft/instances/survival
#ExecStart=/usr/bin/java -Xms2G -Xmx4G -jar /root/minecraft/jars/server.jar nogui
#ExecStart=/usr/bin/java tmux new-session -s mc -d 'java -Xmx1024M -Xms512M -jar /root/minecraft/mc1.19.1/mc_server_1.19.1.jar nogui'
ExecStart=/usr/bin/java -Xmx1024M -Xms512M -jar /root/minecraft/mc1.19.1/mc_server_1.19.1.jar nogui
RestartSec=30
Restart=on-failure
KillMode=process
KillSignal=SIGINT
SuccessExitStatus=130
StandardInput=null
[Install]
WantedBy=default.target
# 启动服务端
systemctl start minecraft-survival
# 停止服务端
systemctl stop minecraft-survival
# 重启服务端
systemctl restart minecraft-survival
# 查看服务运行状态
systemctl status minecraft-survival
# 查看服务启动日志
journalctl -xe
systemctl daemon-reload
x/y/z -550/65/-6
New Minecraft
-- 准备工作
mkdir minecraft
cd minecraft
mkdir versions
cd versions
wget wget https://piston-data.mojang.com/v1/objects/f69c284232d7c7580bd89a5a4931c3581eae1378/server.j
mkdir -p /home/tian/minecraft/instance/mc_v1.19.2
-- 防火墙开放端口
firewall-cmd --zone=public --add-port=80-90/tcp --permanent
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-all
firewall-cmd --list-ports
-- 制作启动文件
cat >/lib/systemd/system/mc_1.19.2.service<<'EOF'
[Unit]
Description=Minecraft Server
Wants=network.target
After=network.target
[Service]
Type=simple
WorkingDirectory=/home/tian/minecraft/instance/mc_v1.19.2
ExecStart=/usr/bin/java -Xms512M -Xmx1024M -jar /home/tian/minecraft/versions/server_1.19.2.jar nogui
RestartSec=30
Restart=on-failure
KillMode=process
KillSignal=SIGINT
SuccessExitStatus=130
StandardInput=null
[Install]
WantedBy=default.target
EOF
-- 生成eula文件
echo "eula=true" > /home/tian/minecraft/instance/mc_v1.19.2/eula.txt
-- 初次启动
systemctl start mc_1.19.2.service
# 启动服务端
systemctl start minecraft-survival
# 停止服务端
systemctl stop minecraft-survival
# 重启服务端
systemctl restart minecraft-survival
# 查看服务运行状态
systemctl status minecraft-survival
# 查看服务启动日志
journalctl -xe
# 开机启动
systemctl enable minecraft-survival.service