Table of Contents
1、环境说明
2、准备工作
2.1、修改Hostname
2.2、添加Hosts映射关系
2.3、配置JDK环境
2.3.1、解压安装包
2.3.2、修改环境配置信息
2.3.3、检查当前JDK版本信息
2.3.4、补充(可选)
2.4、安装SSH
2.5、新建用户
2.6、配置集群之间SSH无密码登陆
3、Hadoop集群安装配置
3.1、修改hadoop配置文件
5.2、同步安装包
3.3、启动Hadoop集群
4、Zookeeper集群安装配置
4.1、修改zookeeper配置文件zoo.cfg
4.2、新建目录、新建并编辑myid文件
4.4、启动zookeeper
4.5、检查zookeeper是否配置成功
5、HBase集群安装配置
5.1、修改hbase配置文件
5.3、启动HBase
6、结语
Home Database Mysql Tutorial 分布式集群环境hadoop、hbase、zookeeper搭建(全)

分布式集群环境hadoop、hbase、zookeeper搭建(全)

Jun 07, 2016 pm 04:30 PM
hadoop hbase distributed environment cluster

1、环境说明 集群环境至少需要3个节点(也就是3台服务器设备):1个Master,2个Slave,节点之间局域网连接,可以相互ping通,下面举例说明,配置节点IP分配如下: Hostname IP 新建用户 新建用户密码 Master 10.10.10.213 hadoop 123456 Slave1 10.10.10.214

1、环境说明

集群环境至少需要3个节点(也就是3台服务器设备):1个Master,2个Slave,节点之间局域网连接,可以相互ping通,下面举例说明,配置节点IP分配如下:

Hostname IP 新建用户 新建用户密码
Master 10.10.10.213 hadoop 123456
Slave1 10.10.10.214 hadoop 123456
Slave2 10.10.10.215 hadoop 123456

三个节点均使用centos?6.3系统,为了便于维护,集群环境配置项最好使用相同用户名、用户密码、相同hadoop、hbase、zookeeper目录结构。

2、准备工作

2.1、修改Hostname

为了集群能够正常稳定的运行,我们需要将每个节点的hostname分别配置为对应的Master、Slave1、Slave2。

(1)在Master服务器中执行以下命令:

hostname Master	//当前有效
Copy after login
vi /etc/sysconfig/network	//重启后生效
Copy after login
Copy after login
Copy after login
HOSTNAME=Master
Copy after login

(2)在Slave1服务器中执行以下命令:

hostname Slave1	//当前有效
Copy after login
vi /etc/sysconfig/network	//重启后生效
Copy after login
Copy after login
Copy after login
HOSTNAME=Slave1
Copy after login

(3)在Slave2服务器中执行以下命令:

hostname Slave2	//当前有效
Copy after login
vi /etc/sysconfig/network	//重启后生效
Copy after login
Copy after login
Copy after login
HOSTNAME=Slave2
Copy after login

2.2、添加Hosts映射关系

分别在三个节点下通过如下命令修改hosts映射关系:

vi /etc/hosts
Copy after login

添加内容如下:

Master	10.10.10.213
Slave1	10.10.10.214
Slave2	10.10.10.215
Copy after login

2.3、配置JDK环境

Hadoop集群必须依赖JDK环境,所以这里我们首先需要配置好JDK环境,同样为了管理,我们建议服务器中的节点JDK安装环境均在相同路径下。

2.3.1、解压安装包

拷贝jdk文件jdk-6u25-linux-x64.bin到/usr/lib/java文件目录(该目录可自行定义)下,解压安装包,如果文件权限被限制,可通过如下命令进行赋权限操作:

chmod u+w jdk-6u25-linux-x64.bin
Copy after login

2.3.2、修改环境配置信息

vi /etc/profile
Copy after login

在最后加上:

export JAVA_HOME=/usr/lib/java/jdk1.6.0_25
export PATH=$PATH:$JAVA_HOME/bin 
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/rt.jar
Copy after login

通过注销或者以下命令使修改生效:

source /etc/profile
Copy after login

2.3.3、检查当前JDK版本信息

java -version
Copy after login

2.3.4、补充(可选)

如果查看当前的JDK版本不是刚才设置的JDK版本,则可以进行默认JDK版本设置操作:

sudo update-alternatives --install /usr/bin/java java /usr/lib/java/jdk1.6.0_25/bin/java 300   
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/java/jdk1.6.0_25/bin/javac 300   
sudo update-alternatives --config java(选择jdk1.6.0_25版本的序号就行)
Copy after login

