'No X11 DISPLAY variable was set' 尝试 运行 EC2 实例上的 Minecraft 服务器
'No X11 DISPLAY variable was set' trying to run Minecraft server on EC2 instance
当我尝试 运行在 ec2 实例上运行 minecraft 服务器时,我 运行 遇到了以下问题:
java[7261]: No X11 DISPLAY variable was set, but this program performed an operation which requires it.
java[7261]: at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
java[7261]: at java.awt.Window.<init>(Window.java:536)
java[7261]: at java.awt.Frame.<init>(Frame.java:420)
java[7261]: at java.awt.Frame.<init>(Frame.java:385)
java[7261]: at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1763)
java[7261]: at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1838)
java[7261]: at javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1696)
java[7261]: at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:863)
java[7261]: at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:666)
java[7261]: at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:637)
java[7261]: at net.minecraftforge.installer.SimpleInstaller.launchGui(SimpleInstaller.java:177)
java[7261]: at net.minecraftforge.installer.SimpleInstaller.main(SimpleInstaller.java:147)
systemd[1]: minecraft.service: main process exited, code=exited, status=1/FAILURE
systemd[1]: Unit minecraft.service entered failed state.
systemd[1]: minecraft.service failed.
我的用户数据脚本如下所示(运行 每次启动实例时):
#!/usr/bin/env bash
sudo yum -y install java-1.8.0
sudo mkdir /minecraft
sudo chown -R 777 /minecraft
cd /minecraft
aws s3 cp s3://minecraft-server-v3/setup/forge-1.12.2-14.23.5.2860-installer.jar /minecraft/forge-1.12.2-14.23.5.2860-installer.jar
export DISPLAY=:0.0
java -jar forge-1.12.2-14.23.5.2860-installer.jar --installServer
echo '#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
#Mon Aug 06 18:11:14 UTC 2018
eula=true' > eula.txt
aws s3 cp s3://minecraft-server-v3/setup/mods.zip /minecraft/mods.zip
unzip mods.zip
sudo aws s3 cp s3://minecraft-server-v3/setup/minecraft.service /etc/systemd/system/minecraft.service
sudo chmod 777 /etc/systemd/system/minecraft.service
sudo systemctl daemon-reload
sudo service minecraft start
我的 minecraft.service
文件如下所示:
[Unit]
Description=Minecraft Service
After=default.target
[Service]
Type=simple
User=ec2-user
WorkingDirectory=/minecraft
ExecStart=/usr/bin/java -Xmx8G -Xms8G -jar /minecraft/forge-1.12.2-14.23.5.2860-installer.jar nogui
知道会发生什么吗?哪个操作需要显示器?我很困惑。非常感谢任何帮助。
问题
据我了解,问题出在您的 minecraft.service
文件上。
启动服务时,您正在运行安装 forge 服务器的安装程序。
安装程序需要 X,除非 运行 带有 --installServer
标志,正如您在用户数据脚本中所做的那样。
这就是您遇到错误的原因。
解决方案
我想你想要 运行 实际的服务器 .jar
对于您使用的安装程序版本,我很确定 jar 的名称是:
minecraftforge-universal-1.12.2-14.23.5.2860.jar
以此为例,您想将当前命令替换为:
/usr/bin/java -Xmx8G -Xms8G -jar minecraftforge-universal-1.12.2-14.23.5.2860.jar nogui
当我尝试 运行在 ec2 实例上运行 minecraft 服务器时,我 运行 遇到了以下问题:
java[7261]: No X11 DISPLAY variable was set, but this program performed an operation which requires it.
java[7261]: at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
java[7261]: at java.awt.Window.<init>(Window.java:536)
java[7261]: at java.awt.Frame.<init>(Frame.java:420)
java[7261]: at java.awt.Frame.<init>(Frame.java:385)
java[7261]: at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1763)
java[7261]: at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1838)
java[7261]: at javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1696)
java[7261]: at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:863)
java[7261]: at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:666)
java[7261]: at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:637)
java[7261]: at net.minecraftforge.installer.SimpleInstaller.launchGui(SimpleInstaller.java:177)
java[7261]: at net.minecraftforge.installer.SimpleInstaller.main(SimpleInstaller.java:147)
systemd[1]: minecraft.service: main process exited, code=exited, status=1/FAILURE
systemd[1]: Unit minecraft.service entered failed state.
systemd[1]: minecraft.service failed.
我的用户数据脚本如下所示(运行 每次启动实例时):
#!/usr/bin/env bash
sudo yum -y install java-1.8.0
sudo mkdir /minecraft
sudo chown -R 777 /minecraft
cd /minecraft
aws s3 cp s3://minecraft-server-v3/setup/forge-1.12.2-14.23.5.2860-installer.jar /minecraft/forge-1.12.2-14.23.5.2860-installer.jar
export DISPLAY=:0.0
java -jar forge-1.12.2-14.23.5.2860-installer.jar --installServer
echo '#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
#Mon Aug 06 18:11:14 UTC 2018
eula=true' > eula.txt
aws s3 cp s3://minecraft-server-v3/setup/mods.zip /minecraft/mods.zip
unzip mods.zip
sudo aws s3 cp s3://minecraft-server-v3/setup/minecraft.service /etc/systemd/system/minecraft.service
sudo chmod 777 /etc/systemd/system/minecraft.service
sudo systemctl daemon-reload
sudo service minecraft start
我的 minecraft.service
文件如下所示:
[Unit]
Description=Minecraft Service
After=default.target
[Service]
Type=simple
User=ec2-user
WorkingDirectory=/minecraft
ExecStart=/usr/bin/java -Xmx8G -Xms8G -jar /minecraft/forge-1.12.2-14.23.5.2860-installer.jar nogui
知道会发生什么吗?哪个操作需要显示器?我很困惑。非常感谢任何帮助。
问题
据我了解,问题出在您的 minecraft.service
文件上。
启动服务时,您正在运行安装 forge 服务器的安装程序。
安装程序需要 X,除非 运行 带有 --installServer
标志,正如您在用户数据脚本中所做的那样。
这就是您遇到错误的原因。
解决方案
我想你想要 运行 实际的服务器 .jar
对于您使用的安装程序版本,我很确定 jar 的名称是:
minecraftforge-universal-1.12.2-14.23.5.2860.jar
以此为例,您想将当前命令替换为:
/usr/bin/java -Xmx8G -Xms8G -jar minecraftforge-universal-1.12.2-14.23.5.2860.jar nogui