Install HDFS 2.7.1 on CentOS 6.6
This article tries to build 10 HDFS clusters on CentOS, instead of YARN and Hive, because Spark will be used later. Install jdk 1.8 first, which is not described here.
The server has 12 disks, so this is a real scenario where the cluster is built, but the size is small.
Download
First download the hadoop binary Package
[Plain] view plaincopyprint?
- Wgethttp: // apache.mesi.com. ar/hadoop/common/hadoop-2.7.1/hadoop-2.7.1.tar.gz
Decompress the package and put it in the/data/slot0/directory, and create a soft link/data/slot0/hadoop
Create an account
Create an account for managing a hadoop Cluster
[Plain] view plaincopyprint?
- Useraddlisa
The/home/lisa directory appears. The lisa account does not need a password because you cannot log on directly.
You can create lisa accounts for all 10 servers in batches, mainly through ssh-t.
Modify directory owner
[Plain] view plaincopyprint?
- Chown-Rlisa: lisahadoop-2.7.1/
- Chown-Rlisa: lisahadoop
- Ll
- Total8
- Drwxr-xr-x3rootroot4096Sep2518: 02 download
- Lrwxrwxrwx1lisalisa13Sep2517: 42hadoop-> hadoop-2.7.1/
- Drwxr-xr-x9lisalisa139Jun2914: 15hadoop-2.7.1.
- Lrwxrwxrwx1rootroot24Sep2516: 50java->/data/slot0/jdk1.8.0 _ 45/
- Drwxr-xr-x8rootroot4096Sep2514: 01jdk1. 8.0 _ 45
Enable SSH authentication between accounts
Switch to the account used by the hadoop system and generate an ssh key
[Plain] view plaincopyprint?
- Su-lisa
- Ssh-keygen-trsa-p''
- Generatingpublic/privatersakeypair.
- Enterfileinwhichtosavethekey (/home/lisa/. ssh/id_rsa ):
- Createddirectory '/home/lisa/. ssh '.
- Youridentificationhasbeensavedin/home/lisa/. ssh/id_rsa.
- Yourpublickeyhasbeensavedin/home/lisa/. ssh/id_rsa.pub.
- Thekeyfingerprintis:
- 15: 44: c6: 4e: bb: cd: b9: 09: e7: 50: c7: AE: dd: 92: 56: 57lisa @ 10-149-11-152
- Thekey'srandomartimageis:
- + -- [RSA2048] ---- +
- | + = |
- |. O. |
- | O... |
- |. O. oE |
- | S = +. |
- | + =. O |
- | = +. |
- | =. |
- |... |
- + ----------------- +
Configure/etc/hosts
The/etc/hosts of the 10 servers must be the same, so that they can communicate with each other through hostname.
[Plain] view plaincopyprint?
- 127.0.0.1localhostlocalhost.localdomainlocalhost4localhost4.localdomain4
- : 1localhostlocalhost. localdomainlocalhost6localhost6. localdomain6
- 10.149.11.15210-149-11-152
- 10.149.11.15310-149-11-153
- 10.149.11.15410-149-11-154
- 10.149.11.15510-149-11-155
- 10.149.11.15610-149-11-156
- 10.149.11.15710-149-11-157
- 10.149.11.15810-149-11-158
- 10.149.11.15910-149-11-159
- 10.149.11.16010-149-11-160
- 10.149.11.16110-149-11-161
Configure core-site.xml
Switch to the lisa account and edit the core-site.xml File
[Plain] view plaincopyprint?
- <Configuration>
- <Property>
- <Name> fs. default. name </name>
- <Value> hdfs: // 10-149-11-152: 9000 </value>
- </Property>
- <Property>
- <Name> io. file. buffer. size </name>
- <Value> 131072 </value>
- </Property>
- <Property>
- <Name> ha. zookeeper. quorum </name>
- <Value> 10.149.11.146: 2181, 10.149.11.147: 2181, 10.149.11.148: 2181 </value>
- </Property>
- </Configuration>
Three zookeeper IP addresses and port numbers are configured here.
Configure hdfs-site.xml
First, create a series of directories to store namenode, journalnode, and datanode data. These directories do not need to be created on every server. I have created them to save time, but I just don't need them.
[Plain] view plaincopyprint?
- Mkdir-p/data/slot0/lisa/hdfs/namenode
- Chown-Rlisa: lisa/data/slot0/lisa
- Mkdir-p/data/slot0/lisa/hdfs/journalnode
- Mkdir-p/data/slot0/lisa/hdfs/datanode
- Mkdir-p/data/slot1/lisa/hdfs/datanode
- Mkdir-p/data/slot2/lisa/hdfs/datanode
- Mkdir-p/data/slot3/lisa/hdfs/datanode
- Mkdir-p/data/slot4/lisa/hdfs/datanode
- Mkdir-p/data/slot5/lisa/hdfs/datanode
- Mkdir-p/data/slot6/lisa/hdfs/datanode
- Mkdir-p/data/slot7/lisa/hdfs/datanode
- Mkdir-p/data/slot8/lisa/hdfs/datanode
- Mkdir-p/data/slot9/lisa/hdfs/datanode
- Mkdir-p/data/slot11/lisa/hdfs/datanode
- Mkdir-p/data/slot10/lisa/hdfs/datanode
- Chown-Rlisa: lisa/data/slot1/lisa
- Chown-Rlisa: lisa/data/slot2/lisa
- Chown-Rlisa: lisa/data/slot3/lisa
- Chown-Rlisa: lisa/data/slot4/lisa
- Chown-Rlisa: lisa/data/slot5/lisa
- Chown-Rlisa: lisa/data/slot6/lisa
- Chown-Rlisa: lisa/data/slot7/lisa
- Chown-Rlisa: lisa/data/slot8/lisa
- Chown-Rlisa: lisa/data/slot9/lisa
- Chown-Rlisa: lisa/data/slot10/lisa
- Chown-Rlisa: lisa/data/slot11/lisa