$ curl "http://localhost:14000/webhdfs/v1?op=gethomedirectory&user.name=hdfs" {"Path":"\/user\/hdfs"}
更多的 API,请参考 WebHDFS REST API
3. 安装和配置YARN根据文章开头的节点规划,cdh1 为resourcemanager节点,cdh2 和 cdh3 为nodemanager节点,为了简单,historyserver 也装在 cdh1 节点上。
3.1 安装服务在 cdh1 节点安装:
$ yum install hadoop-yarn hadoop-yarn-resourcemanager -y #安装 historyserver $ yum install hadoop-mapreduce-historyserver hadoop-yarn-proxyserver -y
在 cdh2、cdh3 节点安装:
$ yum install hadoop-yarn hadoop-yarn-nodemanager hadoop-mapreduce -y
3.2 修改配置参数要想使用YARN,需要在 /etc/hadoop/conf/mapred-site.xml 中做如下配置:
<property> <name>mapreduce.framework.name</name> <value>yarn</value> </property>
修改/etc/hadoop/conf/yarn-site.xml,配置resourcemanager的节点名称以及一些服务的端口号:
<property> <name>yarn.resourcemanager.resource-tracker.address</name> <value>cdh1:8031</value> </property> <property> <name>yarn.resourcemanager.address</name> <value>cdh1:8032</value> </property> <property> <name>yarn.resourcemanager.scheduler.address</name> <value>cdh1:8030</value> </property> <property> <name>yarn.resourcemanager.admin.address</name> <value>cdh1:8033</value> </property> <property> <name>yarn.resourcemanager.webapp.address</name> <value>cdh1:8088</value> </property>
在 /etc/hadoop/conf/yarn-site.xml 中添加如下配置:
<property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <property> <name>yarn.nodemanager.aux-services.mapreduce_shuffle.class</name> <value>org.apache.hadoop.mapred.ShuffleHandler</value> </property> <property> <name>yarn.log-aggregation-enable</name> <value>true</value> </property> <property> <name>yarn.application.classpath</name> <value> $HADOOP_CONF_DIR, $HADOOP_COMMON_HOME/*, $HADOOP_COMMON_HOME/lib/*, $HADOOP_HDFS_HOME/*, $HADOOP_HDFS_HOME/lib/*, $HADOOP_MAPRED_HOME/*, $HADOOP_MAPRED_HOME/lib/*, $HADOOP_YARN_HOME/*, $HADOOP_YARN_HOME/lib/* </value> </property> <property> <name>yarn.log.aggregation.enable</name> <value>true</value> </property>
注意:
yarn.nodemanager.aux-services 的值在 cdh4 中应该为 mapreduce.shuffle,并配置参数yarn.nodemanager.aux-services.mapreduce.shuffle.class值为 org.apache.hadoop.mapred.ShuffleHandler ,在cdh5中为mapreduce_shuffle,这时候请配置yarn.nodemanager.aux-services.mapreduce_shuffle.class参数
这里配置了 yarn.application.classpath ,需要设置一些喜欢环境变量:
export HADOOP_HOME=/usr/lib/hadoop export HIVE_HOME=/usr/lib/hive export HBASE_HOME=/usr/lib/hbase export HADOOP_HDFS_HOME=/usr/lib/hadoop-hdfs export HADOOP_MAPRED_HOME=/usr/lib/hadoop-mapreduce export HADOOP_COMMON_HOME=${HADOOP_HOME} export HADOOP_HDFS_HOME=/usr/lib/hadoop-hdfs export HADOOP_LIBEXEC_DIR=${HADOOP_HOME}/libexec export HADOOP_CONF_DIR=${HADOOP_HOME}/etc/hadoop export HDFS_CONF_DIR=${HADOOP_HOME}/etc/hadoop export HADOOP_YARN_HOME=/usr/lib/hadoop-yarn export YARN_CONF_DIR=${HADOOP_HOME}/etc/hadoop
在hadoop中默认的文件路径以及权限要求如下: