OpenNebula

OpenNebula 允许虚拟机动态放置或者重新放置在一个物理资源池上。这让虚拟机在任意有效的位置上驻留。
这段将详细描述用三台机器配置OpenNebula cluster:一台 Front-End主机,和两台运行虚拟机的 Compute Nodes 。Compute Nodes需要一个bridge配置,来允许虚拟机访问本地网络。更详细的信息参考 “Bridge“ https://help.ubuntu.com/10.04/serverguide/C/network-configuration.html#bridging 。
安装
首先,在 Front-End 的终端输入 :
sudo apt-get install opennebula
在每一台 Compute Nodes 安装:
sudo apt-get install opennebula-node
为了拷贝 SSH keys,oneadmin用户需要一个密码。在每一台机器上执行:
sudo passwd oneadmin
下一步,拷贝 oneadmin 用户的 SSH key 到 Compute Nodes,和到 Front-End的 authorized_keys 文件:
sudo scp /var/lib/one/.ssh/id_rsa.pub oneadmin@node01:/var/lib/one/.ssh/authorized_keys
sudo scp /var/lib/one/.ssh/id_rsa.pub oneadmin@node02:/var/lib/one/.ssh/authorized_keys
sudo sh -c “cat /var/lib/one/.ssh/id_rsa.pub >> /var/lib/one/.ssh/authorized_keys
为了让除了 oneadmin 以外的其他用户能ssh到每一台 Compute Node,给 Compute Nodes 的 SSH key 需要增加到Front-End的 /etc/ssh/ssh_known_hosts 文件。然后退出 SSH 会话,执行下面拷贝 SSH key 从 ~/.ssh/known_hosts 到 /etc/ssh/ssh_known_hosts:
sudo sh -c “ssh-keygen -f .ssh/known_hosts -F node01 1>> /etc/ssh/ssh_known_hosts”
sudo sh -c “ssh-keygen -f .ssh/known_hosts -F node02 1>> /etc/ssh/ssh_known_hosts”
注意:用适当的主机名字替换掉 node01 和 node02。
这允许 oneadmin 在不用交互输入密码的情况下使用scp,来部署一个镜像到 Compute Nodes.
在 Front-End 上创建一个目录,用来存储 VM镜像。你可以使用vmbuilder来创建 Ubuntu虚拟主机, 参考 “JeOS and vmbuilder” https://help.ubuntu.com/10.04/serverguide/C/jeos-and-vmbuilder.html 获得更详细的信息。
配置
OpenNebula Cluster 开始配置了,增加虚拟机到 cluster。
从终端提示符那里输入:
onehost create node01 im_kvm vmm_kvm tm_ssh
onehost create node02 im_kvm vmm_kvm tm_ssh
下一步,创建一个虚拟网络模板文件,名为 vnet01.template:
NAME = “LAN”
TYPE = RANGED
BRIDGE = br0
NETWORK_SIZE = C
NETWORK_ADDRESS = 192.168.0.0
注意:确保修改 192.168.0.0 为你的本地网络。
使用 onevnet 工具,增加这个虚拟网络给 OpenNebula :
onevnet create vnet01.template
现在,创建一个VM模板文件,名字为 vm01.template:
NAME = vm01
CPU = 0.5
MEMORY = 512
OS = [ BOOT = hd ]
DISK = [
source = "/var/lib/one/images/vm01.qcow2",
target = "hda",
readonly = "no" ]
NIC = [ NETWORK = "LAN" ]
GRAPHICS = [ type="vnc", listen="127.0.0.1", port="-1" ]
使用 onevm 启动虚拟机:
onevm submit vm01.template
用 onevm list 选项来查看虚拟机的信息。同样, onevm show vm01 选项将显示更多关于一个指定虚拟机的细节。
Posted in 虚拟化 | Leave a comment

libvirt

