第 4 章 Hypertable

简介:

目录

4.1. Hypertable 安装
4.1.1. Hypertable standalone 单机安装
4.1.2. Hypertable on HDFS(hadoop) 安装
4.1.3. MapR
4.1.4. Ceph
4.1.5. 检验安装
4.2. Code examples
4.2.1. PHP
4.3. HQL
4.3.1. namespace 命名空间管理
4.3.2. Table 表
4.4. FAQ
4.4.1. 切换 DFS Broker

http://hypertable.org/

4.1. Hypertable 安装

4.1.1. Hypertable standalone 单机安装

过程 4.1. Hypertable standalone 安装过程

  1. 安装 Hypertable 软件包

    # cd /usr/local/src/
    # wget http://cdn.hypertable.com/packages/0.9.7.0/hypertable-0.9.7.0-linux-x86_64.rpm
    					
  2. 安装 Hypertable, 我个人比较喜欢用yum localinstall他会解决软件之间的依赖关系

    # yum localinstall hypertable-0.9.7.0-linux-x86_64.rpm
    					

    相关的软件会自动安装

    Dependencies Resolved
    
    ====================================================================================================================
     Package                       Arch          Version                  Repository                               Size
    ====================================================================================================================
    Installing:
     hypertable                    x86_64        0.9.7.0-1                /hypertable-0.9.7.0-linux-x86_64        288 M
    Installing for dependencies:
     mailcap                       noarch        2.1.31-2.el6             base                                     27 k
     perl-Bit-Vector               x86_64        7.1-2.el6                base                                    169 k
     perl-Carp-Clan                noarch        6.03-2.el6               base                                     25 k
     perl-Compress-Raw-Zlib        x86_64        1:2.020-127.el6          base                                     68 k
     perl-Compress-Zlib            x86_64        2.020-127.el6            base                                     43 k
     perl-HTML-Parser              x86_64        3.64-2.el6               base                                    109 k
     perl-HTML-Tagset              noarch        3.20-4.el6               base                                     17 k
     perl-IO-Compress-Base         x86_64        2.020-127.el6            base                                     67 k
     perl-IO-Compress-Zlib         x86_64        2.020-127.el6            base                                    134 k
     perl-IO-String                noarch        1.08-9.el6               base                                     15 k
     perl-URI                      noarch        1.40-2.el6               base                                    117 k
     perl-libwww-perl              noarch        5.833-2.el6              base                                    387 k
    
    Transaction Summary
    ====================================================================================================================
    Install      13 Package(s)
    					
  3. Hypertable 默认安装在 /opt/hypertable/0.9.7.0

    备份配置文件,

    # cd /opt/hypertable/0.9.7.0/conf
    # cp hypertable.cfg hypertable.cfg.original
    					
  4. FHS-IZE 安装

    # bin/fhsize.sh
    Setting up /var/opt/hypertable
    Setting up /etc/opt/hypertable
    fshize /opt/hypertable/0.9.7.0:  success
    					
  5. 设计 "CURRENT" 连接

    # cd /opt/hypertable
    # ln -s 0.9.7.0 current
    					
  6. 安装 notification-hook.sh 脚本.

    # cp conf/notification-hook.tmpl conf/notification-hook.sh
    # chmod o+x conf/notification-hook.sh
    					

    测试 notification-hook.sh脚本 .

    /opt/hypertable/current/conf/notification-hook.sh "Test Message" "This is a test."
    					
  7. 启动 hypertable

    # /opt/hypertable/current/bin/start-all-servers.sh local
    DFS broker: available file descriptors: 1024
    Started DFS Broker (local)
    Started Hyperspace
    Started Hypertable.Master
    /proc/sys/vm/swappiness = 60
    Started Hypertable.RangeServer
    Started ThriftBroker
    					
    					
    # /opt/hypertable/current/bin/ht shell
    
    Welcome to the hypertable command interpreter.
    For information about Hypertable, visit http://hypertable.com
    
    Type 'help' for a list of commands, or 'help shell' for a
    list of shell meta commands.
    
    hypertable>
    					
    					
  8. 测试安装是否有效

    					
    # /opt/hypertable/current/bin/ht shell
    
    Welcome to the hypertable command interpreter.
    For information about Hypertable, visit http://hypertable.com
    
    Type 'help' for a list of commands, or 'help shell' for a
    list of shell meta commands.
    
    hypertable> help
    
    USE ................ Sets the current namespace
    CREATE NAMESPACE ... Creates a new namespace
    DROP NAMESPACE ..... Removes a namespace
    EXISTS TABLE ....... Check if table exists
    CREATE TABLE ....... Creates a table
    DELETE ............. Deletes all or part of a row from a table
    DESCRIBE TABLE ..... Displays a table's schema
    DROP TABLE ......... Removes a table
    RENAME TABLE ....... Renames a table
    DUMP TABLE ......... Create efficient backup file
    ALTER TABLE ........ Add/remove column family from existing table
    INSERT ............. Inserts data into a table
    LOAD DATA INFILE ... Loads data from a TSV input file into a table
    SELECT ............. Selects (and display) cells from a table
    SHOW CREATE TABLE .. Displays CREATE TABLE command used to create table
    SHOW TABLES ........ Displays only the list of tables in the current namespace
    GET LISTING ........ Displays the list of tables and namespace in the current namespace
    
    Statements must be terminated with ';'.  For more information on
    a specific statement, type 'help <statement>', where <statement> is from
    the preceding list.
    
    hypertable>quit
    					
    					
  9. 停止 hypertable

    运行下列命令停止 Hypertable

    $ /opt/hypertable/current/bin/stop-servers.sh
    					

