Hypertable 快速安装,仅需下载一个RPM包,零编译

简介:

本文采用 单机安装

1. Hypertable 安装

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
    					

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

 

2. Code examples

http://hypertable.com/documentation/code_examples/

2.1. PHP

设置环境变量

export PHPTHRIFT_ROOT=/opt/hypertable/current/lib/php
			

安装PHP环境

# yum install php-cli
			

建立测试文件

			
# vim lib/php/test.php
<?php
if (!isset($GLOBALS['THRIFT_ROOT']))
    $GLOBALS['THRIFT_ROOT'] = getenv('PHPTHRIFT_ROOT');

require_once dirname(__FILE__).'/ThriftClient.php';

$client = new Hypertable_ThriftClient("localhost", 38080);
$namespace = $client->namespace_open("");

echo "HQL examples\n";
print_r($client->hql_query($namespace, "show tables"));
print_r($client->hql_query($namespace, "select * from foo"));
			
			

运行测试程序

			
# php lib/php/test.php
HQL examples
Hypertable_ThriftGen_HqlResult Object
(
    [results] => Array
        (
            [0] => foo
        )

    [cells] =>
    [scanner] =>
    [mutator] =>
)
Hypertable_ThriftGen_HqlResult Object
(
    [results] =>
    [cells] => Array
        (
            [0] => Hypertable_ThriftGen_Cell Object
                (
                    [key] => Hypertable_ThriftGen_Key Object
                        (
                            [row] => 000
                            [column_family] => c1
                            [column_qualifier] =>
                            [timestamp] => 1361518099519878001
                            [revision] => 1361518099519878001
                            [flag] => 255
                        )

                    [value] => Hypertable
                )

            [1] => Hypertable_ThriftGen_Cell Object
                (
                    [key] => Hypertable_ThriftGen_Key Object
                        (
                            [row] => 000
                            [column_family] => c2
                            [column_qualifier] =>
                            [timestamp] => 1361518099519878002
                            [revision] => 1361518099519878002
                            [flag] => 255
                        )

                    [value] => is
                )

            [2] => Hypertable_ThriftGen_Cell Object
                (
                    [key] => Hypertable_ThriftGen_Key Object
                        (
                            [row] => 001
                            [column_family] => c1
                            [column_qualifier] =>
                            [timestamp] => 1361518099519878003
                            [revision] => 1361518099519878003
                            [flag] => 255
                        )

                    [value] => very
                )

            [3] => Hypertable_ThriftGen_Cell Object
                (
                    [key] => Hypertable_ThriftGen_Key Object
                        (
                            [row] => 001
                            [column_family] => c2
                            [column_qualifier] =>
                            [timestamp] => 1361518099519878004
                            [revision] => 1361518099519878004
                            [flag] => 255
                        )

                    [value] => easy
                )

        )

    [scanner] =>
    [mutator] =>
)
目录
相关文章
|
图形学
【制作100个unity游戏之27】使用unity复刻经典游戏《植物大战僵尸》,制作属于自己的植物大战僵尸随机版和杂交版3(附带项目源码)
【制作100个unity游戏之27】使用unity复刻经典游戏《植物大战僵尸》,制作属于自己的植物大战僵尸随机版和杂交版3(附带项目源码)
437 2
|
11月前
|
人工智能 弹性计算 数据可视化
解决方案|触手可及,函数计算玩转 AI 大模型 评测
解决方案|触手可及,函数计算玩转 AI 大模型 评测
169 1
|
11月前
|
安全 物联网 量子技术
量子加密技术
量子加密技术
804 1
|
11月前
|
机器学习/深度学习 人工智能 搜索推荐
人工智能与医疗健康:精准医疗的未来
【10月更文挑战第31天】本文探讨了人工智能在医疗健康领域的应用现状,特别是在精准医疗中的作用。通过医学影像分析、个性化治疗方案、慢性病管理和药物研发等方面,AI为医疗带来了革命性的变化。文章还分析了精准医疗的发展趋势和面临的挑战,展望了未来的发展方向。
|
12月前
|
机器学习/深度学习 人工智能 并行计算
CPU和GPU的区别
【10月更文挑战第14天】
|
物联网 智能硬件
智能家居系统入门:打造你的智能生活
想象一下,清晨的阳光和悠扬的音乐将你从甜美的梦乡中唤醒,窗帘自动缓缓拉开,咖啡机已经为你准备好了香浓的咖啡。这不是科幻电影的情节,而是智能家居带给我们的现实生活。本文将带你了解如何通过简单的步骤,将普通的家居环境转变为一个充满科技感的智能家庭。
277 27
|
资源调度 JavaScript 前端开发
vue2乾坤框架搭建
vue2乾坤框架搭建
|
自然语言处理 安全 测试技术
CodeGeeX高级功能
【8月更文挑战第30天】CodeGeeX高级功能
430 6
|
人工智能 机器人
Kimi仅用5秒钟就帮我抓取了5页文章素材
Kimi仅用5秒钟就帮我抓取了5页文章素材
253 3
|
JavaScript 小程序 Java
基于微信小程序的同城家政服务的设计与实现(源码+lw+部署文档+讲解等)
基于微信小程序的同城家政服务的设计与实现(源码+lw+部署文档+讲解等)
170 1