原文链接 libvirt 用作为不同虚拟化技术的接口。在开始了解libvirt之前,最好确定你的硬件支持KVM必需的虚拟话扩展。在控制台输入下面的命令:
kvm-ok
将打印出一条信息,告诉你你的CPU是否支持硬件虚拟化。
注意:对大多数的机器,处理器是支持虚拟化的,需要在BIOS里面激活这个选项。
虚拟化网络
有多种不同的方法允许一个虚拟机访问外部网络。缺省的虚拟网络配置是 usermode 网络,它使用SLIRP协议,被NATed的流量通过主机接口到达外部网络。
让外部主机直接访问虚拟机上的服务,需要配置一个bridge。才能让虚拟接口通过物理接口来连接外部网络,对网络上的其他主机,他们表现的像正常的主机。更多的信息关于设置一个bridge,请看 “Bridaging” 这一段 https://help.ubuntu.com/10.04/serverguide/C/network-configuration.html#bridging 。
安装
安装需要的包,在终端提示符那里输入下面的命令:
sudo apt-get install kvm libvirt-bin
安装完 libvirt-bin 之后,用来管理虚拟机的用户将需要增加到 libvirtd 组。 这样,他就会获得访问高级网络选项的能力。
在终端中输入:
sudo adduser $USER libvirtd
注意:如果选择的是当前用户,要让新的组成员关系生效,你需要重新登录一次。
现在,你准备要安装一个 Guest operating system. 安装一个虚拟机,和直接在硬件上安装操作系统的步骤是一样的。 你需要一种自动安装的方法,或者需要一个键盘和显示器,连接到物理机器上的。
在这个虚拟机器的案例中,类似一个 GUI使用物理键盘和鼠标。不安装一个GUI,virt-viewer使用VNC可以用来连接一个虚拟机器的控制台。参考 “Virtual Machine Viewer“ https://help.ubuntu.com/10.04/serverguide/C/libvirt.html#libvirt-virt-viewer 获得更多信息。
有几种方法可以让Ubuntu的安装过程自动化,例如,使用 preseeds, kickstart, 等等。参考 Ubuntu Installation Guide https://help.ubuntu.com/10.04%20LTS/installation-guide/ 获得更详细的信息。
另外一种安装Ubuntu虚拟机的方法是使用 ubuntu-vm-builder。ubuntu-vm-builder 允许你设置高级分区,执行自定义的 post-install 脚本,等等。更多的信息请看这段 “ JeOS and vmbuilder“ https://help.ubuntu.com/10.04/serverguide/C/jeos-and-vmbuilder.html。
virt-intall
virt-install 是 python-virtinst 包的一部分。要安装它,在终端提示符下输入:
sudo apt-get install python-virtinst
virt-install有几个有效的选项。例如:
sudo virt-install -n web_devel -r 256 -f web_devel.img \
-s 4 -c jeos.iso –accelerate \
–connect=qemu:////system –vnc \
–noautoconsole -v
-n web_devel 在这里例子中,新的虚拟机的名字将会是 web_devel
-r 256 虚拟机使用的内存总数是256
-f web_devel.img 指出虚拟盘的路径,可以为一个文件,分区或者逻辑卷标。在这个例子为一个名为 web_devel.img 的文件
-s 4 虚拟盘的大小
-c jeos.iso 用作虚拟CDROM的文件。这个文件可以是一个ISO文件或者指向主机CDROM设备
–accelerate 打开内核加速技术
–vnc 用VNC输出虚拟的控制台
–noautoconsole 不自动连接到虚拟机控制台
-v 创建一个完全虚拟化的guest
执行 virt-install 后,你可以在本地使用一个GUI连接虚拟机控制台或者使用virt-viewer工具。
virt-clone
virt-clone 应用拷贝 虚拟机。例如:
sudo virt-clone -o web_devel -n database_devel -f /path/to/database_devel.img –connect=qemu:///system
-o 原虚拟机
-n 新的虚拟机名字
-f 文件的路径,逻辑卷标,或者分区(新虚拟机使用)
-connect 指定哪一个管理程序来连接
同样,也可以使用 -d 或者 -debug 选项对 virt-clone 进行故障检测。
注意:可使用适当的虚拟机名字替代 web_devel 和 database_devel。
虚拟机管理
virsh
有个有效的工具管理虚拟机和libvirt。virsh工具使用命令行的方式。下面是一些例子:
+ 列出正在运行的虚拟机
virsh -c qemu:///system list
+ 启动一个虚拟机
virsh -c qemu:///system start web_devel
+ 类似,在引导时启动一个虚拟机
virsh -c qemu:///system autostart web_devel
+ 重启一个虚拟机
virsh -c qemu:///system reboot web_devel
+ 虚拟机的状态可以保存在一个文件中,便于后来的恢复。下面将保存虚拟机状态到一个文件中,以日期命名:
virsh -c qemu:///system save web_devel web_devel-022708.state
一旦保存,虚拟机将不再运行
+ 恢复保存状态的虚拟机的运行
virsh -c qemu:///system restore web_devel-022708.state
+ 关闭虚拟机
virsh -c qemu:///system shutdown web_devel
+ 在虚拟机中状态CDROM
virsh -c qemu:///system attach-dish web_devel /dev/crom /media/cdrom
注意:在上面的例子中,用适当的虚拟机名字替换 web_devel,而 web_devel-022708.state 作为描述文件名也一样。
Virtual Machine Manager
virt-manager 包,内含一个图形工具,管理本地和远程的虚拟机。安装virt-manager ,输入:
sudo apt-get install virt-manager
由于 virt-manager 需要一个GUI环境,推荐安装在工作站或者测试机器上。连接本地 libvirt 服务,输入:
virt-manager -c qemu:///system
你可以连接运行在另一台主机上的libvirt服务,在终端提示符下输入:
virt-manager -c qemu+ssh://virtnode1.mydomain.com/system
注意:上面的例子中, 在管理系统和virtnode1.mydomain.com之间的SSH连接是已经被配置好的,使用 SSH keys 来验证。SSH keys需要是因为 libvirt 发送密码提示符给另一个进程。关于SSH配置的更详细信息请参考 “OpenSSH Sever“ https://help.ubuntu.com/10.04/serverguide/C/openssh-server.html。
Virtual Machine Viewer
virt-viewer应用允许你连接到一个虚拟机控制台。virt-viewer需要GUI支持。
安装 virt-viewer :
sudo apt-get install virt-viewer
一旦虚拟机被安装和运行,你可以使用下面的命令来连接到虚拟机控制台:
virt-viewer -c qemu:///system web_devel
类似于 virt-manager,virt-viewer 能使用key认证的SSH连接到远程主机,如下:
virt-viewer -c qemu+ssh://virtnode1.mydomain.com/system web_devel
确信使用适当的虚拟机名字替换掉 web_devel。
如果配置了一个bridged网络接口,就可以配置SSH来访问虚拟主机,参考 “OpenSSH Server”
https://help.ubuntu.com/10.04/serverguide/C/openssh-server.html 和 ” Bridging”  https://help.ubuntu.com/10.04/serverguide/C/network-configuration.html#bridging 获得更详细的信息。
资源
• KVM 的主页 http://kvm.qumranet.com/kvmwiki
• libvirt 的主页 http://libvirt.org/
• Virtual Machine Manager 主站 http://virt-manager.et.redhat.com/
• #freednode 上的 ubuntu-virt IRC 频道,讨论Ubuntu的虚拟化技术 http://freenode.net/
• Ubuntu Wiki KVM  https://help.ubuntu.com/community/KVM
Posted in 虚拟化 | Leave a comment

