Hadoop standalone installation and configuration process:
1. Install JDK first. It must be sun's jdk, preferably version 1.6 or later.
Check whether java-version is successful.
Pay attention to the configuration of the/etc/profile file, and add the following sentence after it:
ExportJAVA_HOME =/usr/local/jdk1.6.0 _ 17
ExportPATH = $ JAVA_HOME/bin: $ JAVA_HOME/jre: $ PATH
ExportCLASSPATH = $ JAVA_HOME/lib: $ JAVA_HOME/lib/tools. jar
2. Install SSH and log on without a password.
Apt-getinstall openssh-server install ssh
Create SSHKEY:
$ Ssh-keygen-t rsa-P "" (do not add spaces or missing spaces)
In the middle, the installer needs to select the file to save the key. Press enter to use the default file:
Enterfile in which to save the key (/root/. ssh/id_rsa) :( press Enter)
Enable SSHKEY:
$ Cat/root/. ssh/id_rsa.pub>/root/. ssh/authorized_keys
/Etc/init. d/sshreload
Reloadssh
Sshlocalhost
3. install and configure a single-host hadoop
1) decompress the package to/opt/hadoop.
Java code
$ Tar zxvf hadoop-0.20.2.tar.gz
$ Sudo mv hadoop-0.20.2/opt/
$ Sudo chown-R hadoop: hadoop/opt/hadoop-0.20.2
$ Sudo ln-sf/opt/hadoop-0.20.2/opt/hadoop
4. Configure hadoop-env.sh
1) added hadoop-env.sh in hadoop/conf
Java code
ExportJAVA_HOME =/usr/jdk1.6.0.18
ExportHADOOP_HOME =/opt/hadoop
ExportPATH = $ PATH:/opt/hadoop/bin
5. Configuration File
1) zookeeper/opt/hadoop/conf/core-site.xml
Java code
<Configuration>
<Property>
<Name> fs. default. name </name>
<Value> hdfs :/// localhost: 9000 </value>
</Property>
<Property>
<Name> hadoop. tmp. dir </name>
<Value>/tmp/hadoop-$ {user. name} </value>
</Property>
</Configuration>
2) zookeeper/opt/hadoop/conf/hdfs-site.xml
Java code
<Configuration>
<Property>
<Name> dfs. replication </name>
<Value> 1 </value>
</Property>
</Configuration>
3) zookeeper/opt/hadoop/conf/mapred-site.xml
Java code
<Configuration>
<Property>
<Name> mapred. job. tracker </name>
<Value> localhost: 9001 </value>
</Property>
</Configuration>
6. Format hdfs
Java code
$ Cd/opt/hadoop
$ Source conf/hadoop-env.sh
$ Hadoop namenode-format
A large amount of information is prompted...
7. Start hadoop
Java code
$ Sudo./start-all.sh // run under hadoop/bin
8. Test after completion
Java code
Http: // localhost: 50030/-Hadoop Management Interface
Start
[Hadoop @ hadoop00 ~] $ ~ /Hadoop-0.21.0/bin/start-all.sh
Thisscript is Deprecated. Instead use start-dfs.sh andstart-mapred.sh
Starting namenode, logging to/home/hadoop/hadoop-0.21.0/bin/../logs/hadoop-hadoop-namenode-hadoop00.out
192.168.91.11: starting datanode, logging to/home/hadoop/hadoop-0.21.0/bin/../logs/hadoop-hadoop-datanode-hadoop01.out
192.168.91.12: starting datanode, logging to/home/hadoop/hadoop-0.21.0/bin/../logs/hadoop-hadoop-datanode-hadoop02.out
192.168.91.10: starting secondarynamenode, logging to/home/hadoop/hadoop-0.21.0/bin/../logs/hadoop-hadoop-secondarynamenode-hadoop00.out
Startingjobtracker, logging to/home/hadoop/hadoop-0.21.0/bin/../logs/hadoop-hadoop-jobtracker-hadoop00.out
192.168.91.12: starting tasktracker, logging to/home/hadoop/hadoop-0.21.0/bin/../logs/hadoop-hadoop-tasktracker-hadoop02.out
192.168.91.11: starting tasktracker, logging to/home/hadoop/hadoop-0.21.0/bin/../logs/hadoop-hadoop-tasktracker-hadoop01.out
2. Stop
[Hadoop @ hadoop00 ~] $ ~ /Hadoop-0.21.0/bin/stop-all.sh
Thisscript is Deprecated. Instead use stop-dfs.sh andstop-mapred.sh
Stopping namenode
192.168.91.12: stoppingdatanode
192.168.91.11: stopping datanode
192.168.91.10: stopping secondarynamenode
Stopping jobtracker
192.168.91.11: stopping tasktracker
192.168.91.12: stopping tasktracker
Initial HDFS Configuration
1. format the HDFS File System
[Hadoop @ hadoop00 ~] $ Hadoop namenode-format
2. View HDFS
[Hadoop @ hadoop00 ~] $ Hadoop fs-ls/
11/09/24 07:49:55 INFO security. Groups: Groupmapping impl = org. apache. hadoop. security. ShellBasedUnixGroupsMapping; cacheTimeout = 300000
11/09/24 07:49:56 WARN conf. Configuration: mapred. task. id is deprecated. Instead, usemapreduce. task. attempt. id
Found 4 items
Drwxr-xr-x-hadoop supergroup 0 2011-09-22 08:05/home
Drwxr-xr-x-hadoopsupergroup 02011-09-22 11: 29/jobtracker
Drwxr-xr-x-hadoopsupergroup 02011-09-22 11: 23/user
3. View hadoop on the WEB
Run example-wordcount of hadoop.
Wordcount is a simple calculation of the number of times each word appears in the input file, and output to the specified directory. The program is an official example in the hadoop-0.21.0 installation directory of: hadoop-mapred-examples-0.21.0.jar
Create the input directory and file of the Program on hdfs, and create the output directory of the program at the same time.
[Hadoop @ hadoop00 ~] $ Mkdir input
[Hadoop @ hadoop00 ~] $ Cat a B c cc c 1 1 1> input/file
[Hadoop @ hadoop00 ~] $ Hadoop fs-mkdir/wordcount
[Hadoop @ hadoop00 ~] $ Hadoop fs-put input/wordcount
[Hadoop @ hadoop00 ~] $ Hadoop jar hadoop-0.21.0/hadoop-mapred-examples-0.21.0.jarwordcount/wordcount/input/wordcount/output
11/09/24 08: 11: 25 INFO security. Groups: Group mappingimpl = org. apache. hadoop. security. ShellBasedUnixGroupsMapping; cacheTimeout = 300000
11/09/24 08:11:26 WARN conf. Configuration: mapred. task. id is deprecated. Instead, usemapreduce. task. attempt. id
11/09/24 08:11:26 WARNmapreduce. JobSubmitter: Use GenericOptionsParser for parsing thearguments. Applications shocould implement Tool for the same.
11/09/2408: 11: 26 INFO input. FileInputFormat: Total input paths to process: 2
11/09/24 08:11:26 WARN conf. Configuration: mapred. map. tasks isdeprecated. Instead, use mapreduce. job. maps
11/09/24 08:11:26 INFOmapreduce. JobSubmitter: number of splits: 2
11/09/24 08:11:27 INFOmapreduce. JobSubmitter: adding the following namenodes 'delegationtokens: null
11/09/24 08:11:27 INFO mapreduce. Job: Running job: job_201511240745_0002
11/09/24 08:11:28 INFO mapreduce. Job: map 0% reduce 0%
11/09/24 08:11:44 INFO mapreduce. Job: map50 % reduce 0%
11/09/24 08:11:50 INFO mapreduce. Job: map 100% reduce 0%
11/09/24 08:11:57 INFO mapreduce. Job: map 100% reduce 100%
11/09/24 08:11:59 INFO mapreduce. Job: Job complete: job_201511240745_0002
11/09/24 08:11:59 INFO mapreduce. Job: Counters: 34
......
[Hadoop @ hadoop00 ~] $ Hadoop fs-cat/wordcount/output/part-r-00000
11/09/2408: 18: 09 INFO security. Groups: Group mappingimpl = org. apache. hadoop. security. ShellBasedUnixGroupsMapping; cacheTimeout = 300000
11/09/24 08:18:09 WARN conf. Configuration: mapred. task. id is deprecated. Instead, usemapreduce. task. attempt. id
1 3
A 5
B 3
C 9