E-MapReduce集群运维指南
本篇主要旨在说明EMR集群的一些运维的手段,方便大家在使用的时候可以自主的进行服务的运维。
一些通用的环境变量
在集群上,输入env命令可以看到类似如下的环境变量配置(以集群上最新的配置为准,此处只做参考):
- [backcolor=transparent]JAVA_HOME[backcolor=transparent]=[backcolor=transparent]/usr/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]jvm[backcolor=transparent]/[backcolor=transparent]java
- [backcolor=transparent]HADOOP_HOME[backcolor=transparent]=[backcolor=transparent]/usr/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current
- [backcolor=transparent]HADOOP_CLASSPATH[backcolor=transparent]=[backcolor=transparent]/usr/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/*:/usr/lib/tez-current/*:/usr/lib/tez-current/lib/*:/etc/emr/tez-conf:/usr/lib/hbase-current/lib/*:/usr/lib/tez-current/*:/usr/lib/tez-current/lib/*:/etc/emr/tez-conf:/opt/apps/extra-jars/*:/opt/apps/extra-jars/*
- [backcolor=transparent]HADOOP_CONF_DIR=/etc/emr/hadoop-conf
- [backcolor=transparent]SPARK_HOME=/usr/lib/spark-current
- [backcolor=transparent]SPARK_CONF_DIR=/etc/emr/spark-conf
- [backcolor=transparent]HBASE_HOME=/usr/lib/hbase-current
- [backcolor=transparent]HBASE_CONF_DIR=/etc/emr/hbase-conf
- [backcolor=transparent]HIVE_HOME=/usr/lib/hive-current
- [backcolor=transparent]HIVE_CONF_DIR=/etc/emr/hive-conf
- [backcolor=transparent]PIG_HOME=/usr/lib/pig-current
- [backcolor=transparent]PIG_CONF_DIR=/etc/emr/pig-conf
- [backcolor=transparent]TEZ_HOME=/usr/lib/tez-current
- [backcolor=transparent]TEZ_CONF_DIR=/etc/emr/tez-conf
- [backcolor=transparent]ZEPPELIN_HOME=/usr/lib/zeppelin-current
- [backcolor=transparent]ZEPPELIN_CONF_DIR=/etc/emr/zeppelin-conf
- [backcolor=transparent]HUE_HOME=/usr/lib/hue-current
- [backcolor=transparent]HUE_CONF_DIR=/etc/emr/hue-conf
- [backcolor=transparent]PRESTO_HOME=/usr/lib/presto-current
- [backcolor=transparent]PRESTO_CONF_DIR=/etc/emr/presot-conf
服务进程的启停
YARN
[backcolor=transparent]操作用账号:hadoop
- ResourceManager (Master节点)
-
[backcolor=transparent]
// 启动
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]yarn[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh start resourcemanager
- [backcolor=transparent]// 停止
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]yarn[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh stop resourcemanager
- NodeManager (Core节点)
-
[backcolor=transparent]
// 启动
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]yarn[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh start nodemanager
- [backcolor=transparent]// 停止
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]yarn[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh stop nodemanager
- JobHistoryServer (Master节点)
-
[backcolor=transparent]
// 启动
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]mr[backcolor=transparent]-[backcolor=transparent]jobhistory[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh start historyserver
- [backcolor=transparent]// 停止
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]mr[backcolor=transparent]-[backcolor=transparent]jobhistory[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh stop historyserver
- WebProxyServer (Master节点)
-
[backcolor=transparent]
// 启动
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]yarn[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh start proxyserver
- [backcolor=transparent]// 停止
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]yarn[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh stop proxyserver
HDFS
[backcolor=transparent]操作用账号:hdfs
- NameNode (Master节点)
-
[backcolor=transparent]
// 启动
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh start namenode
- [backcolor=transparent]// 停止
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh stop namenode
DataNode (Core节点)
-
[backcolor=transparent]
// 启动
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh start datanode
- [backcolor=transparent]// 停止
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh stop datanode
Hive
[backcolor=transparent]操作用账号:hadoop
MetaStore (Master节点)
-
[backcolor=transparent]
// 启动,这里的内存可以根据需要扩大
- [backcolor=transparent]HADOOP_HEAPSIZE[backcolor=transparent]=[backcolor=transparent]512[backcolor=transparent] [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hive[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]bin[backcolor=transparent]/[backcolor=transparent]hive [backcolor=transparent]--[backcolor=transparent]service metastore [backcolor=transparent]>[backcolor=transparent]/var/[backcolor=transparent]log[backcolor=transparent]/[backcolor=transparent]hive[backcolor=transparent]/[backcolor=transparent]metastore[backcolor=transparent].[backcolor=transparent]log [backcolor=transparent]2[backcolor=transparent]>&[backcolor=transparent]1[backcolor=transparent] [backcolor=transparent]&
- HiveServer2 (Master节点)
-
[backcolor=transparent]
// 启动
- [backcolor=transparent]HADOOP_HEAPSIZE[backcolor=transparent]=[backcolor=transparent]512[backcolor=transparent] [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hive[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]bin[backcolor=transparent]/[backcolor=transparent]hive [backcolor=transparent]--[backcolor=transparent]service hiveserver2 [backcolor=transparent]>[backcolor=transparent]/var/[backcolor=transparent]log[backcolor=transparent]/[backcolor=transparent]hive[backcolor=transparent]/[backcolor=transparent]hiveserver2[backcolor=transparent].[backcolor=transparent]log [backcolor=transparent]2[backcolor=transparent]>&[backcolor=transparent]1[backcolor=transparent] [backcolor=transparent]&
HBase
[backcolor=transparent]操作用账号:hdfs
需要注意的,需要在组件中选择了HBase以后才能使用如下的方式来启动,否则对应的配置未完成,启动的时候会有错误。
- HMaster (Master节点)
-
[backcolor=transparent]
// 启动
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]bin[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh start master
- [backcolor=transparent]// 重启
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]bin[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh restart master
- [backcolor=transparent]// 停止
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]bin[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh stop master
- HRegionServer (Core节点)
-
[backcolor=transparent]
// 启动
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]curren[backcolor=transparent]/[backcolor=transparent]bin[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh start regionserver
- [backcolor=transparent]// 重启
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]curren[backcolor=transparent]/[backcolor=transparent]bin[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh restart regionserver
- [backcolor=transparent]// 停止
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]curren[backcolor=transparent]/[backcolor=transparent]bin[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh stop regionserver
- ThriftServer (Master节点)
-
[backcolor=transparent]
// 启动
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]bin[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh start thrift [backcolor=transparent]-[backcolor=transparent]p [backcolor=transparent]9099[backcolor=transparent] [backcolor=transparent]>[backcolor=transparent]/var/[backcolor=transparent]log[backcolor=transparent]/[backcolor=transparent]hive[backcolor=transparent]/[backcolor=transparent]thriftserver[backcolor=transparent].[backcolor=transparent]log [backcolor=transparent]2[backcolor=transparent]>&[backcolor=transparent]1[backcolor=transparent] [backcolor=transparent]&
- [backcolor=transparent]// 停止
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]bin[backcolor=transparent]/[backcolor=transparent]hbase[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh stop thrift
Hue
[backcolor=transparent]操作用账号:hadoop
- [backcolor=transparent]// 启动
- [backcolor=transparent]su [backcolor=transparent]-[backcolor=transparent]l root [backcolor=transparent]-[backcolor=transparent]c [backcolor=transparent]"${HUE_HOME}/build/env/bin/supervisor >/dev/null 2>&1 &"
- [backcolor=transparent]// 停止
- [backcolor=transparent]ps axu [backcolor=transparent]|[backcolor=transparent] grep hue [backcolor=transparent]// 查找到所有的hue进程
- [backcolor=transparent]kill [backcolor=transparent]-[backcolor=transparent]9[backcolor=transparent] huepid [backcolor=transparent]// 杀掉查找到的对应hue进程
Zeppelin
[backcolor=transparent]操作用账号:hadoop
- [backcolor=transparent]// 启动, 这里的内存可以根据需要扩大
- [backcolor=transparent]su [backcolor=transparent]-[backcolor=transparent]l root [backcolor=transparent]-[backcolor=transparent]c [backcolor=transparent]"ZEPPELIN_MEM=\"-Xmx512m -Xms512m\" ${ZEPPELIN_HOME}/bin/zeppelin-daemon.sh start"
- [backcolor=transparent]// 停止
- [backcolor=transparent]su [backcolor=transparent]-[backcolor=transparent]l root [backcolor=transparent]-[backcolor=transparent]c [backcolor=transparent]"${ZEPPELIN_HOME}/bin/zeppelin-daemon.sh stop"
Presto
[backcolor=transparent]操作用账号:hdfs
- PrestoServer (Master节点)
-
[backcolor=transparent]
// 启动
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]presto[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]//bin/launcher --config=/usr/lib/presto-current/etc/worker-config.properties start
- [backcolor=transparent]// 停止
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]presto[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]//bin/launcher --config=/usr/lib/presto-current/etc/worker-config.properties stop
- (Core节点)
-
[backcolor=transparent]
// 启动
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]presto[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]//bin/launcher --config=/usr/lib/presto-current/etc/coordinator-config.properties start
- [backcolor=transparent]// 停止
- [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]presto[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]//bin/launcher --config=/usr/lib/presto-current/etc/coordinator-config.properties stop
批量操作
当需要对worker(Core)节点做统一操作时,可以写脚本命令,一键轻松解决。在EMR集群中,master到所有worker节点在hadoop和hdfs账号下是ssh打通的。
例如,需要对所有worker节点的nodemanager做停止操作,假设有10个worker节点,则可以这样做:
- [backcolor=transparent] [backcolor=transparent]for[backcolor=transparent] i [backcolor=transparent]in[backcolor=transparent] [backcolor=transparent]`seq 1 10`[backcolor=transparent];[backcolor=transparent]do[backcolor=transparent] ssh emr[backcolor=transparent]-[backcolor=transparent]worker[backcolor=transparent]-[backcolor=transparent]$i [backcolor=transparent]/[backcolor=transparent]usr[backcolor=transparent]/[backcolor=transparent]lib[backcolor=transparent]/[backcolor=transparent]hadoop[backcolor=transparent]-[backcolor=transparent]current[backcolor=transparent]/[backcolor=transparent]sbin[backcolor=transparent]/[backcolor=transparent]yarn[backcolor=transparent]-[backcolor=transparent]daemon[backcolor=transparent].[backcolor=transparent]sh stop nodemanager[backcolor=transparent];[backcolor=transparent]done