fs.default.name
test161.sqa:9000The name of the default file system. Either the literal
string “local” or a host:port for DFS.mapred.job.tracker
test161.sqa:9001The host and port that the MapReduce job tracker runs at.
If “local”, then jobs are run in-process as a single map and reduce task.hadoop.tmp.dir/home/hadoop/HadoopInstall/tmp
A base for other temporary directories.dfs.name.dir
/home/hadoop/HadoopInstall/filesystem/nameDetermines where on the local filesystem
the DFS name node should store the name table. If this is a comma-delimited list of directories then the name table
is replicated in all of the directories, for redundancy. dfs.data.dir
/home/hadoop/HadoopInstall/filesystem/dataDetermines where on the local filesystem
an DFS data node should store its blocks. If this is a comma-delimited list of directories, then data will be stored
in all named directories, typically on different devices. Directories that do not exist are ignored. dfs.replication1Default block replication.
The actual number of replications can be specified when the file is created. The default is used if replication is
not specified in create time. 1.8. 部署datanode节点
将namenode上安装配置完成的hadoop文件拷贝到所有datanode:
scp -r /home/hadoop/HadoopInstall test162.sqa:/home/hadoop/scp -r /home/hadoop/HadoopInstall
test163.sqa:/home/hadoop/scp -r /home/hadoop/HadoopInstall test164.sqa:/home/hadoop/ 1.9. 启动Hadoop
格式化namenode
/home/hadoop/HadoopInstall/hadoop/bin/hadoop namenode -format
在/home/hadoop/HadoopInstall/hadoop/bin/下面有很多启动脚本,可以根据自己的需要来启动:
* start-all.sh 启动所有的Hadoop守护。包括namenode, datanode, jobtracker, tasktrack
* stop-all.sh 停止所有的Hadoop。
* start-mapred.sh 启动Map/Reduce守护。包括Jobtracker和Tasktrack。
* stop-mapred.sh 停止Map/Reduce守护
* start-dfs.sh 启动Hadoop DFS守护.Namenode和Datanode
* stop-dfs.sh 停止DFS守护
在这里,简单启动所有守护
bin/start-all.sh
同样,如果要停止hadoop,则
bin/stop-all.sh 1.10. HDFS测试
运行bin/目录的hadoop命令,可以查看Haoop所有支持的操作及其用法,这里以几个简单的操作为例。
在HDFS建立目录:
bin/hadoop dfs -mkdir testdir
在HDFS中建立一个名为testdir的目录
复制文件到HDFS:
bin/hadoop dfs -put /home/hadoop/large.zip testfile.zip
把本地文件large.zip拷贝到HDFS的根目录/user/hadoop/下,文件名为testfile.zip
查看HDFS的现有文件
bin/hadoop dfs -ls 1.11. C++测试程序
分别用c++编写mapper和reducer程序,完成对文件中的单词数量的统计:
mapper.cpp:
// c++ map reduce Mapper
// word count example
// 2008.4.18
// by iveney
#include
#include
using namespace std;
int main()
{
string buf;
while( cin>>buf )
cout< return 0;
}
reducer.cpp:
#include
#include
#include
using namespace std;int main()
{
map dict;
map::iterator iter;
string word;
int count;
while( cin>>word>>count )
dict[word]+=count;
iter = dict.begin();
while( iter != dict.end() )
{
cout