Centos6.5里安装Hbase(伪分布式)
2015-08-24 21:16
513 查看
首先我们到官方网站下载Hbase,而我使用的版本是hbase-0.94.27.tar.gz
解压下来:
寻找java安装路径
我们找到java的安装路径
所以hbase的配置,如下:
vim hbase-env.sh
启动:
hbase已经启动了:
View Code
参考:
http://hbase.apache.org/book.html http://hbase.apache.org/ http://blog.csdn.net/zwhfyy/article/details/8349788 http://niuzhenxin.iteye.com/blog/1447769 http://abloz.com/hbase/book.html http://www.paul4llen.com/installing-apache-hbase-on-centos-6/ http://cn.soulmachine.me/blog/20140208/ http://blog.csdn.net/wuwenxiang91322/article/details/44684655 http://www.oschina.net/question/54100_24054 http://www.cnblogs.com/heyCoding/archive/2012/11/09/2762334.html http://www.cnblogs.com/zhenjing/p/hbase_example.html http://www.cnblogs.com/panfeng412/archive/2011/08/14/2137984.html http://www.cnblogs.com/caca/p/centos_hadoop_install.html http://www.cnblogs.com/elaron/archive/2013/01/05/2846803.html http://www.cnblogs.com/Dreama/articles/2219190.html
解压下来:
tar zxvf hbase-0.94.27.tar.gz
寻找java安装路径
[root@localhost conf]# which java /usr/bin/java
我们找到java的安装路径
/usr/bin/java
所以hbase的配置,如下:
vim hbase-env.sh
export JAVA_HOME=/usr
启动:
[root@localhost bin]# ./start-hbase.sh starting master, logging to /root/hbase_soft/hbase-0.94.27/bin/../logs/hbase-root-master-localhost.localdomain.out
hbase已经启动了:
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; import org.eclipse.jdt.internal.core.BatchOperation; public class HBaseDBDao { //定义配置对象HBaseConfiguration static Configuration conf =null; static { // Configuration configuration = new Configuration(); // configuration.set("hbase.zookeeper.property.clientPort","2181"); // configuration.set("hbase.zookeeper.quorum", "192.168.1.112"); // configuration.set("hbase.master", "192.168.1.112:60000"); // cfg = new HBaseConfiguration(configuration); conf = HBaseConfiguration.create(); conf.set("hbase.zookeeper.property.clientPort","2181"); conf.set("hbase.zookeeper.quorum", "192.168.1.112"); // conf.set("hbase.master", "192.168.1.112:60000"); } //创建一张表,指定表名,列族 public static void createTable(String tableName,String columnFarily)throws Exception{ HBaseAdmin admin = new HBaseAdmin(conf); if(admin.tableExists(tableName)){ System.out.println(tableName+"不存在!"); System.exit(0); }else{ HTableDescriptor tableDesc = new HTableDescriptor(tableName); tableDesc.addFamily(new HColumnDescriptor(columnFarily+":")); System.out.println("创建表成功!"); } } //添加数据,通过HTable。和BatchUpdate为已经存在的表添加数据data // public static void addData(String tableName,String row,String columnFamily,String column,String data)throws Exception{ // HTable table = new HTable(cfg,tableName); // Put update = new Put(row); // update.put(columnFamily+":"+column, data.getBytes()); // table.commit(update); // System.out.println("添加成功!"); // } //显示所有数据,通过HTable Scan类获取已有表的信息 public static void getAllData(String tableName)throws Exception{ HTable table = new HTable(conf,tableName); Scan scan = new Scan(); ResultScanner rs = table.getScanner(scan); for(Result r:rs){ for(KeyValue kv:r.raw()){ System.out.println(new String(kv.getKey())+new String(kv.getValue())); } } } //测试函数 public static void main(String[] args){ try{ String tableName = "student"; HBaseDBDao.createTable(tableName, "c1"); // HBaseDBDao.addData(tableName, "row1", "c1", "1", "this is row 1 column c1:c1"); HBaseDBDao.getAllData(tableName); }catch(Exception e){ e.printStackTrace(); } } }
View Code
参考:
http://hbase.apache.org/book.html http://hbase.apache.org/ http://blog.csdn.net/zwhfyy/article/details/8349788 http://niuzhenxin.iteye.com/blog/1447769 http://abloz.com/hbase/book.html http://www.paul4llen.com/installing-apache-hbase-on-centos-6/ http://cn.soulmachine.me/blog/20140208/ http://blog.csdn.net/wuwenxiang91322/article/details/44684655 http://www.oschina.net/question/54100_24054 http://www.cnblogs.com/heyCoding/archive/2012/11/09/2762334.html http://www.cnblogs.com/zhenjing/p/hbase_example.html http://www.cnblogs.com/panfeng412/archive/2011/08/14/2137984.html http://www.cnblogs.com/caca/p/centos_hadoop_install.html http://www.cnblogs.com/elaron/archive/2013/01/05/2846803.html http://www.cnblogs.com/Dreama/articles/2219190.html
相关文章推荐
- 解决 RHEL 7/ CentOS 7/Fedora 出现Unit iptables.service failed to load
- Linux命令之目录管理类命令:mkdir, rmdir, tree, dirname, basename
- Linux系统启动流程
- 【Linux命令详解】2、文件和目录操作管理―(pwd、cd、ls、mkdir、rmdir、tree)
- RHEL6.6搭建CentOS6.6 yum源
- Linux SSH远程文件/目录传输命令scp
- Linux格式化硬盘 常用命令小记
- 玩转linux第三天通配符、组合键、IO重定向及管道详解(四)
- linux下安装mysql数据库
- CentOS7.1修改开机默认运行级别
- linux下svn命令大全
- ubuntu9.04 gedit 乱码与修改系统编码
- CentOS 6下HBase安装与使用
- Linux学习
- 玩转linux第三天之cp,mv ,rm, wc ,cut ,sort,uniq命令详解(三)
- 用Linux命令行获取本机外网IP地址
- 玩转Linux第三天cat,tac,more,less ,tail,head touch命令详解(二)
- 汉高澳大利亚sinox为什么不能下载源代码,因为sinox执行unix/linux/windows规划
- Linux系统内存管理及相关操作函数
- linux中文件描述符fd和文件指针flip的理解