澳门美高梅手机网站大数额学习种类之二 —– HBase环境搭建(单机)

Peer Awareness 节点感知(高可用)

Eureka can be made even more resilient and available by running multiple
instances and asking them to register with each other. In fact, this is
the default behaviour, so all you need to do to make it work is add a
valid serviceUrl to a peer, e.g.

Eureka服务器通过跑三个实例并须求登记相互,能够变得更具弹性。实际上,那是Eureka的暗中同意使用方法,那么您必要给节点参加使得的serviceUrl使其健康干活。例如:

application.yml (Two Peer Aware Eureka Servers)

---
spring:
  profiles: peer1
eureka:
  instance:
    hostname: peer1
  client:
    serviceUrl:
      defaultZone: http://peer2/eureka/
---
spring:
  profiles: peer2
eureka:
  instance:
    hostname: peer2
  client:
    serviceUrl:
      defaultZone: http://peer1/eureka/

In this example we have a YAML file that can be used to run the same
server on 2 hosts (peer1 and peer2), by running it in different Spring
profiles. You could use this configuration to test the peer awareness on
a single host (there’s not much value in doing that in production) by
manipulating /etc/hosts to resolve the host names. In fact, the
eureka.instance.hostname is not needed if you are running on a machine
that knows its own hostname (it is looked up using java.net.InetAddress
by default).

透过运营不相同的Spring
profile,本例中的YAML配置文件是在不一样主机上的相同服务器(节点1和节点2)。开发职员通过操纵/etc/hosts伪造127.0.0.1的主机名,能够在同一主机上测试(那样做生产环境上从未有过价值)。实际上,eureka.instance.hostname这几个布局项在生产环境尚未用(PC会查询java.net.InetAddres获取到)。

You can add multiple peers to a system, and as long as they are all
connected to each other by at least one edge, they will synchronize the
registrations amongst themselves. If the peers are physically separated
(inside a data centre or between multiple data centres) then the system
can in principle survive split-brain type failures.

比方节点之间相互连接,开发职员能够为系统添加多少个节点,它们中间会同步注册音讯。假如节点是物理分离的(在一个或三个数据基本),那么系统标准化上得以无视split-brain型故障而运作。

引言

在上一篇中搭建了Hadoop的单机环境,这一篇则搭建HBase的单机环境

文中例子笔者做了一些测试在:http://git.oschina.net/dreamingodd/spring-cloud-preparation

HBase shell 使用

HBase运营现在
输入:
HBase shell
进入hbase
然后输入list 查询有何样表
因为HBase是列式存款和储蓄结构,所以在建表方面和观念的关系型数据库不等同
新建二个用户表 t_user
添加多个列族 st1 和 st2

create 't_user','st1','st2'

给那张表添加数据
添加 主键 、列 和值

put 't_user','1001','st1:age','18'

put 't_user','1001','st2:name','zhangsan'

接下来 查询该表数据

scan 't_user'

查看表结构

describe 't_user'

去除记录

delete't_user','1001','st1:age'

删除表
删去表首先要屏蔽该表

disable 't_user'

删除

drop 't_user'

澳门美高梅手机网站 1
澳门美高梅手机网站 2

High Availability, Zones and Regions 高可用,地区和地区

The Eureka server does not have a backend store, but the service
instances in the registry all have to send heartbeats to keep their
registrations up to date (so this can be done in memory). Clients also
have an in-memory cache of eureka registrations (so they don’t have to
go to the registry for every single request to a service).

Eureka服务器并不在后端存款和储蓄,但注册机中的服务实例都不能够不用心跳消息有限支撑他们的新颖的挂号情况(也正是说能够在内部存款和储蓄器完毕)。客户端同样也有一份注册新闻缓存存在内部存款和储蓄器里。

By default every Eureka server is also a Eureka client and requires (at
least one) service UOdysseyL to locate a peer. If you don’t provide it the
service will run and work, but it will shower your logs with a lot of
noise about not being able to register with the peer.
暗许情况下,每3个Eureka服务器也时3个Eureka客户端,同样供给(至少二个)service
ULX570L来恒定节点。固然就算开发职员不提供还是能跑,可是会大方打出不可能登记的废品log。

See also below for details of Ribbon support on the client side for
Zones and Regions.

3.2.1 环境安排

编辑 /etc/profile 文件
输入:

