You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Mirror与Lightsail的Unity专用服务器启动异常求助

Unity Linux无头服务器启动仅输出内存配置参数问题排查

在AWS Lightsail Linux服务器上运行编译后的Server.x86_64时,执行./Server.x86_64仅输出Unity内存配置参数,服务器无任何启动提示。使用Mirror的KCP传输搭建基础服务器,相关信息如下:

执行命令后输出的内存配置参数

[UnityMemory] Configuration Parameters - Can be set up in boot.config
    "memorysetup-bucket-allocator-granularity=16"
    "memorysetup-bucket-allocator-bucket-count=8"
    "memorysetup-bucket-allocator-block-size=4194304"
    "memorysetup-bucket-allocator-block-count=1"
    "memorysetup-main-allocator-block-size=16777216"
    "memorysetup-thread-allocator-block-size=16777216"
    "memorysetup-gfx-main-allocator-block-size=16777216"
    "memorysetup-gfx-thread-allocator-block-size=16777216"
    "memorysetup-cache-allocator-block-size=4194304"
    "memorysetup-typetree-allocator-block-size=2097152"
    "memorysetup-profiler-bucket-allocator-granularity=16"
    "memorysetup-profiler-bucket-allocator-bucket-count=8"
    "memorysetup-profiler-bucket-allocator-block-size=4194304"
    "memorysetup-profiler-bucket-allocator-block-count=1"
    "memorysetup-profiler-allocator-block-size=16777216"
    "memorysetup-profiler-editor-allocator-block-size=1048576"
    "memorysetup-temp-allocator-size-main=4194304"
    "memorysetup-job-temp-allocator-block-size=2097152"
    "memorysetup-job-temp-allocator-block-size-background=1048576"
    "memorysetup-job-temp-allocator-reduction-small-platforms=262144"
    "memorysetup-temp-allocator-size-background-worker=32768"
    "memorysetup-temp-allocator-size-job-worker=262144"
    "memorysetup-temp-allocator-size-preload-manager=262144"
    "memorysetup-temp-allocator-size-nav-mesh-worker=65536"
    "memorysetup-temp-allocator-size-audio-worker=65536"
    "memorysetup-temp-allocator-size-cloud-worker=32768"
    "memorysetup-temp-allocator-size-gfx=262144"

服务器编译代码

[MenuItem("Build/Build Server (Linux)")]
public static void BuildLinuxServer()
{
    BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
    buildPlayerOptions.scenes = new[] { "Assets/Scenes/Main.unity" };
    buildPlayerOptions.locationPathName = "Builds/Linux/Server/Server.x86_64";
    buildPlayerOptions.target = BuildTarget.StandaloneLinux64;
    buildPlayerOptions.options = BuildOptions.CompressWithLz4HC | BuildOptions.EnableHeadlessMode;

    Console.WriteLine("Building Server (Linux)...");
    BuildPipeline.BuildPlayer(buildPlayerOptions);
    Console.WriteLine("Built Server (Linux).");
}

排查与解决步骤

  • 修复文件权限:执行chmod +x Server.x86_64赋予程序可执行权限,再重新启动。
  • 查看日志详情:在服务器运行目录下查找Player.log或Server.log文件,里面会记录启动时的报错信息,定位具体问题。
  • 显式指定无头模式:执行./Server.x86_64 -batchmode -nographics,强制以无头无图形模式启动,避免图形相关组件导致的启动异常。
  • 补全系统依赖:执行ldd Server.x86_64检查缺失的系统库,比如libgconf-2.so.4等,通过对应包管理器安装(如Ubuntu下sudo apt-get install libgconf-2-4)。
  • 验证Mirror初始化逻辑:确认Main场景中NetworkManager和KCP传输组件配置正确,且代码中已在合适时机(如场景加载完成的Start()方法)调用NetworkManager.StartServer()触发服务器启动。
  • 检查端口与防火墙:确认Mirror使用的端口(默认7777,KCP通常为UDP)未被Lightsail控制台防火墙或服务器本地防火墙拦截,开放对应端口权限。

内容的提问来源于stack exchange,提问作者Wp3Dev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 11:25:20