一、准备:
1、修改主机名,设置集群host
修改主机名,并使之生效; 修改:vim etc/sysconfig/network
统一设置集群host(修改集群中每个节点的hosts文件):vim /etc/hosts
2、利用ntp设置时间同步
less /etc/localtime检查时区看最后一行是否是CST-8,如果不是,执行以下命令修改。
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime |
因为hdp中有服务需要集群的时间同步,所以集群中的每一个机器需要安装启动ntp服务保证集群时间的一致,安装启动如下所示:
for host in node{1,2,3};do ssh root@$host yum install ntp -y; ssh root@$host; done
配置NTP同步:
服务端:
node1作为ntp server,其他节点与其同步
ntpdate -u 202.112.10.36 //可不执行,目的是与网络同步
修改时间:date -s "2018-3-1 15:58:00" //当前时间
写入硬件:clock -w
配置服务端:
vi /etc/ntp.conf
写入自己的地址:
restrict 192.168.2.0 mask 255.255.255.0 nomodify notrap
在# Please consider joining the pool (http://www.pool.ntp.org/join.html)后添加两行:
server 127.127.1.0
fudge 127.127.1.0 stratum 10 #后面的数字在0-15之间都可以,这样就将该机器作为ntp服务器提供给客户端
service ntpd start 或者 /etc/init.d/ntpd start
chkconfig ntpd on #设置为自启动
检查端口是否开启:如果正常可以看见123端口
netstat -unlp
客户端:
vi /etc/ntp.conf
在# Please consider joining the pool (http://www.pool.ntp.org/join.html) 后面添加:
server node1
保存
ntpdate node1 #client端ntp服务未启动时执行
service ntpd start 或者 /etc/init.d/ntpd start
chkconfig ntpd on #设置为自启动
3、防火墙配置
因为集群中的线程之间需要互相通信,所以需要合理配置防火墙,最简单的方式是直接关闭防火墙。操作如下所示:
for host in node{1,2,3};do ssh root@$host /etc/init.d/iptables stop; ssh root@$host chkconfig iptables off; done
或者:
service iptables stop
service ip6tables stop
设置成始终保持关闭:
chkconfig iptables off
chkconfig ip6tables off
4、设置集群免密登录
因为在ambari和hdp部署过程中,ambari和hdp部署的节点都有可能互相访问,所以建议四个节点中的每个节点之间都可以ssh无密码登录,包括它们自己登录到自己。
在Node1机器上执行如下操作,首先查看该用户根目录下的