The premise of this article is: Know what Hadoop is, what is a distributed system, and understand the concepts and principles of hdfs and mapreduce. Here, I will share some of my experiences in learning hadoop with my own views. This article includes two parts: 1. hadoop Installation Process in RedHatlinux
The premise of this article is: Know what Hadoop is, what is a distributed system, and understand the concepts and principles of hdfs and mapreduce. Here, I will share some of my experiences in learning hadoop with my own views. This article includes two parts:
1. hadoop installation in RedHat linux
When Cygwin installs hadoop, the author thinks that the original hadoop design is installed and used in linux. Cygwin installation is nothing more than simulating the linux environment and then installing hadoop in this simulated environment. Now that you want to learn hadoop, you can install it in linux, however, it is not easy for individuals to build a real linux system. However, we can use the Virtual Machine VMware Player to download a virtual machine in windows (VMware Player is a good virtual machine ), then, install a linux system on the Virtual Machine to implement communication with the local windows, how to install the virtual machine, how to install linux on the virtual machine, and how to implement communication with the local windows, I will not talk about it here. There is a lot of information on the Internet.
2. In windows on the local machine, use eclispe to connect to haoop installed on the linux Virtual Machine and perform development and debugging. After hadoop is installed on linux, you can run the hadoop shell command on linux to view the hadoop hdfs file system and run the mapreduce program. However, this is inconvenient, we usually develop programs in windows. After successful debugging, we release them to linux for execution. This part is to share how to configure eclipse in windows, it can be linked to hadoop in linux.
Next, let's talk about the first part:
Hadoop has three installation modes: Standalone mode, pseudo-distributed, and fully distributed.
1. standalone mode: It doesn't make sense. pass it out. Don't discuss it.
2. Pseudo-distributed: Simulate namenode, datanode, jobtracker, tasktracker, and secondaryname on a single machine. Each existing form is a java Process.
3. Completely distributed: A hadoop cluster consisting of n machines. Generally, one machine serves as the master and runs namenode and jobtracker. The other machines act as slave, run datanode and tasktracker. For secondaryname, it can run on the master or another machine. Secondaryname is a namenode backup that also saves the namespace and maps the file to the file block. It is recommended to run on another machine. After the master is dead, you can use the machine where secondaryname is located to retrieve the namespace, map the relationship data with the file block, and restore namenode.
If the conditions are limited, only pseudo-distribution can be implemented, that is, a linux instance is installed on a virtual machine. In fact, you can also install n linux instances on a virtual machine to achieve full distribution, but I am afraid that I can't afford it. You can only install pseudo-distributed.
First, make sure that the virtual machine has been installed in windows and linux has been installed on the virtual machine, and can communicate with windows (ping the linux ip address in windows cmd and ping it. ask: How do you know the linux ip address ?, Answer: Enter the linux terminal, ifconfig will see) I have installed a virtual machine on the windows and installed a linux system on the Virtual Machine. When installing linux, there will be a root user, next, we will use this root user for all operations. There are a lot of online materials about creating a user, such as hadoop, to install hadoop. For convenience, we will use root (in fact, it is a lazy, I don't want to make it complicated. Wow, (* ^__ ^ *) Hey ......).
Hadoop Installation Steps
1. Implement ssh password-less authentication configuration in linux.
2. Install jdk in linux with Environment Variables
3. Modify the linux machine name and configure/etc/hosts
4. Download hadoop 0.20.0 in windows and modify the hadoop-env.sh, core-site.xml, hdfs-site.xml,
Mapred-site.xml, masters, slaves file configuration
5. Upload the entire modified hadoop folder to linux
6. Add the hadoop bin to the environment variable.
7. Format hadoop and start hadoop
8. Verify that the instance is started and run wordcount.
This order is not a write-dead order. You have to follow this order. If you know the principle, You can disrupt the order for operations, such as 1, 2, 3, first, then, no problem, but some steps can only be performed after some operations are completed. We recommend that you follow the sequence for new users. Let's take a look at exchange experiences. (* ^__ ^ *) Xi ......
1. Implement ssh password-less authentication configuration in linux
Ask: Why do I need to configure ssh without password verification?
Answer:Hadoop needs to use the SSH protocol. namenode will use the SSH protocol to start the namenode and datanode processes. (The heartbeat information transmitted from datanode to namenode may also use the SSH protocol, which I think is true, I have no in-depth understanding ). In many tutorials, the configuration of a Hadoop cluster only shows that SSH has no password to log on to all datanode on namenode. During configuration, I found that the datanode must be able to log on to namenode through SSH without a password, the Hadoop cluster can be started normally (maybe this is not necessary, but it is a mistake, but it can be started normally ).The above blue font, if I stick to a senior, probably means that commands between namenode and datanode are issued by ssh, and commands must be issued during running, when sending the message, you certainly don't want to send it once. A dialog box is displayed, saying: Is there a machine connecting me and letting him connect. Therefore, the backend namenode and datanode are required to communicate smoothly. How can this problem be achieved ?, It is to configure ssh password-free authentication. The predecessors mentioned above have a concern that namenode can be easily linked to datanode. Is it still used to implement accessible connections between datanode and namenode ?, I will not take this into consideration. Here I am a pseudo-distribution. One machine, namenode and datanode are both on one machine, and you can achieve your own connection. Don't worry about your own problems ~~, If you encounter this problem when you are fully distributed, you can try it on your own. If not, you can achieve smooth communication between datanode and namenode ~~~.
Ask: no password verification is required to enable the connection. How does it work?
Answer:Take namenode to datanode as an example:As a client, Namenode must implement password-free public key authentication. When connecting to the datanode server, a key pair must be generated on namenode, including a public key and a private key, and then the public key is copied to datanode. When namenode connects to datanode through ssh, datanode generates a random number and encrypts the random number with the namenode public key and sends it to namenode. After receiving the encrypted data, namenode decrypts the data with the private key and returns the data to datanode. After confirming that the number of decrypted data is correct, the namenode can be connected. This is a public key authentication process, during which you do not need to manually enter the password. The important process is to copy the client's namenode public key to datanode.This is what some of my predecessors have said. The predecessors have made it clear that this is the case.
I know why. Now let's get started with how.
I have a machine here, so the operation is very simple.
In the linux Command Line, enter:Ssh-keygen-t rsa and press Enter.
Root @ hadoopName-desktop :~ $ Ssh-keygen-t rsa
GeneratingPublic/PrivateRsa key pair.
Enter fileInWhich to save the key (/home/zhangtao/. ssh/id_rsa ):// Key storage location. Press enter to keep the default value;
Created directory'/Home/zhangtao/. ssh'.
Enter passphrase (emptyForNo passphrase ):// Set the password of the key. If the password is empty, press Enter;
Enter same passphrase again:// Confirm the password set in the previous step.
Then, enter/root/. ssh/and you will see two files.Id_rsa.pub,Id_rsa,
Then run cpId_rsa.pubAuthorized_keys
Then ssh localhost is used to verify whether the request is successful. If you enter yes for the first time, you will not need it in the future.