从AMI镜像恢复AWS Amazon Linux 2实例碰到的VNC服务以及Chrome浏览器无法启动的问题

发布时间:2023年12月26日

小结

Amazon Linux 2保存为AMI (Amazon Machine Images)后,恢复成EC2 Instance (实例)后,VNC服务以及Chrome浏览器无法启动,进行了解决。

问题及解决

如果要将一个EC2 Instance (实例)从一个VPC (Virtual Private Cloud)中迁移到另一个 VPC中,需要将EC2 Instance (实例)保存为AMI (Amazon Machine Images),再从另一个 VPC恢复这个实例。进行了此操作后,恢复后的大部分功能直接使用,但是碰到了VNC服务以及Chrome浏览器无法启动的问题。

VNC服务无法启动

报以下错误:

[ec2-user@ip-100-92-28-119 ~]$ sudo systemctl status vncserver@:1
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2023-12-25 13:17:27 UTC; 2min 13s ago
  Process: 10111 ExecStart=/usr/bin/vncserver_wrapper ec2-user %i (code=exited, status=2)
  Process: 10108 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 10111 (code=exited, status=2)

Dec 25 13:17:27 ip-100-92-28-119 systemd[1]: Starting Remote desktop service (VNC)...
Dec 25 13:17:27 ip-100-92-28-119 systemd[1]: Started Remote desktop service (VNC).
Dec 25 13:17:27 ip-100-92-28-119 vncserver_wrapper[10111]: Warning: ip-100-92-28-119:1 is taken because of /tmp/.X11-unix/X1
Dec 25 13:17:27 ip-100-92-28-119 vncserver_wrapper[10111]: Remove this file if there is no X server ip-100-92-28-119:1
Dec 25 13:17:27 ip-100-92-28-119 vncserver_wrapper[10111]: A VNC server is already running as :1
Dec 25 13:17:27 ip-100-92-28-119 systemd[1]: vncserver@:1.service: main process exited, code=exited, status=2/INVALIDARGUMENT
Dec 25 13:17:27 ip-100-92-28-119 vncserver_wrapper[10111]: FATAL: 'runuser -l ec2-user' failed!
Dec 25 13:17:27 ip-100-92-28-119 systemd[1]: Unit vncserver@:1.service entered failed state.
Dec 25 13:17:27 ip-100-92-28-119 systemd[1]: vncserver@:1.service failed.

解决办法,删除旧有的导致服务锁定的一些文件,例如使用以下办法解决了问题:

[ec2-user@ip-100-92-28-119 ~]$ sudo rm -rf /tmp/.X11-unix/X2 
[ec2-user@ip-100-92-28-119 ~]$ sudo systemctl start vncserver@:1
[ec2-user@ip-100-92-28-119 ~]$ sudo systemctl status vncserver@:1
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2023-12-25 13:22:28 UTC; 3s ago
  Process: 12823 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 12826 (vncserver_wrapp)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service
           ├─12826 /bin/sh /usr/bin/vncserver_wrapper ec2-user :1
           └─13108 sleep 0.1

Dec 25 13:22:28 ip-100-92-28-119 systemd[1]: Starting Remote desktop service (VNC)...
Dec 25 13:22:28 ip-100-92-28-119 systemd[1]: Started Remote desktop service (VNC).
Dec 25 13:22:32 ip-100-92-28-119 vncserver_wrapper[12826]: New 'ip-100-92-28-119:1 (ec2-user)' desktop is ip-100-92-28-119:1
Dec 25 13:22:32 ip-100-92-28-119 vncserver_wrapper[12826]: Starting applications specified in /home/ec2-user/.vnc/xstartup
Dec 25 13:22:32 ip-100-92-28-119 vncserver_wrapper[12826]: Log file is /home/ec2-user/.vnc/ip-100-92-28-119:1.log

Chrome浏览器无法启动

由于旧有的AMI (Amazon Machine Images)里面遗留的用户信息,Chrome浏览器无法启动,报以下错误:

