目的:
准备5台虚拟机centos7,并安装docker,设置IP地址并联网
192.168.2.10
192.168.2.11
192.168.2.12
192.168.2.13
192.168.2.14
192.168.2.15
准备工作:
虚拟机软件:wmware 8.5.8
操作系统:centos 7.3.1611 (采用mini安装,安装好的镜像1.5G大小左右)
操作步骤:
Step 1. wmware安装centos(wmware网络选择桥接模式),具体步骤按照向导next,next不多说,记得打开上网功能。
设置centos:
[[email protected] ~]#vi /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE="Ethernet" BOOTPROTO="static" DEFROUTE="yes" PEERDNS="yes" PEERROUTES="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="ens33" #UUID="81c8d322-d7f7-47f6-954f-64bbe41a4eec"(uuid去掉,便于后面复制虚拟机) DEVICE="ens33" ONBOOT="yes" IPADDR=192.168.2.10 GATEWAY=192.168.2.1 NETMASK=255.255.255.0 DNS1=192.168.2.1
重新启动网络
[[email protected] ~]# service network restart Restarting network (via systemctl): [ OK ] [[email protected] ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:79:a1:48 brd ff:ff:ff:ff:ff:ff inet 192.168.2.10/24 brd 192.168.2.255 scope global ens33 valid_lft forever preferred_lft forever inet6 fe80::341d:c8b4:c7d:f28f/64 scope link valid_lft forever preferred_lft forever 3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN link/ether 02:42:20:5d:55:6e brd ff:ff:ff:ff:ff:ff inet 172.17.0.1/16 scope global docker0 valid_lft forever preferred_lft forever
设置hostname
[[email protected] ~]# hostnamectl --static set-hostname ip10-cent7
安装docker
[[email protected] ~]# yum install -y docker
设置开机启动
[[email protected] ~]# systemctl enable docker [[email protected] ~]# service docker start Redirecting to /bin/systemctl start docker.service
关闭防火墙
systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动
好了,这样ip10的机器设置完毕,接下来继续创建5台虚拟机,并设置相应ip地址
Step 2. 关闭刚才创建的虚拟机,找到虚拟机目录/${path}/ip10-cent7.vmwarevm
拷贝5份,并rename虚拟机
cp ip10-cent7.vmwarevm ip11-cent7.vmwarevm cp ip10-cent7.vmwarevm ip12-cent7.vmwarevm cp ip10-cent7.vmwarevm ip13-cent7.vmwarevm cp ip10-cent7.vmwarevm ip14-cent7.vmwarevm cp ip10-cent7.vmwarevm ip15-cent7.vmwarevm
然后用wmware软件逐一打开*.vmwarevm文件,并在关机状态下设置--网络适配器--高级选项--生成新的MAC地址,避免和第一个虚拟机mac冲突,启动虚拟机。
[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE="Ethernet" BOOTPROTO="static" DEFROUTE="yes" PEERDNS="yes" PEERROUTES="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="ens33" #UUID="81c8d322-d7f7-47f6-954f-64bbe41a4eec" DEVICE="ens33" ONBOOT="yes" IPADDR=192.168.2.11 GATEWAY=192.168.2.1 NETMASK=255.255.255.0 DNS1=192.168.2.1
重启网络,检测机器联网情况
设置hostname
[[email protected] ~]# hostnamectl --static set-hostname ip11-cent7
其他机器按类似操作。
注意:修改虚拟机时候关闭其他虚拟机,避免mac和ip地址冲突。
好了,虚拟机环境准备好了,接下来嗨皮嗨皮啦~~~原创文章,转载请注明出处!
时间: 2024-12-29 23:28:53