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>