第一步 创建三个虚拟机 可复制可克隆
1.复制法:
找到目标虚拟机复制粘贴
复制完成后修改文件名(自定义起名不要有中文)
使用VMware打开三台虚拟机
全部开机
开机时如果询问您是复制的还是移动的,选择我是复制的 等待开机输入用户名和密码
2. 克隆法
全部开机登录
登录成功后
3.更改虚拟机配置信息 ip MAC地址 网卡等
输入 vim /etc/sysconfig/network-scripts/ifcfg-eth0
回车进入
更改网卡信息
我的ip换成了192.168.100.50
后面两台顺位换成了192.168.100.51 和 192.168.100.52最后一个小数点后面的位数可以自定义 但是不能使用 0 或 1 或 2 或 255 可用范围 3 到 244
保存退出
编辑第二个文件 vim /etc/udev/rules.d/70-persistent-net.rules
这是完成后的样子
保存退出
重启系统生效(另外两台虚拟机也是同样操作)
三台机器关闭防火墙
service iptables stop 临时关闭防火墙
chkconfig iptables off 永久关闭防火墙(开机不自启)
chkconfig ipconfig on 开机自启动防火墙
三台机器关闭selinux
命令 vim /etc/selinux/config
三台主机更改主机名
命令 vim /etc/sysconfig/network
重启后会生效
给三台机器的ip起别名
命令 vim /etc/hosts
测试 ping hadoop02
ctrl + c 退出测试
SSH远程登录
有密码远程登录
语法
ssh 节点名或者节点ip
需求 从01节点用密码远程登录到02节点上面
命令 ssh hadoop02
exit 命令退出远程登录
无密码远程登录 生成私钥和公钥
命令 ssh-keygen
在本机 和 hadoop02 和hadoop03 节点上同样执行此操作
重点:
把hadoop02节点和hadoop03节点的公钥发送到hadoop01节点
hadoop01节点也需要发送公钥给hadoop01节点
命令格式 ssh-copy-id 节点名或者节点ip
三台节点都需要执行此命令:ssh-copy-id hadoop01
然后hadoop01 节点就会多出这样一个文件
查看authorized_keys文件会发现保存着三台集群机器的公钥,再把这个文件远程拷贝到其他两台节点上
命令:scp .ssh/authorized_keys hadoop02:/root/.ssh/
去hadoop02节点查看会发现多一个authorized_keys文件与hadoop01节点的authorized_keys文件内容一样
同样操作拷贝到hadoop03节点,这样就实现了三台节点之间免密码登录
三台机器时钟同步
确认是否安装了ntpd 服务 没有安装先安装一下
查看命令 rpm -qa | grep ntpd
如果有就说明已安装如果没有执行下面安装命令
yum install -y ntpd
启动服务 一定要启动服务才能使用ntpdate命令 关闭防火墙
service htpd start 启动服务的命令
在虚拟机联网状态下同步阿里云的时钟服务器(能ping通百度说明已联网)
命令ntpdate ntp4.aliyun.com
确定 (否)没有启动 ntpd 服务和关闭了防火墙
ntpd服务是为了做本地时钟同步用的
在企业中大部分的集群为了数据的安全是没办法连接外网的所以只能以集群中的某一台机器作为本地的时钟同步服务器
第一步
编辑 /etc/ntp.conf
注释掉以下四行内容
#server0.centos.pool.ntp.org
#server1.centos.pool.ntp.org
#server2.centos.pool.ntp.org
#server3.centos.pool.ntp.org
在文件中添加如下内容, 配置我们的时钟广播地址
restrict **本地时钟同步服务器的节点ip** mask 255.255.255.0 nomodify notrap
server 127.127.1.0 # localclock
fudge 127.127.1.0 stratum 10
第二步
编辑 vim /etc/sysconfig/ntpd
添加一行内容
SYNC_HWLOCK=yes
注意: 如果更改ntp时钟服务器的时间,也需要重启 ntpd 服务
使用本地时钟同步服务器同步时间
命令格式 ntpdate 节点名或者节点ip
注意
关闭ntpd 服务就解决了