Installation and configuration of hadoop, Zookeeper, and hbase (absolutely available)

Source: Internet
Author: User

In the past two days, a hadoop cluster (and hbase) is being configured for the company as a platform for storing and computing massive data. Paste the installation process for your reference only.


Hadoop Configuration
  • Physical configuration of the Cluster

Cluster IP Address: 172.16.38.213 ~ 172.16.38.218

(Hostname: Master, slave0, slave1, slave2, slave3, and slave4)

Username/password: Root/123456

The master node serves as jobtracker and namenode, And the other nodes serve as tasktracker and datanode.

  • Node role allocation

Modify the/etc/hosts file of each node and append the following content:

172.16.38.213 master

172.16.38.214 slave0

172.16.38.215 slave1

172.16.38.216 slave2

172.16.38.217 slave3

172.16.38.218 slave4

Modify the hostname of each node. For example, change the/etc/sysconfig/network file of the master node

Networking = Yes

Hostname = Master

Then, run

Hostname master

Exit and enter env | grep hostname. The modification takes effect.
  • Set password-less SSH Login for each node

1. Run on the master node

Ssh-keygen-T RSA


2. on the master node

Cat ~ /. Ssh/id_rsa.pub> ~ /. Ssh/authorized_keys

Then


Chmod 644 ~ /. Ssh/authorized_keys


3. Change ~ The/. Ssh/id_rsa.pub files are SCP to each slave node, as shown in figure

SCP ~ /. Ssh/id_rsa.pub root @ slave0:/home


4. log on to each slave node and run it (take slave0 as an example)

CAT/home/id_rsa.pub> ~ /. Ssh/authorized_keys


5. Modify file permissions

Chmod 600 ~ /. Ssh/authorized_keys


6. cycle from step 1 until each slave node is configured

  • Download hadoop

Download the hadoop-1.1.2, put it in the/home/LTE directory, unzip it with the command tar zxvf hadoop-1.1.2.tar.gz, and generate the directory hadoop-1.1.2 under/home/LTE


  • Modify the hadoop configuration file

Modify the conf/core-site.xml File

<Configuration>

<Property>

<Name> fs. Default. Name </Name>

<Value> HDFS: // master: 54310 </value>

</Property>

<Property>

<Name> hadoop. tmp. dir </Name>

<Value>/home/LTE/hadoop/tmp </value>

</Property>

</Configuration>


Add in CONF/hadoop-env.xml File

Export java_home =/usr/local/Java/jdk1.6.0 _ 32


Modify the conf/hdfs-site.xml file:

<Configuration>

<Property>

<Name> DFS. Replication </Name>

<Value> 2 </value>

</Property>

<Property>

<Name> DFS. Data. dir </Name>

<Value>/home/LTE/hadoop/Data </value>

</Property>

<Property>

<Name> DFS. Name. dir </Name>

<Value>/home/LTE/hadoop/name </value>

</Property>

</Configuration>



Modify the conf/mapred-site.xml file:

<Configuration>

<Property>

<Name> mapred. Job. Tracker </Name>

<Value> master: 9001. </value>

</Property>

<Property>

<Name> mapred. Local. dir </Name>

<Value>/home/LTE/hadoop/temp </value>

</Property>

</Configuration>



Conf/masters File
Master


Conf/slaves File

Slave0

Slave1

Slave2

Slave3

Slave4


Copy the/home/LTE directory from the master node to the/Home Directory of each slave node in sequence.
  • Start hadoop

Format HDFS in the/home/LTE/hadoop-1.1.2 directory of the master node

Bin/hadoop namenode-format


After formatting, all content in HDFS will be lost.
 
Then, enable the hadoop Cluster
Bin/start-all.sh
 
Now, the hadoop cluster has been started and you can submit computation jobs.



Hbase Configuration

When installing hbase, you not only need hbase, but also need zookeeper to provide, manage, and coordinate distributed services. Before Running hbase, you also need to start the zookeeper service.

In addition, hbase of some versions only supports hadoop of specific versions, as shown in the following table:

In this paper, the use of Hadoop-1.1.2, HBase-0.94.8, and ZooKeeper-3.4.5

Because zookeeper uses the paxos Algorithm for election, the number of nodes that can effectively participate in the election is an odd number. Therefore, we only use an odd number of nodes when installing hbase and zookeeper (five nodes are used in this article, namely master, slave0, slave1, slave2, and slave3 ).

Install zookeeper

Decompress zookeeper-3.4.5.tar.gz in/home/LTE to generate a zookeeper-3.4.5 directory. In/home/LTE/zookeeper-3.4.5/Conf, there is a zoo_sample.cfg file that uses the command CP zoo_sample.cfg zoo. cfg to generate the zoo. cfg configuration file. Edit zoo. cfg as follows:

# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just # example sakes.dataDir=/home/LTE/zookeeper# the port at which the clients will connectclientPort=2181server.1=master:2888:3888server.2=slave0:2888:3888server.3=slave1:2888:3888server.4=slave2:2888:3888server.5=slave3:2888:3888## Be sure to read the maintenance section of the # administrator guide before turning on autopurge.## http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance## The number of snapshots to retain in dataDir#autopurge.snapRetainCount=3# Purge task interval in hours# Set to "0" to disable auto purge feature#autopurge.purgeInterval=1

To enable the system to recognize Zoo. server. id = server in host: Port: port. ID: create a file myid in/home/LTE/zookeeper on the master node, which has only one number 1. Similarly, create a file myid in/home/LTE/zookeeper on the slave0 node, which has only one number 2, and so on .... Until the slave3 node. Note that the ID range is 1 ~ 255. The preceding configurations (zookeeper and zookeeper-3.4.5) are replicated to every node in the cluster.

Add at the end of/etc/profile:

export HBASE_HOME=/home/LTE/hbase-0.94.8export HADOOP_HOME=/home/LTE/hadoop-1.1.2export ZK_HOME=/home/LTE/zookeeper-3.4.5export JAVA_HOME=/usr/local/java/jdk1.6.0_32export CLASSPATH=$CLASSPATH:$HBASE_HOME/lib:$JAVA_HOME/libexport PATH=$JAVA_HOME/bin:$HBASE_HOME/bin:$ANT_HOME/bin:$HADOOP_HOME/bin:$ZK_HOME/bin:$PATH

Then, source/etc/profile
This operation must be performed on each node of the cluster.

Start zookeeper

Run the command:./zkserver. Sh start in/home/LTE/zookeeper-3.4.5/bin on each node
In this way, nodes in the zookeeper cluster are started.

Enter the command./zkserver. Sh status
Check whether the role of the current node in the zookeeper cluster is leader or follower.

Install hbase

Extract/home/LTE/hbase-0.94.8.tar.gz to generate/home/LTE/hbase-0.94.8. In hbase-0.94.8/lib, there was originally a hadoop-core-1.0.4.jar file, but the version of hadoop we used was hadoop-1.1.2, so we need to replace hbase-0.94.8/lib/hadoop-core-1.0.4.jar with hadoop-1.1.2/hadoop-core-1.1.2.jar, otherwise there will be conflicts.

Open the conf/hbase-env.sh file and change the last line:
Export hbase_manages_zk = false

This means that we do not use the zookeeper that comes with the hbase-0.94.8, but instead use the zookeeper-2.3.4 we just installed (specifically specifying which zookeeper is specified through the zk_home variable in/etc/profile ).

Open the conf/hbase-site.xml file and add the following:

<configuration>    <property>        <name>hbase.rootdir</name>        <value>hdfs://master:54310/hbase</value>    </property>    <property>        <name>hbase.cluster.distributed</name>        <value>true</value>    </property>    <property>        <name>dfs.replication</name>        <value>3</value>    </property>    <property>        <name>hbase.zookeeper.quorum</name>        <value>master,slave0,slave1,slave2,slave3</value>    </property>    <property>        <name>hbase.zookeeper.property.dataDir</name>        <value>/home/LTE/zookeeper/dataDir</value>    </property></configuration>

Here, we need to use hbase. rootdir specifies a namenode node of HDFS and enables hbase to write data to a directory in HDFS (HDFS: // master: 54310/hbase in this example); hbase. zookeeper. quorum specifies which nodes are running the quorum peer (namely the quorumpeermain process). The number of nodes must be odd.

Open the conf/regionservers file and add the following content:

slave0slave1slave2slave3

This file specifies the nodes on which the hregionserver process will run.

The preceding configuration takes effect on each hbase node.

Start hbase

OK. Now the hbase cluster is configured. Let's start hbase.
Go to the $ hbase_home/bin directory and enter the command
/Start-hbase.sh

After the hbase cluster is started, type the command
./Hbase Shell
Start the hbase console interface

You can view the running status of the hbase System in the browser. The address is http: // 172.16.38.213: 60010/master-status, where 172.16.38.213 is the IP address of the master node.

FAQ: a node in hbase cannot be started.

This is probably because the system time of each node in the cluster is inconsistent (the time difference exceeds a certain threshold). This is because we need to adjust the time of several machines to be consistent.
We can use the master as the time server so that other machines can be connected to the master.

First, type the Command Service ntpd start on the master to enable the time server on the master.
Wait a few minutes and then type the ntpdate master command on each other to pair with the master.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.