Linux,全称GNU/Linux,是一种免费使用和自由传播的类UNIX操作系统,其内核由林纳斯·本纳第克特·托瓦兹于1991年10月5日首次发布,它主要受到Minix和Unix思想的启发,是一个基于POSIX的多用户、多任务、支持多线程和多CPU的操作系统。
在搭建Spark 集群的时候,需要3台虚拟机,为了操作简便,选择搭建一台虚拟机后,另外两台直接选择克隆的方式来实现,于是,克隆会出现几个问题。
网络的配置和源机一样
用户名称与源机一样
用户的hosts 与源机一样
OK,咱们现在知道,有这3个东西,是和源机保持一致的,那么,咱们需要做的事,就是,修改这3个部分的内容,即可,下面,咱们以将克隆机修改为spark2的作为例子。
1.修改网络配置
首先咱们观察到,spark1的网络配置为:
[root@spark1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:30:E5:54
TYPE=Ethernet
UUID=18b5fd33-bcf0-408b-ac48-f7d7ba3aa03d
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.30.111
NETMASK=255.255.255.0
GATEWAY=192.168.30.2
注意:这两个地方,是需要修改的部分,首先,HWADDR是mac地址,每一台机器有一个固定的mac地址,而IPADDR是 ip 地址,每一台机器也是独立的拥有单独的IP。
先修改 mac地址,由于克隆机会自动生成一个新的mac 地址,但是,需要我们来自己改动。
[root@spark2 ~]# vi /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:30:e5:54", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:15:1b:71", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
将上面的内容进行修改,并且,注意留意eth1的mac设置
修改后
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:30:e5:54", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:15:1b:71", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
注意修改的内容为:
1].注释掉了
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:30:e5:54", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
2].修改了
NAME="eth1"为NAME="eth0"
将该修改后内容保存后退出。
[root@spark1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
进入网络设置,修改配置为:
DEVICE=eth0
HWADDR=00:0c:29:15:1b:71
TYPE=Ethernet
UUID=18b5fd33-bcf0-408b-ac48-f7d7ba3aa03d
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.30.112
NETMASK=255.255.255.0
GATEWAY=192.168.30.2
保存后退出。
执行命令:
[root@spark1 ~]# service network restart
2.修改主机名称
[root@spark1 ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=spark2
3.修改用户hosts
[root@spark2 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.30.112 spark2
最后一步,重新启动客户机! reboot 即可成功!