Note that all the commands you should use the “hadoop” user to execute. And all the directories involved below should be owned by the “hadoop” user as well.
Make the nodes can find each other by domain name.
Add the following content info the “/etc/hosts” file on each server(master node and slave nodes):
In this case JDK version “jdk1.8.0_45” is used. And the installation directory is “/export/jdk1.8.0_45”. Using the same directory on each node(master and slaves) makes it easier to set “JAVA_HOME” in the “~/.bashrc” file of each node(master and slaves).
Configure “/home/hadoop/.bashrc” file(master node and slave nodes).
Download the “Hadoop” package file and put it to the master node.
In this case “hadoop-2.6.1” is used.
1 2 3 4 5 6 7 8
# 1. Download "Hadoop" package file. wget -t 99 -c http://apache.01link.hk/hadoop/common/hadoop-2.6.1/hadoop-2.6.1.tar.gz # 2. Send the file to each node. scp hadoop-2.6.1.tar.gz root@192.168.149.86:/export/App # 3. Login the "HadoopMaster(192.168.149.86)" server and extract the file # and the "/export/App/hadoop-2.6.1" directory will be created. cd /export/App tar -xvf hadoop-2.6.1.tar.gz
Update the “hadoop” configuration files on the “master” node
All the following files are on the “HadoopMaster(192.168.149.86)”
<!-- Paste these lines into <configuration> tag OR Just update it by replacing localhost with master --> <property> <name>fs.default.name</name> <value>hdfs://HadoopMaster</value> </property>
## Add name of slave nodes HadoopSlave1 HadoopSlave2 HadoopSlave3 HadoopSlave4
Distribute the “hadoop” files from master node to the slave nodes
We do this to reduce the configuration step in the last section.
1 2 3 4 5 6 7 8 9 10 11
# 1. Login the "master" node. Pacakge the "hadoop" directory on it. cd /export/App tar -czvf hadoop-2.6.1-config.tar.gz hadoop-2.6.1/ # 2. Distribute the package file to the slave nodes. scp hadoop-2.6.1-config.tar.gz root@192.168.149.87:/export/App scp hadoop-2.6.1-config.tar.gz root@192.168.149.88:/export/App scp hadoop-2.6.1-config.tar.gz root@192.168.149.89:/export/App scp hadoop-2.6.1-config.tar.gz root@192.168.149.90:/export/App # 3. Login each slave node and run the following commands to extract. cd /export/App tar -xvf hadoop-2.6.1-config.tar.gz
Create directories for “namenode/datanode” on the “master/slave” nodes
1 2 3 4 5 6 7 8 9 10
# 1. Run the following command on the "master" node to create the "namenode" directory. mkdir -p /export/Data/hadoop-2.6.1/hdfs/namenode/ # If the "hadoop" user does not have permission to create this directory, use "root" to do it and run the following command to set the owner of this directory as "hadoop". chown hadoop:hadoop -R /export/Data/hadoop-2.6.1/ # 2. Run the following command on the "slave" nodes to create the "datanode" directory. mkdir -p /export/Data/hadoop-2.6.1/hdfs/datanode/ # If the "hadoop" user does not have permission to create this directory, use "root" to do it and run the following command to set the owner of this directory as "hadoop". chown hadoop:hadoop -R /export/Data/hadoop-2.6.1/
Format “namenode” on the “master” node
1 2
# run the following command: hdfs namenode -format
Start Hadoop Daemon on the “master” node
1 2 3 4 5
# 1. Start the "dfs" daemon: start-dfs.sh
# 2. Start the "yarn" daemon: start-yarn.sh
If everything works, you can access here and here in your browser. The you can find the information about the HDFS cluster and Yarn cluster.