[ec2-user@ip-100-92-28-119 ~]$ /usr/bin/chromium-browser 
*** longjmp causes uninitialized stack frame ***: /usr/lib64/chromium-browser/chromium-browser --enable-plugins --enable-extensions --enable-user-scripts --enable-printing --enable-gpu-rasterization --enable-sync --auto-ssl-client-auth terminated
[1225/134002.778959:ERROR:file_io_posix.cc(145)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[1225/134002.778999:ERROR:file_io_posix.cc(145)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
[604:604:1225/134002.834881:ERROR:process_singleton_posix.cc(353)] The profile appears to be in use by another Chromium process (14895) on another computer (ip-10-0-3-241.ap-southeast-1.compute.internal). Chromium has locked the profile so that it doesn't get corrupted. If you are sure no other processes are using this profile, you can unlock the profile and relaunch Chromium.
[604:604:1225/134002.834965:ERROR:message_box_dialog.cc(146)] Unable to show a dialog outside the UI thread message loop: Chromium - The profile appears to be in use by another Chromium process (14895) on another computer (ip-10-0-3-241.ap-southeast-1.compute.internal). Chromium has locked the profile so that it doesn't get corrupted. If you are sure no other processes are using this profile, you can unlock the profile and relaunch Chromium.

进行以下操作删除旧有用户信息也就是Singleton*相关文件,可以解决问题:

[ec2-user@ip-100-92-28-119 chromium]$ pwd
/home/ec2-user/.config/chromium
[ec2-user@ip-100-92-28-119 chromium]$ 
[ec2-user@ip-100-92-28-119 chromium]$ ls
AutofillStates         Crash Reports           Dictionaries                 FirstPartySetsPreloaded  hyphen-data   NativeMessagingHosts      PKIMetadata                          segmentation_platform  SingletonSocket   
BrowserMetrics         Crowd Deny              FileTypePolicies             First Run                Last Version  OnDeviceHeadSuggestModel  PrivacySandboxAttestationsPreloaded  ShaderCache            SSLErrorAssistant 
CertificateRevocation  Default                 first_party_sets.db          GraphiteDawnCache        Local State   OptimizationHints         Safe Browsing                        SingletonCookie        Subresource Filter
component_crx_cache    DeferredBrowserMetrics  first_party_sets.db-journal  GrShaderCache            MEIPreload    OriginTrials              SafetyTips                           SingletonLock          TpcdMetadata      
[ec2-user@ip-100-92-28-119 chromium]$ rm -rf Singleton*

可以正常启动chromium-browser

[ec2-user@ip-100-92-28-119 ~]$ /usr/bin/chromium-browser 
*** longjmp causes uninitialized stack frame ***: /usr/lib64/chromium-browser/chromium-browser --enable-plugins --enable-extensions --enable-user-scripts --enable-printing --enable-gpu-rasterization --enable-sync --auto-ssl-client-auth terminated
[1225/134932.848548:ERROR:file_io_posix.cc(145)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[1225/134932.848588:ERROR:file_io_posix.cc(145)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
[6597:6597:1225/134932.975664:ERROR:policy_logger.cc(156)] :components/enterprise/browser/controller/chrome_browser_cloud_management_controller.cc(161) Cloud management controller initialization aborted as CBCM is not enabled. Please use the `--enable-chrome-browser-cloud-management` command line flag to enable it if you are not using the official Google Chrome build.
[6638:6638:1225/134933.236481:ERROR:viz_main_impl.cc(196)] Exiting GPU process due to errors during initialization
[6597:6702:1225/134933.260061:ERROR:object_proxy.cc(577)] Failed to call method: org.freedesktop.DBus.Properties.Get: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[6597:6702:1225/134933.260347:ERROR:object_proxy.cc(577)] Failed to call method: org.freedesktop.UPower.GetDisplayDevice: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[6597:6702:1225/134933.260617:ERROR:object_proxy.cc(577)] Failed to call method: org.freedesktop.UPower.EnumerateDevices: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[6703:6703:1225/134933.398015:ERROR:viz_main_impl.cc(196)] Exiting GPU process due to errors during initialization
[6673:25:1225/134933.463239:ERROR:command_buffer_proxy_impl.cc(127)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.
[ec2-user@ip-100-92-28-119 ~]$ /usr/bin/chromium-browser 
*** longjmp causes uninitialized stack frame ***: /usr/lib64/chromium-browser/chromium-browser --enable-plugins --enable-extensions --enable-user-scripts --enable-printing --enable-gpu-rasterization --enable-sync --auto-ssl-client-auth terminated
[1226/104833.800228:ERROR:file_io_posix.cc(145)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[1226/104833.800269:ERROR:file_io_posix.cc(145)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
[25423:25423:1226/104833.930465:ERROR:policy_logger.cc(156)] :components/enterprise/browser/controller/chrome_browser_cloud_management_controller.cc(161) Cloud management controller initialization aborted as CBCM is not enabled. Please use the `--enable-chrome-browser-cloud-management` command line flag to enable it if you are not using the official Google Chrome build.
[25423:25513:1226/104834.192655:ERROR:object_proxy.cc(577)] Failed to call method: org.freedesktop.DBus.Properties.Get: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[25423:25513:1226/104834.193197:ERROR:object_proxy.cc(577)] Failed to call method: org.freedesktop.UPower.GetDisplayDevice: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[25423:25513:1226/104834.193375:ERROR:object_proxy.cc(577)] Failed to call method: org.freedesktop.UPower.EnumerateDevices: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[25461:25461:1226/104834.196267:ERROR:viz_main_impl.cc(196)] Exiting GPU process due to errors during initialization
[25489:27:1226/104834.266593:ERROR:command_buffer_proxy_impl.cc(127)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.


效果如下:
chrome browser

参考

chromium.org: Issue 367048: Cannot start chrome after changing hostname
askubuntu.com: “Your profile could not be opened correctly.” while opening Chrome(ium)
forums.fedoraforum.org: VNC Server Warning: localhost:1 is taken because of /tmp/.X1-lock

文章来源:https://blog.csdn.net/scruffybear/article/details/135228500
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。