export HBASE_HOME=/home/hbase/hbase-1.2.6
export PATH=.:${JAVA_HOME}/bin:${HADOOP_HOME}/bin:${HBASE_HOME}/bin:$PATH

澳门美高梅手机网站 3
输入:

source  /etc/profile

使配置生效
输入

hbase version 

翻看版本
澳门美高梅手机网站 4

瑟维斯 Discovery: Eureka Server 服务意识:Eureka服务端

3,下载地址

官网地址:
JDK:
http://www.oracle.com/technetwork/java/javase/downloads

Hadopp:
http://www.apache.org/dyn/closer.cgi/hadoop/common
HBase:
http://mirror.bit.edu.cn/apache/hbase/

百度云:
链接:https://pan.baidu.com/s/1jIemnA2 密码:3ykr

How to Include Eureka Server 如何成立Eureka服务端

To include Eureka Server in your project use the starter with group
org.springframework.cloud and artifact id
spring-cloud-starter-eureka-server. See the Spring Cloud Project page
for details on setting up your build system with the current Spring
Cloud Release Train.

运用Eureka服务需求引入org.springframework.cloud的spring-cloud-starter-eureka-server项目。能够参照http://projects.spring.io/spring-cloud/来创建你的第一个Eureka服务。

2,配置选拔

JDK:1.8 (jdk-8u144-linux-x64.tar.gz)
Hadoop:2.8.2 (hadoop-2.8.2.tar.gz)
HBase:1.6.2 (hbase-1.2.6-bin.tar.gz)

Prefer IP Address 使用IP

In some cases, it is preferable for Eureka to advertise the IP Adresses
of services rather than the hostname. Set
eureka.instance.preferIpAddress to true and when the application
registers with eureka, it will use its IP Address rather than its
hostname.

有些景况下,使用IP比hostname好。eureka.instance.preferIpAddress=true能够形成那一点。

 

dreamingodd原创作品,如转发请注脚出处。

叁 、HBase环境设置

How to Run a Eureka Server 如何运维Eureka服务端

@SpringBootApplication
@EnableEurekaServer
public class Application {
    public static void main(String[] args) {
        new SpringApplicationBuilder(Application.class).web(true).run(args);
    }
}

