[root@hadoop100 hadoop]# ssh hadoop102 "jps"
bash: jps: command not found
执行脚本变量
[root@hadoop100 hadoop]# ssh hadoop102 "source /etc/profile && jps"
11028 NodeManager
10588 SecondaryNameNode
9774 DataNode
12174 Jps
[root@hadoop100 hadoop]#
配置历史服务器
为了查看程序的历史运行情况,需要配置一下历史服务器。具体配置步骤如下:
- 配置mapred-site.xml
[root@hadoop100 hadoop]# vim mapred-site.xml
<!-- 历史服务器端地址 -->
<property>
<name>mapreduce.jobhistory.address</name>
<value>hadoop100:10020</value>
</property>
<!-- 历史服务器web端地址 -->
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>hadoop100:19888</value>
</property>
配置yarn-site.xml
<!-- 日志聚集功能使能 -->
<property>
<name>yarn.log-aggregation-enable</name>
<value>true</value>
</property>
<!-- 日志保留时间设置7天 -->
<property>
<name>yarn.log-aggregation.retain-seconds</name>
<value>604800</value>
- 启动历史服务器
sbin/mr-jobhistory-daemon.sh start historyserver
[root@hadoop100 hadoop-2.7.2]# sbin/mr-jobhistory-daemon.sh start historyserver
starting historyserver, logging to /opt/hadoop/module/hadoop-2.7.2/logs/mapred-root-historyserver-hadoop100.out
[root@hadoop100 hadoop-2.7.2]#
分发Hadoop101、hadoop102
[root@hadoop100 hadoop]# scp -r /opt/hadoop/module/hadoop-2.7.2/etc/hadoop/* root@hadoop101:/opt/hadoop/module/hadoop-2.7.2/etc/hadoop/
[root@hadoop100 hadoop]# scp -r /opt/hadoop/module/hadoop-2.7.2/etc/hadoop/* root@hadoop102:/opt/hadoop/module/hadoop-2.7.2/etc/hadoop/
重新启动
[root@hadoop100 hadoop-2.7.2]# start-all.sh
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
Starting namenodes on [hadoop100]
..................
访问8088
关闭NodeManager 、ResourceManager和HistoryServer
[root@hadoop100 hadoop-2.7.2]# sbin/yarn-daemon.sh stop resourcemanager
stopping resourcemanager
[root@hadoop100 hadoop-2.7.2]# sbin/yarn-daemon.sh stop nodemanager
stopping nodemanager
[root@hadoop100 hadoop-2.7.2]# sbin/mr-jobhistory-daemon.sh stop historyserver
stopping historyserver
启动NodeManager 、ResourceManager和HistoryServer
[root@hadoop100 hadoop-2.7.2]# sbin/yarn-daemon.sh start resourcemanager
starting resourcemanager, logging to /opt/hadoop/module/hadoop-2.7.2/logs/yarn-root-resourcemanager-hadoop100.out
[root@hadoop100 hadoop-2.7.2]# sbin/yarn-daemon.sh start nodemanager
starting nodemanager, logging to /opt/hadoop/module/hadoop-2.7.2/logs/yarn-root-nodemanager-hadoop100.out
[root@hadoop100 hadoop-2.7.2]# sbin/mr-jobhistory-daemon.sh start historyserver
starting historyserver, logging to /opt/hadoop/module/hadoop-2.7.2/logs/mapred-root-historyserver-hadoop100.out
查看进程
[root@hadoop100 hadoop-2.7.2]# jps
10672 NodeManager
7765 DataNode
10824 JobHistoryServer
10860 Jps
7629 NameNode
10431 ResourceManager
[root@hadoop100 hadoop-2.7.2]#
集群时间同步
时间同步的方式:找一个机器,作为时间服务器,所有的机器与这台集群时间进行定时的同步,比如,每隔十分钟,同步一次时间。
配置时间同步具体实操:
- 时间服务器配置(必须root用户)
(1)检查ntp是否安装,没有就安装
[root@hadoop100 ~]# rpm -qa|grep ntp
[root@hadoop100 ~]#
[root@hadoop100 ~]# yum install ntp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
......................................
......................................
(2)修改ntp配置文件
修改之前,首先,必须把ntp服务停止
[root@hadoop100 ~]# systemctl stop ntpd.service
接着,需要把ntp关闭
[root@hadoop100 ~]# systemctl disable ntpd.service
[root@hadoop100 ~]#
接下来,我们就可以编辑修改ntp的配置文件
[root@hadoop100 ~]# vim /etc/ntp.conf
server 127.127.1.0
fudge 127.127.1.0 stratum 10
保存,退出!
接着,修改/etc/sysconfig/ntpd 文件
vim etc/sysconfig/ntpd
增加内容如下(让硬件时间与系统时间一起同步)
SYNC_HWCLOCK=yes
保存,退出!
重新启动ntpd服务
[root@hadoop100 ~]# systemctl status ntpd.service
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
[root@hadoop100 ~]#
ntpd 已停
[root@hadoop100 ~]# systemctl start ntpd.service
[root@hadoop100 ~]#
正在启动 ntpd
查看ntpd状态:
systemctl status ntpd.service
[root@hadoop100 ~]# systemctl status ntpd.service
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2019-11-20 17:01:41 GMT; 56s ago
Process: 11182 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 11183 (ntpd)
CGroup: /system.slice/ntpd.service
└─11183 /usr/sbin/ntpd -u ntp:ntp -g
Nov 20 17:01:41 hadoop100 ntpd[11183]: Listen normally on 2 lo 127.0.0.1 UDP 123
Nov 20 17:01:41 hadoop100 ntpd[11183]: Listen normally on 3 ens33 192.168.219.7 UDP 123
Nov 20 17:01:41 hadoop100 ntpd[11183]: Listen normally on 4 docker0 172.17.0.1 UDP 123
Nov 20 17:01:41 hadoop100 ntpd[11183]: Listen normally on 5 lo ::1 UDP 123
Nov 20 17:01:41 hadoop100 ntpd[11183]: Listen normally on 6 ens33 fe80::565c:1d78:2a6f:ed3e UDP 123
Nov 20 17:01:41 hadoop100 ntpd[11183]: Listening on routing socket on fd #23 for interface updates
Nov 20 17:01:41 hadoop100 ntpd[11183]: 0.0.0.0 c016 06 restart
Nov 20 17:01:41 hadoop100 ntpd[11183]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
Nov 20 17:01:41 hadoop100 ntpd[11183]: 0.0.0.0 c011 01 freq_not_set
Nov 20 17:01:42 hadoop100 ntpd[11183]: 0.0.0.0 c514 04 freq_mode
[root@hadoop100 ~]#
接着,设置ntpd服务开机启动
[root@hadoop100 ~]# systemctl enable ntpd.service
yi'ic[root@hadoop100 ~]#
2. 其他机器配置(必须root用户)
(1)在其他机器配置10分钟与时间服务器同步一次
[root@hadoop100 ~]# crontab -e
编写定时任务如下:
*/1 * * * * /usr/sbin/ntpdate hadoop102
意思:每隔一分钟执行/usr/sbin/ntpdate hadoop102一次
保存,退出!
修改任意机器时间
[root@hadoop100 ~]# date -s "2017-9-11 11:11:11"
Mon Sep 11 11:11:11 GMT 2017
[root@hadoop100 ~]#
十分钟后查看机器是否与时间服务器同步
[root@hadoop100 ~]# date
Mon Sep 11 11:14:22 GMT 2017
[root@hadoop100 ~]#