Hadoop installation and configuration, Hadoop installation Configuration
Content of this Chapter
Install and configure Hadoop on Linux
Install and configure Hadoop on Windows
Install and configure a Hadoop Cluster
Log Analysis and several tips
Summary
Hadoop installation is very simple. You can download the latest versions from the official website at http://apache.etoak.com/hadoop/core /.
Hadoop was first developed for use on the Linux platform, but Hadoop runs well on UNIX, Windows, and Mac OS X systems. However, running Hadoop on Windows is a little complicated. You must first install Cygwin to simulate the Linux environment before installing Hadoop.
The process of installing Hadoop on Unix is basically the same as that of installing Hadoop on Linux, so we will not detail it below.
2.1 install and configure Hadoop on Linux
Before installing Hadoop on Linux, you need to install two programs:
JDK 1.6 or later;
We recommend that you install OpenSSH for SSH (Secure Shell protocol.
The following describes the reasons for installing these two programs:
Hadoop is developed in Java. JDK is required for compiling Hadoop and running MapReduce.
Hadoop needs to use SSH to start the daemon processes of each host in the salve list. Therefore, SSH must be installed, even if the pseudo-distributed version is installed (because Hadoop does not distinguish cluster-based and pseudo-distributed ). For pseudo-distributed systems, Hadoop uses the same processing method as the cluster, that is, starting the processes on the host recorded in the conf/slaves file in order, in the pseudo-distributed system, salve is localhost (itself), so SSH is also required for pseudo-distributed Hadoop.
2.1.1 install JDK 1.6
The process of installing JDK is very simple. The following uses Ubuntu as an example.
(1) download and install JDK
Make sure you can connect to the Internet and enter the following command:
sudo apt-get install sun-java7-jdk
Enter the password and confirm. Then you can install JDK.
Here we will explain the two commands sudo and apt. The sudo command allows common users to execute some or all of the commands that require the root permission. It provides detailed logs, you can record the operations performed by each user using this command. At the same time, sudo also provides flexible management methods to restrict the use of commands. The sudo configuration file is/etc/sudoers.
Apt is called the Advanced Packaging Tool. It is part of the Debian program and is the software package management software of Ubuntu. You do not need to consider the dependency between software when installing software through apt, you can directly install the required software. apt automatically downloads dependent packages and installs them in sequence, install apt in Ubuntu, a graphical interface program synaptic (translated in Chinese as "new"). If you are interested, you can use this program to install the required software. (If you want to learn more, you can refer to the Debian plan .)
(2) Configure Environment Variables
Enter the following command:
sudo gedit /etc/profile
Enter the password to open the profile file.
Enter the following content at the bottom of the file:
# Set Java Environment export JAVA_HOME = (your JDK installation location, usually/usr/lib/jvm/java-6-sun) export CLASSPATH = ".: $ JAVA_HOME/lib: $ CLASSPATH "export PATH =" $ JAVA_HOME/: $ PATH"
The significance of this step is to configure environment variables so that your system can find JDK.
(3) Verify that JDK is successfully installed
Enter the following command:
java -version
View information:
java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode)
2.1.2 configure SSH password-free Login
Take Ubuntu as an example. Assume that the user name is u.
1) confirm the connection to the Internet and enter the command
sudo apt-get install ssh
2) you can log on to the local machine without a password.
First, check whether the. ssh folder exists under the u user (Note that there is "." In front of ssh, which is a hidden folder). Enter the following command:
ls -a /home/u
Generally, this hidden folder is automatically created under the current user during SSH installation. If there is no hidden folder, you can manually create one.
Next, enter the command:
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
Ssh-keygen indicates the generated key.-t (case sensitive) indicates the type of the generated key. dsa indicates the dsa key authentication, that is, the key type; -P is used to provide the secret language;-f specifies the generated key file. (I will not describe the knowledge about key cryptography in detail here. It will involve some knowledge about SSH. If you are interested, you can check the information on your own .)
In Ubuntu ,~ Represents the current user folder, Which is/home/u.
This command will. create two files id_dsa and id_dsa.pub In the ssh folder. This is a pair of private keys and public keys for SSH. Similar to keys and locks, append id_dsa.pub (Public key) to the authorized key.
Enter the following command:
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
This section adds the public key to the public key file used for authentication. The authorized_keys here is the public key file used for authentication.
At this point, no password is set to log on to the local machine.
3) Verify that SSH is successfully installed and that you can log on to the local machine without a password.
Enter the following command:
ssh -version
Display result:
OpenSSH_5.1p1 Debian-6ubuntu2, OpenSSL 0.9.8g 19 Oct 2007
Bad escape character 'rsion '.
It indicates that SSH has been installed successfully.
Enter the following command:
ssh localhost
The following information is displayed:
The authenticity of host 'localhost (: 1) 'can't be established.
RSA key fingerprint is 8b: c3: 51: a5: 2a: 31: b7: 74: 06: 9d: 62: 04: 4f: 84: f8: 77.
Are you sure you want to continue connecting (yes/no )? Yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
Linux master 2.6.31-14-generic # 48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686
To access official Ubuntu documentation, please visit:
Http://help.ubuntu.com/
Last login: Mon Oct 18 17:12:40 2010 from master
Admin @ Hadoop :~ $
This indicates that the installation is successful. When you log on for the first time, you will be asked if you want to continue the link. Enter yes to enter.
In fact, it does not matter whether to log on without a password during Hadoop installation. However, if you do not configure a password-free logon, you need to enter the password to log on to the DataNode of each machine. Considering that Hadoop clusters usually have hundreds or thousands of machines, SSH password-less logon is usually configured.
2.1.3 install and run Hadoop
Before introducing Hadoop installation, let's first introduce Hadoop's role definitions for each node.
Hadoop divides hosts into two roles from three perspectives. First, it is divided into master and slave, that is, master and slave. Second, from the HDFS perspective, the host is divided into NameNode and DataNode (in Distributed File Systems, directory management is very important, directory management is equivalent to the master, while NameNode is the Directory Manager). Third, from the MapReduce perspective, the host is divided into JobTracker and TaskTracker (a job is often divided into multiple tasks, from this perspective, it is not difficult to understand the relationship between them ).
Hadoop has an official release and cloudera. Among them, cloudera is a commercial version of Hadoop. Here we will first introduce the installation method of the official release of Hadoop.
Hadoop has three running modes: Single Node mode, single-host pseudo distribution mode, and cluster mode. At first glance, the first two methods do not reflect the advantages of cloud computing. They do not make much sense in actual applications. However, they make sense in the testing and debugging of programs.
You can obtain the official release of Hadoop at the following address:
Http://www.apache.org/dyn/closer.cgi/Hadoop/core/
Download hadoop-0.20.2.tar.gz and decompress it. Here, it will be decompressed to the user directory, generally:/home/[your username]/.
Single Node Configuration:
You do not need to configure a single-node Hadoop installation. In this way, Hadoop is considered a separate Java Process, which is often used for debugging.
Pseudo-distributed configuration:
You can regard pseudo-distributed Hadoop as a cluster with only one node. in this cluster, this node is both a master node and a slave node, NameNode and DataNode, and JobTracker and TaskTracker.
The pseudo-distributed configuration process is also very simple. You only need to modify several files, as shown below.
Go to the conf folder and modify the configuration file:
Hadoop-env.sh: export JAVA_HOME = "Your JDK installation address"
Specify the JDK installation location:
conf/core-site.xml: <configuration> <property> <name>fs.default.name</name> <value>hdfs://localhost:9000</value> </property> </configuration>
This is the core configuration file of Hadoop. The address and port number of HDFS are configured here.
conf/hdfs-site.xml: <configuration> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration>
This is the HDFS configuration in Hadoop. The default backup mode is 3. In the standalone version of Hadoop, you need to change it to 1.
conf/mapred-site.xml: <configuration> <property> <name>mapred.job.tracker</name> <value>localhost:9001</value> </property> </configuration>
This is the configuration file of MapReduce in Hadoop, Which is configured with the address and port of JobTracker.
Note that if the version is installed earlier than version 0.20, there is only one configuration file, that is, the Hadoop-site.xml.
Next, you need to format the HDFS File System of Hadoop before starting Hadoop (this is the same as that of Windows, and the volume after partitioning always needs to be formatted ). Enter the Hadoop folder and enter the following command:
bin/Hadoop NameNode -format
Format the file system and start Hadoop.
Enter the following command:
Bin/start-all.sh (all started)
Finally, verify that Hadoop is successfully installed.
Open your browser and enter the URL:
Http: // localhost: 50030 (MapReduce Web page)
Http: // localhost: 50070 (HDFS Web page)
If it can be viewed, it indicates that Hadoop has been installed successfully.
For Hadoop, installing MapReduce and HDFS is required, but if necessary, you can still just start HDFS (start-dfs.sh) or MapReduce (start-mapred.sh ).
For fully distributed Hadoop, see Section 2.3.
Install and configure Hadoop
Using hadoop to analyze a file (or file set) with a size of more than one hundred KB is simply a cannon. Unless you are doing exercises. If you are doing exercises, there are too many documents in this area, and you can use them by searching for them.
Hadoop FUSE installation Configuration
Installing hadoop does not require ant to be installed on all hosts.