hadoop 2.6的“伪”分式安装与“全”分式安装相比,99%的操作是相同的,唯一的区别是不用配置slaves文件,下面是几个关键的配置:
(安装JDK、创建用户、设置SSH免密码、设置环境变量这些准备工作,大家可参考hadoop 2.6全分布安装 一文,以下所有配置文件,均在$HADOOP_HOME/etc/hadoop目录下)
一、修改hadoop-env.sh、yarn-env.sh
主要是设置JAVA_HOME的路径
二、修改core-site.xml
1 <configuration> 2 <property> 3 <name>fs.default.name</name> 4 <value>hdfs://localhost:9000</value> 5 </property> 6 <property> 7 <name>hadoop.tmp.dir</name> 8 <value>/opt/app/hadoop-2.6.0/tmp</value> 9 </property> 10 </configuration>
三、修改hdfs-site.xml
1 <configuration> 2 <property> 3 <name>dfs.name.dir</name> 4 <value>/opt/app/hadoop-2.6.0/hdfs/name</value> 5 <description>namenode storage path</description> 6 </property> 7 <property> 8 <name>dfs.data.dir</name> 9 <value>/opt/app/hadoop-2.6.0/hdfs/data</value> 10 <description>datanode storage path</description> 11 </property> 12 <property> 13 <name>dfs.replication</name> 14 <value>1</value> 15 </property> 16 </configuration>
四、修改mapred-site.xml
1 <configuration> 2 <property> 3 <name>mapred.job.tracker</name> 4 <value>hdfs://localhost:9001</value> 5 </property> 6 <property> 7 <name>mapred.local.dir</name> 8 <value>/opt/app/hadoop-2.6.0/mapred/local</value> 9 <description>mapreduce storage path</description> 10 </property> 11 <property> 12 <name>mapred.system.dir</name> 13 <value>/opt/app/hadoop-2.6.0/mapred/system</value> 14 <description>mapreduce system level storage path</description> 15 </property> 16 </configuration>
五、修改yarn-site.xml
1 <configuration> 2 <property> 3 <name>yarn.nodemanager.aux-services</name> 4 <value>mapreduce_shuffle</value> 5 </property> 6 </configuration>
注:以上这些配置里的目录,要确实存在,如果没有,请先手动创建,参考命令 mkdir -p mapred/system
可以开始测试了:
1.先格式化
bin/hdfs namenode –format
2、启动dfs、yarn
sbin/start-dfs.sh
sbin/start-yarn.sh
然后用jps查看java进程,应该能看到以下几个进程:
25361 NodeManager
24931 DataNode
25258 ResourceManager
24797 NameNode
25098 SecondaryNameNode
还可以用以下命令查看hdfs的报告:
bin/hdfs dfsadmin -report 正常情况下可以看到以下内容
Configured Capacity: 48228589568 (44.92 GB)
Present Capacity: 36589916160 (34.08 GB)
DFS Remaining: 36589867008 (34.08 GB)
DFS Used: 49152 (48 KB)
DFS Used%: 0.00%
Under replicated blocks: 0
Blocks with corrupt replicas: 0
Missing blocks: 0
-------------------------------------------------
Live datanodes (1):
Name: 127.0.0.1:50010 (localhost)
Hostname: dc191
Decommission Status : Normal
Configured Capacity: 48228589568 (44.92 GB)
DFS Used: 49152 (48 KB)
Non DFS Used: 11638673408 (10.84 GB)
DFS Remaining: 36589867008 (34.08 GB)
DFS Used%: 0.00%
DFS Remaining%: 75.87%
Configured Cache Capacity: 0 (0 B)
Cache Used: 0 (0 B)
Cache Remaining: 0 (0 B)
Cache Used%: 100.00%
Cache Remaining%: 0.00%
Xceivers: 1
Last contact: Tue May 05 17:42:54 CST 2015
3、web管理界面查看
http://localhost:50070/
http://localhost:8088/
4、在hdfs中创建目录
bin/hdfs dfs -mkdir /x
这样就在hdfs中创建了一个目录x
5、向hdfs中放入文件
bin/hdfs dfs -put README.txt /x
上面的命令会把当前目录下的README.TXT放入hdfs的/x目录中,在web管理界面里也可以看到该文件