Maven是什么

Maven的主要作用

Maven的主要作用

Apache Maven 是一个软件项目管理和理解工具。基于项目对象模型(POM)的概念,管理一个项目的建立,报告和文档。
如果你认为Maven给与你的项目与帮助,你可以在导航栏的“关于“段找到更多的信息。这里面深入的描述 Maven 是什么, 一些主要的特点, 和一些用户频繁问到的问题。
简介
Maven , Yiddish语为知识的累加器、专家。创建这个项目的目的源于在Jakata Turbin 项目中简化建造的过程。有几个项目,他们的Ant 建造文件略有不同,JARs检入到CVS中。我们想有一个标准的方式建造这些项目,一个清晰的定义就是项目是由什么组成,便易的方法是发布项目信息并且在几个项目之间共享JARs。
导致产生了一个用来建造和管理基于Java的项目的工具。我们希望这些事情能让Java开发者更容易工作,并且帮助对基于Java的项目的理解。
Maven 的目标
Maven的主要目的是帮助开发者在最短的时间内理解开发进展的完全状态。为了达到这个目标,Maven处理几个相关的领域的问题:
+ 使建造过程更容易
Maven 没有排除知道底层机制的需要的同时,对细节提供很多防护层。
+ 提供统一的建造系统
Maven允许使用他的项目对象模型(POM)和一个插件的集合来建造项目。一旦你熟悉一个Maven项目是如何建造的,你会自动明白所有的Maven项目是如何建造的,当驾驭很多个的项目时,能节约的大量的时间。
+ 提供高品质的项目信息
Maven提供大量有用的项目信息,一部分来自POM,一部分你来自项目的源码。例如,Maven可以提供:
++ Change 日志文档,直接从源码控制那里创建
++ 源码的交叉应用
++ 邮箱列表
++ 依赖列表
++ 单元测试报告(内含涉及范围)
Maven改良了信息的供给,所有这些对用户来说都是透明的。
其他产品可以提供Maven插件,来允许他们在Mave给出的标准的信息旁边放置自己的项目信息集。所有这些都是基于POM的。
+ 提供开发练习的指导方案
Maven为最好的开发练习收集理念,在这个方向上给项目提供指导。
例如,规范,执行和单元测试报告,这些都是使用Maven的正常建造周期的一部分。当前单元测试最好的练习指南:
++ 把你的单元测试源代码防止在独立,并且是平行的源码树中
++ 使用 test case 命名约定来定位和执行测试
++ 拥有单元测试的设置自己的环境,对于测试准备,不依赖自定义的建造。
Maven帮助项目流程,如发布管理和问题跟踪。
Maven提供对于项目目录结构布局的知道,一旦你学会布局,你可以很容易以同样的方式浏览其他的项目。
+ 允许透明合并新的 features
Maven为Maven客户端提供一个容易的方式来更新已安装的版本,以致达到充分利用升级后的好处。
从这点来讲,安装或者升级新的Maven自己或者第三方的插件是无关重要的。
Maven 不是什么
你可能听说过关于Maven的一些事情:
+ Maven是一个站点和一个文档工具
+ Maven扩展了Ant,让你下载依赖
+ Maven是一个可重用的Ant scriplets的集合
你从上面可以了解到Maven可以做这些事情。但这不是Maven具备的所有能力,他的目标是十分不同。
Maven鼓励更好的练习,但我们认识到由于历史的原因,一些项目已经不适合用于练习。在这些状况和出于不同项目的需要,没有对目标完善的妥协,它不能迎合每一种状况。
如果你决定用 Maven ,但拥有一个你不能整改的不平常的建造结构,你要么忘记这些特征或者完全使用Maven。
特色概要
+ 简单项目的setup – 在几秒钟内获得一个新项目或者模块
+ 所有的项目,一致的用法,表示新的开发者使用同样的时间就能进入一个项目
+ 超级的依赖管理,包含自动升级,依赖关口(传递依赖)
+ 在同一时间开展多个项目
+ 在盒子之外使用一个大型的、可增长的libraries和metadata的仓库,和大型的开源项目安置在一起,实时获得这些项目的最新发布版本
+ 可扩展性,容易使用Java或者脚本语言写插件
+ 不需要或者小小的配置就能实时访问新的features
+ 在Maven之外用Ant任务做依赖管理和发布
+ 基于模块的建造:Maven能够建造一定数量的预定义项目,输出类型如 JAR, WAR, 或者分发,基于该项目的metadata,对于大多数项目都不需要编写脚本。
+ 清晰的项目信息站点: 为建造过程使用同样的metadata,Maven能生成一个web站点或者PDF,包含你增加的文档,或者增加的标准报告,关于项目开发的状态。这些信息出现在左边导航的底下的“Project Information“和“Project Report” 子菜单。
+ 发行管理和分支发布:不需要额外的配置,Maven可以与你的源代码控制系统交互,如CVS,基于某个tag的项目发行。同样可以发布到某个分发的位置,给其他的项目使用。Maven能发布独立的输出,如JAR,一个包含其他依赖和文档的Archarce,或者一个源码分发。
+ 依赖管理: Maven鼓励使用JARs和其他依赖的中央仓库。Maven设定一个机制,就是你项目的客户端将会使用从中央仓库下载需要的JARs来建造你的项目,如Perl的CPAN。这让Maven的用户在项目之间重用JARs,鼓励项目之间的通信,确保向后兼容的问题的处理。中央仓库安置在ibiblio的服务器上。
Posted in 开发工具 | Leave a comment

在 HBase 0.20.x 编程中,执行 new HBaseConfiguration() 是抛出XML分析异常

原因是有多个XML分析器,需要通过JVM指定一个属性来解决问题。

-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.\
internal.jaxp.DocumentBuilderFactoryImpl

使 用上面指定的分析器就不再抛出异常

Posted in hbase | Leave a comment

安装 HBase 0.20.x

我把HBase官方的文档译了一下,没完成,方便对比着看。

Requirements

  • Java 1.6.x, preferably from Sun. Use the latest version available.
  • Java 1.6.x ,sun ,最好是最新版
  • This version of HBase will only run on Hadoop 0.20.x.
  • 指定的Hadoop版 本
  • ssh must be installed and sshd must be running to use Hadoop’s scripts to manage remote Hadoop daemons. You must be able to ssh to all nodes, including your local node, using passwordless login (Google “ssh passwordless login”).
  • ssh 和sshd 必须有,机器之间无须输入密码登录
  • HBase depends on ZooKeeper as of release 0.20.0. HBase keeps the location of its root table, who the current master is, and what regions are currently participating in the cluster in ZooKeeper. Clients and Servers now must know theirZooKeeper Quorum locations before they can do anything else (Usually they pick up this information from configuration supplied on their CLASSPATH). By default, HBase will manage a single ZooKeeper instance for you. In standalone andpseudo-distributed modes this is usually enough, but for fully-distributed mode you should configure a ZooKeeper quorum (more info below).
  • 需要指定版本的 ZooKeeper ,客户和服务在工作之前,需要在他们的CLASSPATH提供的配置中获得 他们的 ZookKeeper Quorum locations 信息。 缺省情况下,HBase管理一个Zookeeper实例。在standalone和 pseudo-distibuted 模式下是足够的,但是在 fully-distributed 模式,你需要配置一个 ZooKeeper quorum。(下面有更详细的信息)
  • Hosts must be able to resolve the fully-qualified domain name of the master.
  • 所有主机必须能解释 master 的 fully-qualified domain name 。
  • HBase currently is a file handle hog. The usual default of 1024 on *nix systems is insufficient if you are loading any significant amount of data into regionservers. See the FAQ: Why do I see “java.io.IOException…(Too many open files)” in my logs? for how to up the limit. Also, as of 0.18.x Hadoop DataNodes have an upper-bound on the number of threads they will support (dfs.datanode.max.xcievers). The default is 256 threads. Up this limit on your hadoop cluster.
  • 需要调整系统相关的文件句柄上限和线程上限。/etc/security /limits.conf 和 dfs.datanode.max.xcievers。
  • The clocks on cluster members should be in basic alignments. Some skew is tolerable but wild skew could generate odd behaviors. Run NTP on your cluster, or an equivalent.
  • 集群内所有节点时间同步,使用NTP。
  • HBase servers put up 10 listeners for incoming connections by default. Up this number if you have a dataset of any substance by setting hbase.regionserver.handler.count in your hbase-site.xml.
  • 缺省10个 listerners 处理进入到连接,可以通过配置 hbase-site.xml 的 hbase.regionserver.handler.count 来修改。
  • This is the current list of patches we recommend you apply to your running Hadoop cluster:
  • 下面是两个推荐使用的Hadoop集群的补丁:
  • HADOOP-4681/HDFS-127 “DFSClient block read failures cause open DFSInputStream to become unusable”. This patch will help with the ever-popular, “No live nodes contain current block”. The hadoop version bundled with hbase has this patch applied. Its an HDFS client fix so this should do for usual usage but if your cluster is missing the patch, and in particular if calling hbase from a mapreduce job, you may run into this issue. If running with hadoop 0.20.2, it has this patch in place already.
  • HDFS-630: “In DFSOutputStream.nextBlockOutputStream(), the client can exclude specific datanodes when locating the next block”. Dead DataNodes take ten minutes to timeout at NameNode. In the meantime the NameNode can still send DFSClients to the dead DataNode as host for a replicated block. DFSClient can get stuck on trying to get block from a dead node. This patch allows DFSClients pass NameNode lists of known dead DataNodes.

