Hbase配置手册

Hbase配置手册 - 奔跑的羚羊 - ITeye技术网站

Hbase配置手册

1)下载hbase

解压到每台服务器的/data/soft

解压
Java代码  收藏代码
  1. root@master:/data/soft# tar zxvf hbase-0.90.0.tar.gz  


建立软连

Java代码  收藏代码
  1. root@master:/data/soft# ln -s hbase-0.90.0 hbase  




2)配置hbase


前提是安装完成hadoop,默认在namenode上进行

1.修改conf/hbase-env.sh,添加jdk支持


Java代码  收藏代码
  1. export JAVA_HOME=/usr/local/jdk  
  2. export HBASE_MANAGES_ZK=true  
  3. export HBASE_LOG_DIR=/data/logs/hbase  




2. 修改conf/hbase-site.xml,



 

Xml代码  收藏代码
  1. <property>  
  2.   <name>hbase.rootdir</name>  
  3.   <value>hdfs://master:9000/hbase</value>  
  4. </property>  
  5. <property>  
  6.   <name>hbase.cluster.distributed</name>  
  7.   <value>true</value>  
  8. </property>  
  9. <property>   
  10.   <name>hbase.master</name>   
  11.   <value>hdfs://master:60000</value>   
  12. </property>   
  13.   
  14. <property>      
  15.       <name>hbase.zookeeper.quorum</name>      
  16.       <value>slave-001,slave-002,slave-003</value>      
  17.       <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>    
  18. </property>  
  19. <property>      
  20.       <name>hbase.zookeeper.property.dataDir</name>      
  21.       <value>/data/work/zookeeper</value>      
  22.       <description>Property from ZooKeeper's config zoo.cfg.    The directory where the snapshot is stored.    </description>    
  23. </property>  


hbase.rootdir设置hbase在hdfs上的目录,主机名为hdfs的namenode节点所在的主机

hbase.cluster.distributed设置为true,表明是完全分布式的hbase集群

hbase.master设置hbase的master主机名和端口

hbase.zookeeper.quorum设置zookeeper的主机,建议使用单数





3.修改hadoop的目录下的conf/hdfs-site.xml


Xml代码  收藏代码
  1. <property>  
  2.         <name>dfs.datanode.max.xcievers</name>  
  3.         <value>4096</value>  
  4.       </property>  




4.复制hadoop的jar到hbase的lib目录下,删除原来的lib下的hadoop.jar

原来的hadoop-core-0.20-append-r1056497.jar

新的hadoop-0.20.2-core.jar



5.修改conf/regionservers

将所有的datanode添加到这个文件,类似与hadoop中slaves文件



6.拷贝hbase到所有的节点



3)启动hbase


Java代码  收藏代码
  1. $Snbsp;./bin/start-hbase.sh  




4)hbase自带的web界面

http://master:60010/





5)测试

1.登录hbase客户端


Java代码  收藏代码
  1. ./bin/hbase shell  


2.新建数据表,并插入3条记录


Java代码  收藏代码
  1. hbase(main):003:0> create 'test''cf'  
  2. 0 row(s) in 1.2200 seconds  
  3. hbase(main):003:0> list 'table'  
  4. test  
  5. 1 row(s) in 0.0550 seconds  
  6. hbase(main):004:0> put 'test''row1''cf:a''value1'  
  7. 0 row(s) in 0.0560 seconds  
  8. hbase(main):005:0> put 'test''row2''cf:b''value2'  
  9. 0 row(s) in 0.0370 seconds  
  10. hbase(main):006:0> put 'test''row3''cf:c''value3'  
  11. 0 row(s) in 0.0450 seconds  


3.查看插入的数据


Java代码  收藏代码
  1. hbase(main):007:0> scan 'test'  
  2. ROW        COLUMN+CELL  
  3. row1       column=cf:a, timestamp=1288380727188, value=value1  
  4. row2       column=cf:b, timestamp=1288380738440, value=value2  
  5. row3       column=cf:c, timestamp=1288380747365, value=value3  
  6. 3 row(s) in 0.0590 seconds  


4.读取单条记录


Java代码  收藏代码
  1. hbase(main):008:0> get 'test''row1'  
  2. COLUMN      CELL  
  3. cf:a        timestamp=1288380727188, value=value1  
  4. 1 row(s) in 0.0400 seconds  


5.停用并删除数据表


Java代码  收藏代码
  1. hbase(main):012:0> disable 'test'  
  2. 0 row(s) in 1.0930 seconds  
  3. hbase(main):013:0> drop 'test'  
  4. 0 row(s) in 0.0770 seconds   


6.退出


Java代码  收藏代码
  1. hbase(main):014:0> exit  
原文地址:https://www.cnblogs.com/lexus/p/2388937.html