【二】ZooKeeper 学习 - VirtualBox 配置虚拟网络

在 VirtualBox 安装完 CentOS 之后,还不能联网,
1、在 VirtualBox 的 管理 | 主机网络管理器:
【二】ZooKeeper 学习 - VirtualBox 配置虚拟网络
点击应用。
2、新建操作系统 centos1 的设置
【二】ZooKeeper 学习 - VirtualBox 配置虚拟网络
3、启动虚拟操作系统,进入 CentOS 系统修改配置文件
【二】ZooKeeper 学习 - VirtualBox 配置虚拟网络

cd /etc/sysconfig/network-scripts
vi ifcfg-enp0s3

【二】ZooKeeper 学习 - VirtualBox 配置虚拟网络
将 ONBOOT 改成 yes。
然后执行

network service restart 

【二】ZooKeeper 学习 - VirtualBox 配置虚拟网络
这样就可以联网了。
在我安装虚拟机的宿主电脑上:
【二】ZooKeeper 学习 - VirtualBox 配置虚拟网络
可以 ping 通到虚拟机系统。
4、将虚拟机系统改成固定的 IP 地址
进入虚拟机系统,在终端

 cd /etc/sysconfig/network-scripts
 cp fcfg-enp0s3 fcfg-enp0s8
 vi ifcfg-enp0s8

修改 ifcfg-enp0s8 的配置,保留如下的配置就行:
【二】ZooKeeper 学习 - VirtualBox 配置虚拟网络
重新启动网络服务,IP 地址就变成固定的了:
【二】ZooKeeper 学习 - VirtualBox 配置虚拟网络
在宿主电脑上:
【二】ZooKeeper 学习 - VirtualBox 配置虚拟网络
OK,虚拟机的静态 IP 修改成功。
5、ssh 连上虚拟机
【二】ZooKeeper 学习 - VirtualBox 配置虚拟网络
能用上 ssh 了,想着就很爽。