Windows

需要安装Cygwin

Getting Started

What follows presumes you have obtained a copy of HBase, see Releases, and are installing for the first time. If upgrading your HBase instance, see Upgrading

假定已经获得Hbase的拷贝, 升级请看这里 Upgrading

Three modes are described: standalone, pseudo-distributed (where all servers are run on a single host), and fully-distributed. If new to HBase start by following the standalone instructions.

三 种模式:standalone , preudo-distributed, fully-distributed.

Begin by reading Requirements.

Whatever your mode, define ${HBASE_HOME} to be the location of the root of your HBase installation, e.g. /user/local/hbase. Edit ${HBASE_HOME}/conf/hbase-env.sh. In this file you can set the heapsize for HBase, etc. At a minimum, set JAVA_HOME to point at the root of your Java installation.

无论使用 什么模式,都要定义 ${HBASE_HOME}到安装目录,编辑 ${HBASE_HOME}/conf/hbase-env.sh ,设置 HBase的 heapsize 等等,至少要设置 JAVA_HOME.

Standalone mode

If you are running a standalone operation, there should be nothing further to configure; proceed to Running and Confirming Your Installation. If you are running a distributed operation, continue reading.

standalone模式不需要配置,直接运行就可以。

Distributed Operation: Pseudo- and Fully-distributed modes

Distributed modes require an instance of the Hadoop Distributed File System (DFS). See the Hadoop requirements and instructions for how to set up a DFS.

分布式模式下需要一个HDFS实例。看这里Hadoop requirements and instructions如何安装一个DFS