4.1.2. Hypertable on HDFS(hadoop) 安装

Hadoop - HDFS 安装指南

过程 4.2. Hypertable on HDFS

  1. 创建工作目录

    $ hadoop fs -mkdir /hypertable
    $ hadoop fs -chmod 777 /hypertable
    					
  2. 安装 Java 运行环境

    yum install java-1.7.0-openjdk
    yum localinstall http://ftp.cuhk.edu.hk/pub/packages/apache.org/hadoop/common/hadoop-1.1.2/hadoop-1.1.2-1.x86_64.rpm
    					
  3. 修改 jrun bug

    cp /opt/hypertable/current/bin/jrun /opt/hypertable/current/bin/jrun.old
    
    vim /opt/hypertable/current/bin/jrun
    #HT_JAR=`ls -1 /opt/hypertable/doug/current/lib/java/*.jar | grep "hypertable-[^-]*.jar" | awk 'BEGIN {FS="/"} {print $NF}'`
    HT_JAR=`ls -1 /opt/hypertable/current/lib/java/*.jar | grep "hypertable-[^-]*.jar" | awk 'BEGIN {FS="/"} {print $NF}'`
    					
     export JAVA_HOME=/usr
     export HADOOP_HOME=/usr
     export HYPERTABLE_HOME=/opt/hypertable/current
    					
  4. hypertable.cfg

    # cat conf/hypertable.cfg
    #
    # hypertable.cfg
    #
    
    # HDFS Broker
    #HdfsBroker.Hadoop.ConfDir=/etc/hadoop/conf
    HdfsBroker.Hadoop.ConfDir=/etc/hadoop
    
    # Ceph Broker
    CephBroker.MonAddr=192.168.6.2:6789
    
    # Local Broker
    DfsBroker.Local.Root=fs/local
    
    # DFS Broker - for clients
    DfsBroker.Port=38030
    
    # Hyperspace
    Hyperspace.Replica.Host=localhost
    Hyperspace.Replica.Port=38040
    Hyperspace.Replica.Dir=hyperspace
    
    # Hypertable.Master
    #Hypertable.Master.Host=localhost
    Hypertable.Master.Port=38050
    
    # Hypertable.RangeServer
    Hypertable.RangeServer.Port=38060
    
    Hyperspace.KeepAlive.Interval=30000
    Hyperspace.Lease.Interval=1000000
    Hyperspace.GracePeriod=200000
    
    # ThriftBroker
    ThriftBroker.Port=38080
    					

    Hadoop 配置文件 /etc/hadoop/core-site.xml

    					
    # cat /etc/hadoop/core-site.xml
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
    
    <!-- Put site-specific property overrides in this file. -->
    
    <configuration>
        <property>
             <name>fs.default.name</name>
             <value>hdfs://namenode.example.com:9000</value>
        </property>
        <property>
             <name>hadoop.tmp.dir</name>
             <value>/var/tmp/hadoop</value>
        </property>
    </configuration>
    					
    					

    Hadoop 配置文件 /etc/hadoop/hdfs-site.xml

    					
    # cat /etc/hadoop/hdfs-site.xml
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
    
    <!-- Put site-specific property overrides in this file. -->
    
    <configuration>
        <property>
            <name>dfs.name.dir</name>
            <value>/var/hadoop/name1</value>
            <description>  </description>
        </property>
        <property>
            <name>dfs.data.dir</name>
            <value>/var/hadoop/hdfs/data1</value>
            <description> </description>
        </property>
        <property>
            <name>dfs.replication</name>
            <value>2</value>
        </property>
    </configuration>
    					
    					
  5. 启动 dfsbroker

    # /opt/hypertable/current/bin/set-hadoop-distro.sh cdh4
    Hypertable successfully configured for Hadoop cdh4
    					
    # /opt/hypertable/current/bin/start-dfsbroker.sh hadoop
    DFS broker: available file descriptors: 1024
    Started DFS Broker (hadoop)
    					

    查看启动日志

    # tail -f /opt/hypertable/current/log/DfsBroker.hadoop.log
    log4j:WARN No appenders could be found for logger (org.apache.hadoop.conf.Configuration).
    log4j:WARN Please initialize the log4j system properly.
    HdfsBroker.dfs.client.read.shortcircuit=false
    HdfsBroker.dfs.replication=2
    HdfsBroker.Server.fs.default.name=hdfs://namenode.example.com:9000
    Apr 23, 2013 6:43:18 PM org.hypertable.AsyncComm.IOHandler DeliverEvent
    INFO: [/192.168.6.25:53556 ; Tue Apr 23 18:43:18 HKT 2013] Connection Established
    Apr 23, 2013 6:43:18 PM org.hypertable.DfsBroker.hadoop.ConnectionHandler handle
    INFO: [/192.168.6.25:53556 ; Tue Apr 23 18:43:18 HKT 2013] Disconnect - COMM broken connection : Closing all open handles from /192.168.6.25:53556
    Closed 0 input streams and 0 output streams for client connection /192.168.6.25:53556
    					