The server has a home page with a UI, and HTTP API endpoints per the
normal Eureka functionality under /eureka/*.

Eureka服务端有壹个暗中同意的UI主页,种种Eureka服务端你都有多少个HTTP
API节点在/eureka/*

Eureka background reading: see flux capacitor and google group
discussion.

想理解越多Eureka背景知识,推荐阅读 https://github.com/cfregly/fluxcapacitor/wiki/NetflixOSS-FAQ#eureka-service-discovery-load-balancerhttps://groups.google.com/forum/?fromgroups#!topic/eureka_netflix/g3p2r7gHnN0

TIP Due to Gradle’s dependency resolution rules and the lack of a
parent bom feature, simply depending on
spring-cloud-starter-eureka-server can cause failures on application
startup. To remedy this the Spring Boot Gradle plugin must be added and
the Spring cloud starter parent bom must be imported like so:

gradle引入:

build.gradle

buildscript {
  dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE")
  }
}
apply plugin: "spring-boot"
dependencyManagement {
  imports {
    mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RELEASE"
  }
}

条件准备

 

3.2.2.1 修改hbase-env.sh

编排 hbase-env.sh 文件,添加以下配置

export JAVA_HOME=/home/java/jdk1.8
export HADOOP_HOME=/home/hadoop/hadoop2.8
export HBASE_HOME=/home/hbase/hbase-1.2.6
export HBASE_CLASSPATH=/home/hadoop/hadoop2.8/etc/hadoop
export HBASE_PID_DIR=/root/hbase/pids
export HBASE_MANAGES_ZK=false

澳门美高梅手机网站 5
声明:配置的不二法门以祥和的为准。HBASE_MANAGES_ZK=false
是不启用HBase自带的Zookeeper集群。

Standalone Mode 单机格局

The combination of the two caches (client and server) and the heartbeats
make a standalone Eureka server fairly resilient to failure, as long as
there is some sort of monitor or elastic runtime keeping it alive (e.g.
Cloud Foundry). In standalone mode, you might prefer to switch off the
client side behaviour, so it doesn’t keep trying and failing to reach
its peers. Example:

假设存在某种监察和控制或弹性运维时刻来使服务存活(如Cloud
Foundry),七个缓存和心跳协议的构成就能让单机的Eureka服务器对故障保有分外的弹性。单机方式下,开发职员或许更爱好关闭服务器的客户端表现,那样服务端就不必一贯尝试败北地走访节点。

application.yml (Standalone Eureka Server)

server:
  port: 8761
eureka:
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

Notice that the serviceUrl is pointing to the same host as the local
instance.

留意serviceUrl跟地面实例是如出一辙的。

2,关闭防火墙

关门防火墙,方便外部访问。
CentOS 7版本以下输入:
闭馆防火墙
service iptables stop
CentOS 7 以上的本子输入:
systemctl stop firewalld.service

合法文书档案地址为:http://cloud.spring.io/spring-cloud-static/Dalston.SR3/#spring-cloud-eureka-server

1,下载HBase

将下载下来的HBase的安顿文件举行解压
在linux上输入:

 tar  -xvf   hbase-1.2.6-bin.tar.gz

然后移动到/opt/hbase 里面
输入

mv  hbase-1.2.6  /home/hbase

2,HBase环境安排

贰 、服务器的相干配置

在配置Hadoop在此之前,应该先做一下配置

1,服务器选拔

Ali云服务器:入门型(按量付费)
操作系统:linux CentOS 6.8
Cpu:1核
内存:1G
硬盘:40G

1,更改主机名

第二更改主机名,目标是为了方便管理。
输入:
hostname
查看本机的称号
接下来输入:

vim /etc/sysconfig/network

修改主机名称
将HOSTNAME 的称号改变为您想要设置的称呼
澳门美高梅手机网站 6
:主机名称改成之后,要重启(reboot)才会生效。

输入

vim /etc/hosts

添加 主机IP 和呼应的主机名称,做映射。

澳门美高梅手机网站 7
注:在配置文件中选拔主机名的话,那个映射必须做!

3.2.2.2 修改 hbase-site.xml

编纂hbase-site.xml 文件,在丰硕如下配置

<!-- 存储目录 -->
<property>  
 <name>hbase.rootdir</name>  
 <value>hdfs://test1:9000/hbase</value>  
 <description>The directory shared byregion servers.</description>  
</property>  
<!-- hbase的端口 -->
<property>  
 <name>hbase.zookeeper.property.clientPort</name>  
 <value>2181</value>  
 <description>Property from ZooKeeper'sconfig zoo.cfg. The port at which the clients will connect.  
 </description>  
</property>  
<!--  超时时间 -->
<property>  
 <name>zookeeper.session.timeout</name>  
 <value>120000</value>  
</property>  
<!--  zookeeper 集群配置。如果是集群,则添加其它的主机地址 -->
<property>  
 <name>hbase.zookeeper.quorum</name>  
 <value>test1</value>  
</property>  
<property>  
 <name>hbase.tmp.dir</name>  
 <value>/root/hbase/tmp</value>  
</property>  
<!-- false是单机模式,true是分布式模式  -->
<property>  
 <name>hbase.cluster.distributed</name>  
 <value>false</value>  
</property>

澳门美高梅手机网站 8
证实:hbase.rootdir:这一个目录是region server的共享目录,用来持久化Hbase
。hbase.cluster.distributed
:Hbase的运维形式。false是单机情势,true是分布式情势。若为false,Hbase和Zookeeper会运营在同一个JVM里面。

4,HBase启动

在功成名就运转Hadoop之后
切换到HBase目录下
cd /home/hbase/hbase-1.2.6/bin
输入:
./start-hbase.sh
澳门美高梅手机网站 9

在浏览器输入:
http://39.108.208.105:16010/
澳门美高梅手机网站 10

体现那个界面则成功!

3.2.2 修改配置文件

在 root目录下新建文件夹

mkdir  /root/hbase  
mkdir  /root/hbase/tmp  
mkdir  /root/hbase/pids

澳门美高梅手机网站 11
切换到 /home/hbase/hbase-1.2.6/conf 下

3,时间设置

输入:
date
翻看服务器时间是还是不是相同,若差异则变动
改变时间命令

date -s ‘MMDDhhmmYYYY.ss’

发表评论

电子邮件地址不会被公开。 必填项已用*标注