Pseudo-distributed mode

A pseudo-distributed mode is simply a distributed mode run on a single host. Once you have confirmed your DFS setup, configuring HBase for use on one host requires modification of ${HBASE_HOME}/conf/hbase-site.xml, which needs to be pointed at the running Hadoop DFS instance. Use hbase-site.xml to override the properties defined in ${HBASE_HOME}/conf/hbase-default.xml(hbase-default.xml itself should never be modified). At a minimum the hbase.rootdir property should be redefined in hbase-site.xml to point HBase at the Hadoop filesystem to use. For example, adding the property below to your hbase-site.xml says that HBase should use the /hbase directory in the HDFS whose namenode is at port 9000 on your local machine:

pseudo-distributed模式,仅仅在一台机器上运行一个 distributed模式。DFS setup 后,配置 HBase 在一台机器上运行需要修改 ${HBASE_HOOME}/conf/hbase-site.xml 文件, 至少要 重新定义 hbase.rootdir 属性,指向要使用的 HDFS 。例如增加下面的属性到 hbase-site.xml , 说明 HBase 应该使用HDFS的 /hbase 目录,HDFS的名字节点在 localhost ,端口号为 9000

<configuration>

<property>

<name>hbase.rootdir</name>

<value>hdfs://localhost:9000/hbase</value>

<description>The directory shared by region servers.

</description>

</property>

</configuration>

Note: Let HBase create the directory. If you don’t, you’ll get warning saying HBase needs a migration run because the directory is missing files expected by HBase (it’ll create them if you let it).

Also Note: Above we bind to localhost. This means that a remote client cannot connect. Amend accordingly, if you want to connect from a remote location.

注意:要让 HBase自己创建这个目录。否则你会得到一个警告,HBase needs a migration run because the directory is missing files expected by HBase (it’ll create them if you let it).

同时要注意:上面绑定的是 localhost . 这表示 远程的客户无法连接。如果需要远程了解需要做相应的修改。

Fully-Distributed Operation

For running a fully-distributed operation on more than one host, the following configurations must be made in addition to those described in the pseudo-distributed operation section above.

fully-distributed 模式比较复杂一点,下面的配置内容需要额外增加到上面描述的 pseudo-distributed 操作段落上面。

In hbase-site.xml, set hbase.cluster.distributed to true.

在 hbase-site.xml ,设置 hbase.cluster.distributed 为true.

<configuration>

<property>

<name>hbase.cluster.distributed</name>

<value>true</value>

<description>The mode the cluster will be in. Possible values are

false: standalone and pseudo-distributed setups with managed Zookeeper

true: fully-distributed with unmanaged Zookeeper Quorum (see hbase-env.sh)

</description>

</property>

</configuration>

In fully-distributed mode, you probably want to change your hbase.rootdir from localhost to the name of the node running the HDFS NameNode. In addition to hbase-site.xml changes, a fully-distributed mode requires that you modify${HBASE_HOME}/conf/regionservers. The regionserver file lists all hosts running HRegionServers, one host per line (This file in HBase is like the Hadoop slaves file at ${HADOOP_HOME}/conf/slaves).

hbase.rootdir 改为 HDFS 的名字节点。修改 conf/regionservers 文件。一行一个HRegionServer 的主机。就如 Hadoop 的 slaves 文件一样。

A distributed HBase depends on a running ZooKeeper cluster. All participating nodes and clients need to be able to get to the running ZooKeeper cluster. HBase by default manages a ZooKeeper cluster for you, or you can manage it on your own and point HBase to it. To toggle HBase management of ZooKeeper, use the HBASE_MANAGES_ZK variable in ${HBASE_HOME}/conf/hbase-env.sh. This variable, which defaults to true, tells HBase whether to start/stop the ZooKeeper quorum servers alongside the rest of the servers.

需要 Zookeeper 集群。 所有节点和客户都需要能够到达所有的 Zookeeper集群。 HBase缺省管理一个Zookeeper,或者你自己管理,然后让HBase指向它。让 HBase 管理的,修改 conf/hbase-env.sh 文件,让其中的 HBASE_MANAGERS_ZK 为 true , 告诉 HBase 是否随 ZooKeeper quorum servers 的启动/关闭而进行启动/关闭。