4.1.3. MapR

4.1.4. Ceph

修改 CephBroker.MonAddr 对应的服务器与端口号即可

# cat hypertable.cfg
#
# hypertable.cfg
#

# HDFS Broker
HdfsBroker.Hadoop.ConfDir=/etc/hadoop/conf

# Ceph Broker
CephBroker.MonAddr=192.168.6.2:6789

# Local Broker
DfsBroker.Local.Root=fs/local

# DFS Broker - for clients
DfsBroker.Port=38030

# Hyperspace
Hyperspace.Replica.Host=localhost
Hyperspace.Replica.Port=38040
Hyperspace.Replica.Dir=hyperspace

# Hypertable.Master
Hypertable.Master.Port=38050

# Hypertable.RangeServer
Hypertable.RangeServer.Port=38060

Hyperspace.KeepAlive.Interval=30000
Hyperspace.Lease.Interval=1000000
Hyperspace.GracePeriod=200000

# ThriftBroker
ThriftBroker.Port=38080
			

启动 dfsbroker

# /opt/hypertable/current/bin/start-dfsbroker.sh ceph
			

4.1.5. 检验安装

创建一个表

			
# echo "USE '/'; CREATE TABLE foo ( c1, c2 ); GET LISTING;" \
>     | /opt/hypertable/current/bin/ht shell --batch
foo
sys	(namespace)
tmp	(namespace)
			
			

插入一些数据

			
# echo "USE '/'; INSERT INTO foo VALUES('001', 'c1', 'very'), \
>     ('000', 'c1', 'Hypertable'), ('001', 'c2', 'easy'), ('000', 'c2', 'is');" \
>     | /opt/hypertable/current/bin/ht shell --batch
			
			

查询数据

			
# echo "USE '/'; SELECT * FROM foo;" \
>     | /opt/hypertable/current/bin/ht shell --batch
000	c1	Hypertable
000	c2	is
001	c1	very
001	c2	easy
			
			

如果你想清楚所有表运行下面命令

