10.249.200.157 h1
10.249.196.166 h2
10.249.196.3 h3
|
useradd hadoop
|
rm -rf ~/.ssh
mkdir ~/.ssh
chmod 700 ~/.ssh
/usr/bin/ssh-keygen -t rsa
/usr/bin/ssh-keygen -t dsa
touch ~/.ssh/authorized_keys
cd ~/.ssh
ssh hadoop@10.20.149.83 cat /home/hadoop/.ssh/id_rsa.pub >> authorized_keys
ssh hadoop@10.20.149.83 cat /home/hadoop/.ssh/id_dsa.pub >> authorized_keys
ssh hadoop@10.20.149.84 cat /home/hadoop/.ssh/id_rsa.pub >> authorized_keys
ssh hadoop@10.20.149.84 cat /home/hadoop/.ssh/id_dsa.pub >> authorized_keys
ssh hadoop@10.20.143.12 cat /home/hadoop/.ssh/id_rsa.pub >> authorized_keys
ssh hadoop@10.20.143.12 cat /home/hadoop/.ssh/id_dsa.pub >> authorized_keys
ssh本机也须要无密码
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
|
完成后可以使用ssh命令验证如:ssh h1,来确认 html
tar -xzvf hadoop-0.20.2.0.tar
|
如今hadoop路径为/home/hadoop/hadoop-0.20.2.0 java
cat /home/hadoop/hadoop-0.20.2.0/conf/masters
10.20.143.12
|
cat /root/hadoop/hadoop-0.20.2.0/conf/slaves
10.20.149.83
10.20.149.84
|
mkdir -p data/tmp
mkdir -p data/data
mkdir -p data/name
|
vi $HADOOP_HOME/conf/hadoop-env.sh
|
增长内容 node
export JAVA_HOME=/usr/alibaba/java
export HADOOP_HOME=/home/hadoop/hadoop-0.20.2.0
|
more conf/core-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/data/temp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://h1:9000</value>
<description>The name of the default file system. A URI whose
scheme and authority determine the FileSystem implementation. The
uri scheme determines the config property (fs.SCHEME.impl) naming
the FileSystem implementation class. The uri authority is used to
determine the host, port, etc. for a filesystem.</description>
</property>
</configuration>
|
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>h1:8021</value>
<description>The host and port that the MapReduce job tracker runs
at. If 'ocal' then jobs are run in-process as a single map
and reduce task.
</description>
</property>
</configuration>
|
more conf/hdfs-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.data.dir</name>
<value>/home/hadoop/data/data</value>
</property>
<property>
<name>dfs.name.dir</name>
<value>/home/hadoop/data/name</value>
</property>
</configuration>
|
export HADOOP_LOG_DIR=/home/hadoop/0.20.2/log/hadoop
|
scp conf/*.* h2:/home/hadoop/hadoop-0.20.2.0/conf/
scp conf/*.* h3:/home/hadoop/hadoop-0.20.2.0/conf/
|
bin/hadoop namenode -format
|
启动hadoop守护进程 linux
bin/start-all.sh
|
$ bin/hadoop fs -put conf input
|
运行发行版提供的示例程序: apache
$ bin/hadoop jar hadoop-examples-0.20.2.0.jar grep input output 'dfs[a-z.]+'
|
查看输出文件:
将输出文件从分布式文件系统拷贝到本地文件系统查看: windows
$ bin/hadoop fs -get output output
$ cat output/*
|
在分布式文件系统上查看输出文件: 安全
$ bin/hadoop fs -cat output/*
|
$bin/hadoop-daemon.sh start datanode
$bin/hadoop-daemon.sh start tasktracker
|
$bin/hadoop balancer
|
10.249.200.157 h1
10.249.196.166 h2
10.249.196.3 h3 服务器
参考下面几篇文章: eclipse
咱们使用的hadoop是0.20.2 ssh
下载地址:http://labs.renren.com/apache-mirror/hadoop/core/hadoop-0.20.2/hadoop-0.20.2.tar.gz
http://www.51testing.com/?uid-159438-action-viewspace-itemid-211599
http://hadoop.apache.org/common/docs/r0.20.2/cn/quickstart.html#Local
http://hi.baidu.com/yuweiming/blog/item/6bf4242db074c420359bf744.html
core-site.xml mapred-site.xml hdfs-site.xml 这三个文件的配置就参考这篇文章,h1换成本身的ip
datax若是没有的话,能够手工把hdfs文件拷贝过去。
bin/hadoop fs -mkdir -p /datax/noah/dev
bin/hadoop fs -chmod -R 777 /datax/noah
先从h1 上把datax经过的文件下载的本地磁盘,好比c:\hadoopTmp
而后在上传到本身开发环境的单机hadoop上。
<?xml version="1.0" ?> <configuration> <property> <name>fs.default.name</name> <value>file:///</value> </property> <property> <name>mapred.job.tracker</name> <value>local</value> </property> </configuration>