When HBase manages the ZooKeeper cluster, you can specify ZooKeeper configuration using its canonical zoo.cfg file (see below), or just specify ZookKeeper options directly in the ${HBASE_HOME}/conf/hbase-site.xml (If new to ZooKeeper, go the path of specifying your configuration in HBase’s hbase-site.xml). Every ZooKeeper configuration option has a corresponding property in the HBase hbase-site.xml XML configuration file named hbase.zookeeper.property.OPTION. For example, the clientPortsetting in ZooKeeper can be changed by setting the hbase.zookeeper.property.clientPort property. For the full list of available properties, see ZooKeeper’s zoo.cfg. For the default values used by HBase, see ${HBASE_HOME}/conf/hbase-default.xml.

当 HBase 管理 ZooKeeper 集群, 你可以用规定的 zoo.cfg 文件来描述 Zookeeper , 或者直接在 hbase-site.xml 中描述 Zookeeper 的选项。如果是新手,直接在 hbase-site.xml 中配置比较好。每一个ZooKeeper 配置选项 在 HBase 的 hbase-site.xml 文件中都有 对应的属性,名字为 hbase.zookeeper.property.OPTION,其中 OPTION 是变化的参数,如 hbase.zookeeper.property.clientPort 属性。从 ZooKeeper 的 zoo.cfg 可以获得所有的属性。从 hbase-defalut.xml 可以获得缺省的属性。

At minimum, you should set the list of servers that you want ZooKeeper to run on using the hbase.zookeeper.quorum property. This property defaults to localhost which is not suitable for a fully distributed HBase (it binds to the local machine only and remote clients will not be able to connect). It is recommended to run a ZooKeeper quorum of 3, 5 or 7 machines, and give each ZooKeeper server around 1GB of RAM, and if possible, its own dedicated disk. For very heavily loaded clusters, run ZooKeeper servers on separate machines from the Region Servers (DataNodes and TaskTrackers).

至少,使用 hbase.zookeeper.quorum 属性设置 Zookeeper 运行的服务器。 缺省 为localhost,这和 fully distributed 模式不合,仅绑定本地机器,远程机器无法连接。建议运行 3,5或者7台机器的 Zookeeper quorum , 给每个ZooKeeper服务器1G的内存, 如果可以的话,拥有专属的磁盘 。对于负载非常重的集群,在其他的机器上运行ZooKeeper服务,不要和 Region Servers(DataNodes 和 TaskTrackers) 放在一起。

To point HBase at an existing ZooKeeper cluster, add a suitably configured zoo.cfg to the CLASSPATH. HBase will see this file and use it to figure out where ZooKeeper is. Additionally set HBASE_MANAGES_ZK in ${HBASE_HOME}/conf/hbase-env.sh to false so that HBase doesn’t mess with your ZooKeeper setup:

要把HBase指向已经存在的 Zookeeper 集群,增加一个合适的配置文件 zoo.cfg 到 CLASSPATH . HBase 将会使用这个文件来找到 ZooKeeper 的位置。 另外设置 hbase-env.sh 的 HBASE_MANAGERS_ZK 为 false ,以免HBase将 Zookeeper的设置搞乱。

# Tell HBase whether it should manage it’s own instance of Zookeeper or not.

export HBASE_MANAGES_ZK=false

As an example, to have HBase manage a ZooKeeper quorum on nodes rs{1,2,3,4,5}.example.com, bound to port 2222 (the default is 2181), use:

作为一个例子, HBase管理在节点 rs[1,2,3,4,5].example.com 上的 ZooKeeper quorum ,绑定 端口 2222 (缺省是2181):

${HBASE_HOME}/conf/hbase-env.sh:

# Tell HBase whether it should manage it’s own instance of Zookeeper or not.

export HBASE_MANAGES_ZK=true

${HBASE_HOME}/conf/hbase-site.xml:

<configuration>

<property>

<name>hbase.zookeeper.property.clientPort</name>

<value>2222</value>

<description>Property from ZooKeeper’s config zoo.cfg.

The port at which the clients will connect.

</description>

</property>

<property>

<name>hbase.zookeeper.quorum</name>

<value>rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com</value>

<description>Comma separated list of servers in the ZooKeeper Quorum.

For example, “host1.mydomain.com,host2.mydomain.com,host3.mydomain.com“.

By default this is set to localhost for local and pseudo-distributed modes

of operation. For a fully-distributed setup, this should be set to a full

list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set in hbase-env.sh

this is the list of servers which we will start/stop ZooKeeper on.

</description>

</property>

</configuration>

When HBase manages ZooKeeper, it will start/stop the ZooKeeper servers as a part of the regular start/stop scripts. If you would like to run it yourself, you can do:

当 HBase来管理Zookeeper,它会将启动/关闭Zookeeper servers作为正常启动/关闭脚本的一部分。如果你想自己来运行,可以:

${HBASE_HOME}/bin/hbase-daemons.sh {start,stop} zookeeper

Note that you can use HBase in this manner to spin up a ZooKeeper cluster, unrelated to HBase. Just make sure to set HBASE_MANAGES_ZK to false if you want it to stay up so that when HBase shuts down it doesn’t take ZooKeeper with it.

For more information about setting up a ZooKeeper cluster on your own, see the ZooKeeper Getting Started Guide. HBase currently uses ZooKeeper version 3.2.0, so any cluster setup with a 3.x.x version of ZooKeeper should work.

要得到更多的 ZooKeeper 集群的配置信息,请看 Getting Started Guide 。 HBase 当前使用 3.2.0 的版本,因此 3.x.x 版本的资料可以参考。

Of note, if you have made HDFS client configuration on your Hadoop cluster, HBase will not see this configuration unless you do one of the following:

注意,如果你 在 Hadoop集群中进行 HDFS client 的配置,HBase无法看到这些配置,除非你做下面的任何一项工作:

  • Add a pointer to your HADOOP_CONF_DIR to CLASSPATH in hbase-env.sh.
  • 在 hbase-env.sh 中增加一个路径指向 HADOOP_CONF_DIR
  • Add a copy of hdfs-site.xml (or hadoop-site.xml) to ${HBASE_HOME}/conf, or
  • 增加一个 hdfs-site.xml 或者 hadoop-site.xml 的拷贝到 ${HBASE_HOME}/conf 目录下,或者
  • if only a small set of HDFS client configurations, add them to hbase-site.xml.
  • 如果 HBase的有关配置很少,增加配置内容到 hbase-site.xml 中。

An example of such an HDFS client configuration is dfs.replication. If for example, you want to run with a replication factor of 5, hbase will create files with the default of 3 unless you do the above to make the configuration available to HBase.

例如,需要调整 dfs 的复制因子。 dfs.replication ,hbase缺省是 3 ,你想修改的话就在 HBase的配置文件中修改。

Running and Confirming Your Installation

If you are running in standalone, non-distributed mode, HBase by default uses the local filesystem.

非分布式,将使用本地文件系统

If you are running a distributed cluster you will need to start the Hadoop DFS daemons and ZooKeeper Quorum before starting HBase and stop the daemons after HBase has shut down.

分布式需要 先启动/后关闭 HDFS daemons 和 ZooKeeper Quorum 。

Start and stop the Hadoop DFS daemons by running ${HADOOP_HOME}/bin/start-dfs.sh. You can ensure it started properly by testing the put and get of files into the Hadoop filesystem. HBase does not normally use the mapreduce daemons. These do not need to be started.

启动 HDFS。

关闭 HDFS 之前必须先确保 HBase已经关闭成功。

Start up your ZooKeeper cluster.

启动 ZooKeeper 集群。

Start HBase with the following command:

使用下面的命令:

${HBASE_HOME}/bin/start-hbase.sh

Once HBase has started, enter ${HBASE_HOME}/bin/hbase shell to obtain a shell against HBase from which you can execute commands. Type ‘help’ at the shells’ prompt to get a list of commands. Test your running install by creating tables, inserting content, viewing content, and then dropping your tables. For example:

使用 HBase shell 来测试。

hbase> # Type “help” to see shell help screen

hbase> help

hbase> # To create a table named “mylittletable” with a column family of “mylittlecolumnfamily”, type

hbase> create “mylittletable”, “mylittlecolumnfamily”

hbase> # To see the schema for you just created “mylittletable” table and its single “mylittlecolumnfamily”, type

hbase> describe “mylittletable”

hbase> # To add a row whose id is “myrow”, to the column “mylittlecolumnfamily:x” with a value of ‘v’, do

hbase> put “mylittletable”, “myrow”, “mylittlecolumnfamily:x”, “v”

hbase> # To get the cell just added, do

hbase> get “mylittletable”, “myrow”

hbase> # To scan you new table, do

hbase> scan “mylittletable”

To stop HBase, exit the HBase shell and enter:

下面的命令关闭 HBase .

${HBASE_HOME}/bin/stop-hbase.sh

If you are running a distributed operation, be sure to wait until HBase has shut down completely before stopping the Hadoop daemons.

The default location for logs is ${HBASE_HOME}/logs.

HBase also puts up a UI listing vital attributes. By default its deployed on the master host at port 60010 (HBase RegionServers listen on port 60020 by default and put up an informational http server at 60030).

端口 : 60010(master) 60020(region servers)

Posted in hbase | Leave a comment