最近身边的小伙伴准备接触 Hadoop,因此需要有一套自己的测试环境,便想着使用 windows 自带的 hyper-v 来搭建一套学习环境,顺便记录一下搭建过程,也方便给其它小伙伴做参考。文章所涉及的配置方法(仅做为参考),大家可结合自身情况进行相应的调整。前往下载 CentOS镜像
如果尚未安装 hyper-v,自行前往:程序和功能 -> 启用或关闭Windows功能 -> 勾选 Hyper-V 相关服务
系统安装
1. 由于本机有提前下载好的ios文件,所以本示例为通过iso文件进行安装演示

创建成功后点启动

按键盘上键( ↑ ) 选中第一个选项,按回车( Enter )

出现此界面后,根据自身情况一步步选择,直到最后重启就安装完成了。

网络配置
1. 创建一个虚拟网络,方便对虚拟机做静态ip配置


2. 打开网络配置,找到新创建的 PrivateNet 网络,属性进行IP网段配置

3. 为新创建的虚拟机添加新网络

4. 系统安装过程已跳过(点点点就行),完成后对网络进行静态ip处理,切换到网络配置目录cd /etc/sysconfig/network-scripts

修改配置文件 vi ifcfg-eth0

修改配置文件 vi ifcfg-eth1

5. 重启虚拟机后ping
可以成功访问外网,证明网络配置没有问题

至此网络配置已全部完成,多主机间可以通过配置的静态ip进行互相访问。如果多主机间需要ssh互通,可参考另一篇文章:SSH 实现多主机间互相免密登录
切换国内软件源
无法通过yum
安装软件时,可以切换到国内软件源
bash
# 备份文件
cd /etc/yum.repos.d
mkdir repo_bak
mv *.repo repo_bak
# 使用国内源
# CentOS7:curl -o CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
curl -o CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
# 生成缓存
yum makecache