2.4、安装SSH

Centos系统安装时默认可以选择安装SSH,ubuntu下可以通过如下命令进行安装(前提是必须联网):

sudo apt-get install ssh
sudo apt-get install rsync
Copy after login

2.5、新建用户

为了hadoop集群的安全与方便管理,我们要另外新建用户,并设置密码,命令如下:

sudo adduser hadoop
sudo passwd hadoop
Copy after login

上述命令中,第一行命令新建了一个user为hadoop的用户,第二行命令是为这个hadoop用户设置密码,同样最好服务器之间均保持一致。

2.6、配置集群之间SSH无密码登陆

集群环境的使用必须通过ssh无密码登陆来执行,本机登陆本机必须无密码登陆,主机与从机之间必须可以双向无密码登陆,从机与从机之间无限制。以本次为例,比如Master与Slave1之间的无密码登陆设置步骤如下:

(1)进入Master服务器,进行无密码自登陆设置

ssh hadoop@Master	//登陆Master
ssh-keygen  -t  rsa  -P  ''  -f  ~/.ssh/id_rsa
cat  ~/.ssh/id_rsa.pub  >>  ~/.ssh/authorized_keys	//生成密钥
chmod 700 ~/.ssh && chmod 600 ~/.ssh/*	//设置权限
Copy after login

如果不知道是否配置成功,可通过如下命令进行验证:

ssh localhost
Copy after login
如果上述命令不需要输入密码则表示配置成功。

进入Slave1服务器,进行无密码自登陆设置,操作同上,只需将对应的Master改为Slave1即可,此处省略。

(2)进入Master服务器,设置Master->Slave1的无密码登陆

ssh hadoop@Master	//登陆Master
cat ~/.ssh/id_rsa.pub | ssh hadoop@Slave1 'cat - >> ~/.ssh/authorized_keys'
ssh hadoop@Slave1	//若此处不需要输入密码则配置成功
Copy after login

(3)进入Slave1服务器,设置Slave1->Master的无密码登陆

ssh hadoop@Slave1	//登陆Slave1
cat ~/.ssh/id_rsa.pub | ssh hadoop@Master 'cat - >> ~/.ssh/authorized_keys'
ssh hadoop@Master	//若此处不需要输入密码则成功
Copy after login

以上便是Master与Slave1之间的双向无密码登陆配置。Master与Slave2之间的配置原理同上述基本一样,所以不再赘述。

3、Hadoop集群安装配置

3.1、修改hadoop配置文件

在centos系统下解压hadoop安装包hadoop-1.0.3.tar.gz,修改conf目录下的6个文件:

(1)core-site.xml
		fs.default.name
		hdfs://Master:9000
Copy after login
(2)hadoop-env.sh

在该文件中加上如下一行代码:

export JAVA_HOME=(你配置的jdk路径,比如:/usr/java/jdk1.6.0_25)
Copy after login

(3)hdfs-site.xml

	
		dfs.name.dir
		/home/hadoop/temp/hadoop
		dfs.data.dir
		/home/hadoop/temp/hadoop
		dfs.replication
		1
		dfs.support.append
		true
Copy after login

(4)mapred-site.xml

		mapred.job.tracker
		Master:9001
		mapred.acls.enabled
		false
Copy after login

(5)Masters

Master
Copy after login

(6)Slaves

Slave1
Slave2
Copy after login
Copy after login

3.2、同步安装包

将解压修改后的hadoop-1.0.3文件夹分别拷贝到Master、Slave1、Slave2的相同hadoop安装路径下。

3.3、启动Hadoop集群

进入Master的hadoop-1.0.3目录,执行以下操作:

bin/hadoop namenode -format	//格式化namenode,第一次启动服务前执行的操作,以后不需要执行
bin/start-all.sh	 //启动hadoop
jps	//用jps命令能看到除jps外有5个进程
Copy after login

至此,hadoop集群配置过程结束。可通过浏览器地址http://10.10.10.213:50070?查看节点启用状态验证配置是否成功。

4、Zookeeper集群安装配置

4.1、修改zookeeper配置文件zoo.cfg

在centos系统下解压zookeeper安装包zookeeper-3.4.3.tar.gz?,进入到conf目录,将zoo_sample.cfg拷贝一份命名为zoo.cfg(Zookeeper?在启动时会找这个文件作为默认配置文件),打开该文件进行修改为以下格式(注意权限问题,如果最后配置有问题请检查过程中权限是否正确)。

dataDir=/home/hadoop/temp/zookeeper/data
server.0=10.10.10.213:2888:3888
server.1=10.10.10.214:2888:3888
server.2=10.10.10.215:2888:3888
Copy after login

4.2、新建目录、新建并编辑myid文件

(本次配置myid文件放在/home/hadoop/temp/zookeeper/data目录下)

mkdir /home/hadoop/temp/zookeeper/data	//dataDir目录
vi /home/hadoop/temp/zookeeper/data/myid
Copy after login

注意myid文件中的内容为:Master中为0,Slave1中为1,Slave2中为2,分别与zoo.cfg中对应起来。

4.3、同步安装包

将解压修改后的zookeeper-3.4.3文件夹分别拷贝到Master、Slave1、Slave2的相同zookeeper安装路径下。注意:myid文件的内容不是一样的,各服务器中分别是对应zoo.cfg中的设置。

4.4、启动zookeeper

Zookeeper的启动与hadoop不一样,需要每个节点都执行,分别进入3个节点的zookeeper-3.4.3目录,启动zookeeper:

bin/zkServer.sh start
Copy after login
注意:此时如果报错先不理会,继续在另两台服务器中执行相同操作。

4.5、检查zookeeper是否配置成功

待3台服务器均启动后,如果过程正确的话zookeeper应该已经自动选好leader,进入每台服务器的zookeeper-3.4.3目录,执行以下操作查看zookeeper启动状态:

bin/zkServer.sh status
Copy after login

如果出现以下代码表示安装成功了。

[java] view plaincopy
JMX enabled by default  
Using config: /home/hadoop/zookeeper-3.4.3/bin/../conf/zoo.cfg  
Mode: follower	//或者有且只有一个leader
Copy after login

5、HBase集群安装配置

5.1、修改hbase配置文件

在centos系统下解压hadoop安装包hadoop-1.0.3.tar.gz,修改conf目录下的3个文件:

(1)hbase-env.sh

export JAVA_HOME=/usr/lib/java/jdk1.6.0_25	//JDK的安装目录
export HBASE_CLASSPATH=/home/hadoop/hadoop-1.0.3/conf	//hadoop的安装目录
export HBASE_MANAGES_ZK=true
Copy after login

(2)hbase-site.xml

		hbase.rootdir
		hdfs://Master:9000/hbase
		hbase.cluster.distributed
		true
		hbase.zookeeper.property.clientPort
		2181
		hbase.zookeeper.quorum
		Master
		hbase.zookeeper.property.dataDir
		/home/hadoop/temp/zookeeper
		dfs.support.append
		true
Copy after login

(3)regionservers

Slave1
Slave2
Copy after login
Copy after login

5.2、同步安装包

将解压修改后的hbase-0.94.1-security文件夹分别拷贝到Master、Slave1、Slave2的相同hbase安装路径下。

5.3、启动HBase

进入Master的hbase-0.94.1-security目录,执行以下操作:

bin/start-hbase.sh	//之后用jps查看是否所有进程都已启动
Copy after login

至此,hbase服务配置过程结束。可通过浏览器地址http://10.10.10.213:60010?查看hbase是否可用。

也可以执行以下命令,进入hbase?shell进行验证。

6、结语

关于hadoop、zookeeper、hbase的启动与关闭顺序:启动时hadoop和zookeeper随意先后,但是hbase必须最后启动,关闭时hbase必须首先关闭,然后随意先后关闭hadoop、zookeeper。否则,会出现异常。

关于各软件的安装包可以去官网下载,不同版本的安装配置可能会有少许的变动,而且版本搭配如果不一样的话也可能出现问题,有问题就针对性地去查,这样学习才有进步。

作者:jinnchang 发表于2013-5-8 16:29:30 原文链接

阅读:44 评论:0 查看评论

分布式集群环境hadoop、hbase、zookeeper搭建(全)

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Unable to boot into Windows recovery environment Unable to boot into Windows recovery environment Feb 19, 2024 pm 11:12 PM

Windows Recovery Environment (WinRE) is an environment used to repair Windows operating system errors. After entering WinRE, you can perform system restore, factory reset, uninstall updates, etc. If you are unable to boot into WinRE, this article will guide you through fixes to resolve the issue. Unable to boot into the Windows Recovery Environment If you cannot boot into the Windows Recovery Environment, use the fixes provided below: Check the status of the Windows Recovery Environment Use other methods to enter the Windows Recovery Environment Did you accidentally delete the Windows Recovery Partition? Perform an in-place upgrade or clean installation of Windows below, we have explained all these fixes in detail. 1] Check Wi

Node completely evacuates from Proxmox VE and rejoins the cluster Node completely evacuates from Proxmox VE and rejoins the cluster Feb 21, 2024 pm 12:40 PM

Scenario description for nodes to completely evacuate from ProxmoxVE and rejoin the cluster. When a node in the ProxmoxVE cluster is damaged and cannot be repaired quickly, the faulty node needs to be kicked out of the cluster cleanly and the residual information must be cleaned up. Otherwise, new nodes using the IP address used by the faulty node will not be able to join the cluster normally; similarly, after the faulty node that has separated from the cluster is repaired, although it has nothing to do with the cluster, it will not be able to access the web management of this single node. In the background, information about other nodes in the original ProxmoxVE cluster will appear, which is very annoying. Evict nodes from the cluster. If ProxmoxVE is a Ceph hyper-converged cluster, you need to log in to any node in the cluster (except the node you want to delete) on the host system Debian, and run the command

How to use Redis to achieve distributed data synchronization How to use Redis to achieve distributed data synchronization Nov 07, 2023 pm 03:55 PM

How to use Redis to achieve distributed data synchronization With the development of Internet technology and the increasingly complex application scenarios, the concept of distributed systems is increasingly widely adopted. In distributed systems, data synchronization is an important issue. As a high-performance in-memory database, Redis can not only be used to store data, but can also be used to achieve distributed data synchronization. For distributed data synchronization, there are generally two common modes: publish/subscribe (Publish/Subscribe) mode and master-slave replication (Master-slave).

How Redis implements distributed session management How Redis implements distributed session management Nov 07, 2023 am 11:10 AM

How Redis implements distributed session management requires specific code examples. Distributed session management is one of the hot topics on the Internet today. In the face of high concurrency and large data volumes, traditional session management methods are gradually becoming inadequate. As a high-performance key-value database, Redis provides a distributed session management solution. This article will introduce how to use Redis to implement distributed session management and give specific code examples. 1. Introduction to Redis as a distributed session storage. The traditional session management method is to store session information.

Sharing experience in using MongoDB to implement distributed task scheduling and execution Sharing experience in using MongoDB to implement distributed task scheduling and execution Nov 02, 2023 am 09:39 AM

MongoDB is an open source NoSQL database with high performance, scalability and flexibility. In distributed systems, task scheduling and execution are a key issue. By utilizing the characteristics of MongoDB, distributed task scheduling and execution solutions can be realized. 1. Requirements Analysis for Distributed Task Scheduling In a distributed system, task scheduling is the process of allocating tasks to different nodes for execution. Common task scheduling requirements include: 1. Task request distribution: Send task requests to available execution nodes.

How to use Docker to manage and expand multi-node clusters How to use Docker to manage and expand multi-node clusters Nov 07, 2023 am 10:06 AM

In today's cloud computing era, containerization technology has become one of the most popular technologies in the open source world. The emergence of Docker has made cloud computing more convenient and efficient, and has become an indispensable tool for developers and operation and maintenance personnel. The application of multi-node cluster technology is widely used based on Docker. Through multi-node cluster deployment, we can utilize resources more efficiently, improve reliability and scalability, and also be more flexible in deployment and management. Next, we will introduce how to use Docker to

Using Redis to achieve distributed cache consistency Using Redis to achieve distributed cache consistency Nov 07, 2023 pm 12:05 PM

Using Redis to achieve distributed cache consistency In modern distributed systems, cache plays a very important role. It can greatly reduce the frequency of system access to the database and improve system performance and throughput. In a distributed system, in order to ensure cache consistency, we need to solve the problem of data synchronization between multiple nodes. In this article, we will introduce how to use Redis to achieve distributed cache consistency and give specific code examples. Redis is a high-performance key-value database that supports persistence, replication, and collection

How to use Swoole to implement distributed scheduled task scheduling How to use Swoole to implement distributed scheduled task scheduling Nov 07, 2023 am 11:04 AM

How to use Swoole to implement distributed scheduled task scheduling Introduction: In traditional PHP development, we often use cron to implement scheduled task scheduling, but cron can only execute tasks on a single server and cannot cope with high concurrency scenarios. Swoole is a high-performance asynchronous concurrency framework based on PHP. It provides complete network communication capabilities and multi-process support, allowing us to easily implement distributed scheduled task scheduling. This article will introduce how to use Swoole to implement distributed scheduled task scheduling

See all articles