hbase连接linux开发过程
最近近公司被安排做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开发过程的更多相关文章
- xshell连接linux,切换焦点,自动执行ctrl+c
这几天发现 xshell 连接 linux 的时候,无缘无故的执行了 ctrl+c,导致 执行界面 终端,比方说 ,hbase shell 执行窗口命令 ,每次切换 窗口焦点之后,就终止了.百度后 发 ...
- Windows远程连接Linux
目录 xrdp方式 vnc方式 xrdp方式 ----------------------------------------------------------------------------- ...
- 1、linux网络服务实验 用PuTTY连接Linux
这个是大三下学期的Linux网络服务配置详解时,感觉老师上得简单,就整理下,岭南师范学院师弟妹有福,如果是蔡老师交的话,可以拿来预习,复习. 一.用PuTTY连接Linux ①.装有redhat系统的 ...
- 第2章 Linux系统安装(3)_SSH连接Linux工具:SecureCRT和WinSCP
4. SSH连接Linux工具 4.1 Linux网卡配置 (1)临时配置: ifconfig eth0 192.168.32.100 //给eth0网卡指定IP,写在ROM里的,关机会丢失. (2) ...
- hbase连接操作
hbase连接操作 package com.test; import java.io.IOException; import org.apache.hadoop.conf.Configuration; ...
- xmanager远程桌面连接Linux
远程桌面连接Linux,两种工具:vnc.xmanager xmanager使用参考如下,暂未整理: Xmanager连接Centos的远程桌面 | 大爱 http://lovesoo.org/xma ...
- ssh连接linux服务器只显示-bash-4.1#不显示路径解决方法
ssh连接linux服务器只显示-bash-4.1#不显示路径时,我们只需要修改 ~/.bash_profile文件,如果不存在这个文件,那么新建一个,增加内容 export PS1='[\u@\ ...
- windows远程连接Linux(Ubuntu)的方法
需要做的工作: 1.在Linux(Ubuntu)端安装.设置好SSH 2.下载putty,并通过putty的SSH连接登录Linux 一 .如何在Linux(Ubuntu)端安装.设置好SSH,获取I ...
- 记一次VNC远程连接Linux问题解决记录(5900端口测试、KDE桌面安装)
最近几天,到一个项目上安装Linux部署环境.由于服务器在机房,而进机房又比较麻烦,于是选择VNC远程连接Linux就显得自然而然了.以前也用过VNC,而且还经常使用,由于各个项目环境不太一样,这次也 ...
随机推荐
- PHP面向对象编程题(方法的实践)
<?php header('content-type:text/html;charset=utf-8'); /*设计一个peron类(有名字,年龄和蛋糕三个属性) 蛋糕一共1000块,是所有人共 ...
- 国外主机如何ICP备案
想都不要想了,无法备案. 因为,备案是在主机服务器提供商处的备案平台提交申请,国外的主机服务商是没有这种平台服务的.(跟你域名在哪儿买的没关系) 下面,把昨天折腾到半夜的过程记录一下,希望可以帮到需要 ...
- IDE 插件新版本发布,开发效率 “biu” 起来了
近日,Cloud Toolkit正式推出了面向 IntelliJ 和 Eclipse 两个平台的新款插件,本文挑选了其中三个重大特性进行解读,点击文末官网跳转链接,可查看详细的版本说明. 本地应用一键 ...
- SpringBoot_02_SpringBoot的配置文件
1.SpringBoot配置文件 SpringBoot是基于约定的,所以很多配置都有默认值,但如果想使用自己的配置替换默认配置的话,就可以使用application.properties或者appli ...
- CPU中的主要的寄存器
寄存器 名为寄存器的存储电路. 8种16位寄存器 AX accumulator 累加寄存器 CX counter 计数寄存器 DX data 数据寄存器 BX base 基址寄存器 SP stack ...
- iOS之UIGraphics.h方法简介
// // UIGraphics.h // UIKit // // Copyright (c) 2005-2017 Apple Inc. All rights reserved. // #import ...
- CentOS源码安装Wireshark
(2019年2月19日注:这篇文章原先发在自己github那边的博客,时间是2016年8月25日) Wireshark为网络管理员常用的一个网络管理工具,通过使用这个软件,我们可以对本机网卡上的经过的 ...
- Spark-内存管理调优
这篇文章主要是对官网内容学习过程的总结,大部分是原文,加上自己的学习笔记!!! spark 2.0+内存模型 调优内存使用时需要考虑三个因素: 对象使用的内存数量(您可能希望您的整个数据集都能装入内存 ...
- momentjs 使用总结
一.安装 cnpm install moment 二.引入 var moment = require('moment') 三.使用 let today = moment().format('YYYY- ...
- 《DSP using MATLAB》Problem 8.30
10月1日,新中国70周岁生日,上午观看了盛大的庆祝仪式,整齐的方阵,先进的武器,尊敬的先辈英雄,欢乐的人们,愿我们的 国家越来越好,人民生活越来越好. 接着做题. 代码: %% ---------- ...