Windows 11的Hyper-V配置
(写在前面的话)
我最近开始对docker部署有点兴趣,属于从头开始学习(真正零基础),开个专栏记录一下学习笔记。
正好Windows从22H2版本开始原生态的Hyper-V有了很大的改善,这次就不用传统的VMware。尝试一下新工具。
Windows 11的Hyper-V配置
安装Hyper-V
笔者买的Matebook X pro的系统是家庭版的,默认是不安装Hyper-V组件的。
-
将下述命令保存为 “hyper-v.bat” 文件,并以管理员身份运行安装Hyper-V组件。
pushd "%~dp0" dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i" del hyper-v.txt Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL pause -
打开 控制面板 ⇒ \Rightarrow ⇒ 程序 ⇒ \Rightarrow ⇒ “启用或关闭Windows功能”,勾选如下windows功能
-
Hyper-V
-
Windows 虚拟机监控程序平台
-
虚拟机平台
-
-
重启 计算机后可以搜索到“Hyper-V管理器”,打开后的界面如下图所示

安装Centos 7
-
前往 阿里云开源镜像站 下载centos-7-isos-x86_64安装包
-
创建 内部 网络的 交换虚拟机。(我一开始按照网上教程使用外网交换虚拟机,Centos安装好之后无论是动态还是静态IP都连不上网,后来换成内网交换虚拟机就OK了)

-
按部就班地创建Centos 7虚拟机。
-
新建 ⇒ \Rightarrow ⇒ 虚拟机
-
虚拟机的代数选择 第一代,启动内存设置 4096MB(我电脑的内存是 16G,根据自己的实际情况配置)
-
配置网络选择刚才新建的 内网交换机
-
虚拟硬盘的大小 20G
-
选择之前下载的CentOS-7-x86_64-DVD-2207-02.iso镜像进行安装即可
-
-
(如果虚拟机代数选的是 第二代)开机前选中 centos7虚拟机,右键 设置 ⇒ \Rightarrow ⇒ 安全 中关闭 “安全启动”
-
双击第一次开机,并进行 centos7 系统的安装,这里不再赘述 (安装组件选择 GNOME桌面版)
配置yum源
国外的yum源下载速度过慢,配置到阿里云
#尝试ping mirrors.aliyun.com
[root@centos ~]$ ping mirrors.aliyun.com
PING mirrors.aliyun.com.w.alikunlun.com (121.194.7.196) 56(84) bytes of data.
64 bytes from 121.194.7.196 (121.194.7.196): icmp_seq=1 ttl=54 time=17.4 ms
64 bytes from 121.194.7.196 (121.194.7.196): icmp_seq=2 ttl=54 time=21.0 ms
64 bytes from 121.194.7.196 (121.194.7.196): icmp_seq=3 ttl=54 time=16.7 ms
#查看并备份官方的yum源配置
[root@centos ~]$ cat /etc/yum.repos.d/CentOS-Base.repo
[root@centos ~]$ mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#下载Centos-7.repo文件
[root@centos ~]$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#清除和生成yum缓存
[root@centos ~]$ yum clean all
[root@centos ~]$ yum makecache
Tips
Hyper-V不支持与宿主机之间剪切板的共享,导致很多网上找到的命令都要自己手打,很不方便。还不如直接用Windows11的cmd通过ssh来访问(这里实名表扬一波Win11的cmd颜值)
C:\Users\thurc> ssh root@192.168.137.126
具体IP地址可以在Hyper-V管理器中查询到

3万+

被折叠的 条评论
为什么被折叠?



