具体问题情况如下:
C:\WINDOWS\system32>multipass launch --name my-vm 20.04
launch failed: Remote "" is unknown or unreachable.
C:\WINDOWS\system32>multipass ls
No instances found.
C:\WINDOWS\system32>multipass startlaunch failed: Remote "" is unknown or unreachable.
launch failed: Remote "" is unknown or unreachable.
第一个问题:设置local.driver为virtualbox
C:\WINDOWS\system32>multipass set local.driver=virtualbox
C:\WINDOWS\system32>multipass get local.driver
virtualbox
C:\WINDOWS\system32>
但是发现再次运行multipass launch仍然失败。
失败原因如下:
C:\WINDOWS\system32>multipassd restart
E0506 14:22:17.230000000 13160 chttp2_server.cc:1044] UNKNOWN:No address added out of total 2 resolved for 'localhost:50051' {created_time:"2024-05-06T06:22:17.2291532+00:00", children:[UNKNOWN:Failed to add port to server {created_time:"2024-05-06T06:22:17.2172129+00:00", children:[UNAVAILABLE:WSA Error {syscall:"bind", os_error:"Only one usage of each socket address (protocol/network address/port) is normally permitted.\r\n", grpc_status:14, wsa_error:10048, created_time:"2024-05-06T06:22:17.2171038+00:00"}]}, UNKNOWN:Failed to add port to server {created_time:"2024-05-06T06:22:17.2173117+00:00", children:[UNAVAILABLE:WSA Error {syscall:"bind", os_error:"Only one usage of each socket address (protocol/network address/port) is normally permitted.\r\n", grpc_status:14, wsa_error:10048, created_time:"2024-05-06T06:22:17.2172799+00:00"}]}]}error: Failed to start multipass gRPC service at localhost:50051.
原因:端口50051已经被占用,cmd中查看占用进程,输入netstat命令:
netstat -aon | findstr :50051
出现如下:
C:\Users\Xheng1934>netstat -aon | findstr :50051
TCP 127.0.0.1:50051 0.0.0.0:0 LISTENING 3776
TCP 127.0.0.1:50051 127.0.0.1:57935 TIME_WAIT 0
TCP [::1]:50051 [::]:0 LISTENING 3776
TCP [::1]:50051 [::1]:57934 TIME_WAIT 0
TCP [::1]:57940 [::1]:50051 TIME_WAIT 0
C:\Users\Xheng1934>
打开任务管理器-详细信息,找到pid为3776的进程,发现是multipassd.exe,UAC虚拟化设置为了不允许(UAC虚拟化跟本次问题无关)
端口号为50051,pid为3776,二者不是一个数字。
解决方案:
任务管理器端口号不是pid
解决方案:
1:管理员cmd运行:
taskkill /PID 3776 /F
结果如下:
C:\WINDOWS\system32>taskkill /PID 3776 /F成功: 已终止 PID 为 3776 的进程。
重新multipassd restart:
C:\WINDOWS\system32>multipassd restart
E0506 14:39:44.645000000 15312 chttp2_server.cc:1044] UNKNOWN:No address added out of total 2 resolved for 'localhost:50051' {created_time:"2024-05-06T06:39:44.6452589+00:00", children:[UNKNOWN:Failed to add port to server {created_time:"2024-05-06T06:39:44.6451464+00:00", children:[UNAVAILABLE:WSA Error {syscall:"bind", os_error:"Only one usage of each socket address (protocol/network address/port) is normally permitted.\r\n", grpc_status:14, wsa_error:10048, created_time:"2024-05-06T06:39:44.6449827+00:00"}]}, UNKNOWN:Failed to add port to server {created_time:"2024-05-06T06:39:44.6452471+00:00", children:[UNAVAILABLE:WSA Error {created_time:"2024-05-06T06:39:44.6452191+00:00", wsa_error:10048, grpc_status:14, os_error:"Only one usage of each socket address (protocol/network address/port) is normally permitted.\r\n", syscall:"bind"}]}]}error: Failed to start multipass gRPC service at localhost:50051.C:\WINDOWS\system32>
可见仍然失效。
2:切换默认json文件中的端口号
文件的路径为C:\Users\你的用户名\.multipass\daemon.json下添加:
grpc_listen_address: "localhost:50052"
若无.multipass文件夹,则在目录
C:\Users\Xheng1934\AppData\Local\multipass
下的conf文件内添加:
grpc_listen_address=127.0.0.1:5005
此方法仍然失效。
3:网络问题,查看防火墙,切换网络。
看到github上说有火绒解决的,尝试后无果。
4:关闭win10家庭版中自行安装的Hyper-V功能,有可能起冲突。
控制面板-程序-程序和功能-启用或关闭windows功能
关闭hyperV后成功如图。
解决方法是:
一开始为自己的win10家庭版安装了hyper-V(前面有文章提到过),hyperV和新安装的virtualbox起冲突,具体冲突原因是:需要在没有安装hyperV的情况下,执行这一行:
multipass set local.driver=virtualbox
再检查下确定是virtualbox:
multipass get local.driver
以上都是再没有安装hyperV的情况下执行的,安装hyperV会起冲突。
目前问题launch failed: Remote "" is unknown or unreachable.已经解决。
不过出现了新问题。新问题出现的原因可能是不相干的。因此下篇再说。按照这个方法一般能解决。