最近近公司被安排做hbase开发,太久没做今天记录下过程

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HBaseAdmin;

public class getHbaseConfiguration {

private static Configuration conf = null;
public getHbaseConfiguration()
{

}

//这里必须预先处理化不然不然可能会出现未初始化conf就开始使用的问题
static
{
if(null == conf)
{
conf = HBaseConfiguration.create();
Path path = new Path("hbase-site.xml");
conf.addResource(path);
}
// return conf;
}
public void createTable(String tableName) throws IOException
{

HBaseAdmin admin = new HBaseAdmin(conf);
if(admin.tableExists(tableName))
{
System.out.println("Exists tables");
}
HTableDescriptor hTabeDescriptor = new HTableDescriptor("tableName");
hTabeDescriptor.addFamily(new HColumnDescriptor("cf1"));
admin.createTable(hTabeDescriptor);

}
public static void main(String[] args) {
//new getHbaseConfiguration().getInstance();
try {
new getHbaseConfiguration().createTable("test_1");
} catch (IOException e) {
e.printStackTrace();
}
}
}

被初始化的conf要求,可以从集群中hbase目录下conf拷贝,记得集群先hbase shell ---list测试集群可用否

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://CDHProject1:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.tmp.dir</name>
<value>/home/hadoop/bigdata/softs/hbase-1.0.0-cdh5.5.5/data/tmp</value>
</property>
<!-- zookeeper- -->
<property>
<name>hbase.zookeeper.quorum</name>
<value>CDHProject1,CDHProject2,CDHProject3</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
</configuration>

hbase连接linux开发过程的更多相关文章

  1. xshell连接linux,切换焦点,自动执行ctrl+c

    这几天发现 xshell 连接 linux 的时候,无缘无故的执行了 ctrl+c,导致 执行界面 终端,比方说 ,hbase shell 执行窗口命令 ,每次切换 窗口焦点之后,就终止了.百度后 发 ...

  2. Windows远程连接Linux

    目录 xrdp方式 vnc方式 xrdp方式 ----------------------------------------------------------------------------- ...

  3. 1、linux网络服务实验 用PuTTY连接Linux

    这个是大三下学期的Linux网络服务配置详解时,感觉老师上得简单,就整理下,岭南师范学院师弟妹有福,如果是蔡老师交的话,可以拿来预习,复习. 一.用PuTTY连接Linux ①.装有redhat系统的 ...

  4. 第2章 Linux系统安装(3)_SSH连接Linux工具:SecureCRT和WinSCP

    4. SSH连接Linux工具 4.1 Linux网卡配置 (1)临时配置: ifconfig eth0 192.168.32.100 //给eth0网卡指定IP,写在ROM里的,关机会丢失. (2) ...

  5. hbase连接操作

    hbase连接操作 package com.test; import java.io.IOException; import org.apache.hadoop.conf.Configuration; ...

  6. xmanager远程桌面连接Linux

    远程桌面连接Linux,两种工具:vnc.xmanager xmanager使用参考如下,暂未整理: Xmanager连接Centos的远程桌面 | 大爱 http://lovesoo.org/xma ...

  7. ssh连接linux服务器只显示-bash-4.1#不显示路径解决方法

    ssh连接linux服务器只显示-bash-4.1#不显示路径时,我们只需要修改  ~/.bash_profile文件,如果不存在这个文件,那么新建一个,增加内容  export PS1='[\u@\ ...

  8. windows远程连接Linux(Ubuntu)的方法

    需要做的工作: 1.在Linux(Ubuntu)端安装.设置好SSH 2.下载putty,并通过putty的SSH连接登录Linux 一 .如何在Linux(Ubuntu)端安装.设置好SSH,获取I ...

  9. 记一次VNC远程连接Linux问题解决记录(5900端口测试、KDE桌面安装)

    最近几天,到一个项目上安装Linux部署环境.由于服务器在机房,而进机房又比较麻烦,于是选择VNC远程连接Linux就显得自然而然了.以前也用过VNC,而且还经常使用,由于各个项目环境不太一样,这次也 ...

随机推荐

  1. springcloud系列15 bus的使用

    可以结合wekbbok进行通知: 将更新的代码进行点击就好:

  2. 18-2-call和apply

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. java_static关键字

    /** * static关键字:静态关键字 * 静态优先于非静态加载到内存中(静态优先于对进入到内存中) * 被static修饰的成员变量不能被序列化的,序列化的都是对象 * transient关键字 ...

  4. C++: inheritance

    公有继承(public).私有继承(private).保护继承(protected)是常用的三种继承方式. 1. 公有继承(public) 公有继承的特点是基类的公有成员和保护成员作为派生类的成员时, ...

  5. loj2509 hnoi2018排列

    题意:对于a数组,求它的一个合法排列的最大权值.合法排列:对于任意j,k,如果a[p[j]]=p[k],那么k<j. 权值:sigma(a[p[i]]*i).n<=50W. 标程: #in ...

  6. 进程互斥软件实现之Lamport面包店算法

    一. 进程互斥的实现方式 1. 软件方式: 保护临界区, 自己编写代码来实现对进程的控制. Dekker算法Peterson算法Lamport算法等 2. 硬件方式: 使用特殊指令保护临界区. 开关中 ...

  7. 阿里云 Aliplayer高级功能介绍(四):直播时移

    基本介绍 时移直播基于常规的HLS视频直播,直播推流被切分成TS分片,通过HLS协议向播放用户分发,用户请求的m3u8播放文件中包含不断刷新的TS分片地址:对于常规的HLS直播而言,TS分片地址及相应 ...

  8. 「题解」:[组合数学][DP]:地精部落

    拿到这道题秒懂题意:波动序列. 然鹅不会打.想了一节课,想打纯组合数学,结果找不到规律. 想的是先假设拍出一个序列,然后交换其中的元素求组合, 无奈没啥规律可循,显然不能一口气求出来(我说的是我没办法 ...

  9. HTML值改变事件

    1.动态拼接html[表格中,如bootstrap grid] return '<input type="text" name="bjce" onchan ...

  10. threading.local在flask中的用法

    一.介绍 threading.local的作用: 多个线程修改同一个数据,复制多份变量给每个线程用,为每个线程开辟一块空间进行数据的存储,而每块空间内的数据也不会错乱. 二.不使用threading. ...