$ /opt/hypertable/current/bin/stop-servers.sh
$ /opt/hypertable/current/bin/clean-database.sh
			





原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

目录
相关文章
|
6天前
|
NoSQL Cloud Native Redis
Redis核心开发者的新征程:阿里云与Valkey社区的技术融合与创新
阿里云瑶池数据库团队后续将持续参与Valkey社区,如过往在Redis社区一样耕耘,为开源社区作出持续贡献。
Redis核心开发者的新征程:阿里云与Valkey社区的技术融合与创新
|
6天前
|
关系型数据库 分布式数据库 数据库
PolarDB闪电助攻,《香肠派对》百亿好友关系实现毫秒级查询
PolarDB分布式版助力《香肠派对》实现百亿好友关系20万QPS的毫秒级查询。
PolarDB闪电助攻,《香肠派对》百亿好友关系实现毫秒级查询
|
7天前
|
消息中间件 Cloud Native Serverless
RocketMQ 事件驱动:云时代的事件驱动有啥不同?
本文深入探讨了云时代 EDA 的新内涵及它在云时代再次流行的主要驱动力,包括技术驱动力和商业驱动力,随后重点介绍了 RocketMQ 5.0 推出的子产品 EventBridge,并通过几个云时代事件驱动的典型案例,进一步叙述了云时代事件驱动的常见场景和最佳实践。
115053 1
|
8天前
|
弹性计算 安全 API
访问控制(RAM)|云上安全使用AccessKey的最佳实践
集中管控AK/SK的生命周期,可以极大降低AK/SK管理和使用成本,同时通过加密和轮转的方式,保证AK/SK的安全使用,本次分享为您介绍产品原理,以及具体的使用步骤。
101817 2
|
7天前
|
自然语言处理 Cloud Native Serverless
通义灵码牵手阿里云函数计算 FC ,打造智能编码新体验
近日,通义灵码正式进驻函数计算 FC WebIDE,让使用函数计算产品的开发者在其熟悉的云端集成开发环境中,无需再次登录即可使用通义灵码的智能编程能力,实现开发效率与代码质量的双重提升。
95393 2
Doodle Jump — 使用Flutter&Flame开发游戏真不错!
用Flutter&Flame开发游戏是一种什么体验?最近网上冲浪的时候,我偶然发现了一个国外的游戏网站,类似于国内的4399。在浏览时,我遇到了一款经典的小游戏:Doodle Jump...
112734 12
|
12天前
|
SQL 存储 JSON
Flink+Paimon+Hologres 构建实时湖仓数据分析
本文整理自阿里云高级专家喻良,在 Flink Forward Asia 2023 主会场的分享。
71338 1
Flink+Paimon+Hologres 构建实时湖仓数据分析
|
16天前
|
弹性计算 运维 安全
访问控制(RAM)|云上程序使用临时凭证的最佳实践
STS临时访问凭证是阿里云提供的一种临时访问权限管理服务,通过STS获取可以自定义时效和访问权限的临时身份凭证,减少长期访问密钥(AccessKey)泄露的风险。本文将为您介绍产品原理,以及具体的使用步骤。
151046 4
|
15天前
|
监控 负载均衡 Java
深入探究Java微服务架构:Spring Cloud概论
**摘要:** 本文深入探讨了Java微服务架构中的Spring Cloud,解释了微服务架构如何解决传统单体架构的局限性,如松耦合、独立部署、可伸缩性和容错性。Spring Cloud作为一个基于Spring Boot的开源框架,提供了服务注册与发现、负载均衡、断路器、配置中心、API网关等组件,简化了微服务的开发、部署和管理。文章详细介绍了Spring Cloud的核心模块,如Eureka、Ribbon、Hystrix、Config、Zuul和Sleuth,并通过一个电商微服务系统的实战案例展示了如何使用Spring Cloud构建微服务应用。
103520 9
|
15天前
|
Java 数据处理 调度
更高效准确的数据库内部任务调度实践,阿里云数据库SelectDB 内核 Apache Doris 内置 Job Scheduler 的实现与应用
Apache Doris 2.1 引入了内置的 Job Scheduler,旨在解决依赖外部调度系统的问题,提供秒级精确的定时任务管理。

热门文章

最新文章